← index #8017Issue #235
Related · high · value 0.415
QUERY · ISSUE

SHA512 and hashlib port

openby willianpaixaoopened 2021-11-20updated 2024-10-01
enhancement

At the moment, Micropython supports SHA1 and SHA256.

I would like to suggest addition of more algorithms, in specific SHA512.
It's already implemented in micropython-lib and of course at cpython itself.

CANDIDATE · ISSUE

Hashlib questions (use of uhashlib, native code otherwise present, ripemd160)

closedby doc-hexopened 2017-11-22updated 2023-07-21

I have some questions and comments about the hashlib module.

  1. Some boards/ports have sha256, sha1 and others, as part of the binary already (particularly when SSL is being used). Some of these are made available in uhashlib, and so IMHO hashlib should use those versions since they are both faster and smaller than anything we can do in pure python. It looks to me like sha256 is guaranteed to be there (if uhashlib exists) and SHA1 may exist if MICROPY_PY_UHASHLIB_SHA1 is set.

  2. It pains me that lib/axtls/crypto contains lots of hash functions that could be part of uhashlib, plus AES and other primitives. That belongs as an issue against axtls though.

  3. hashlib.new() seems like a useful addition to implement, since that would allow pruning of algorithms that aren't needed on today's project, and if this module is rewritten in C, it becomes a great place to extend with native versions, when available.

  4. I need to have ripemd160 but I don't think it's common enough to bother weighing-down this module for everyone.

I'm going to follow-up with pull requests for 1 and 3, and maybe 4 if there is interest.

Any thoughts?

1 comment
dpgeorge · 2023-07-21

Point 1 should be fixed by da5ddfc6e21e8b2d680a74826bcf2652aa8e75ee

Point 3 (addition of new()) was done a while ago in 175634b3cdf3a9269f5f6f9f8e76dbd524e24c44

For point 4, hashlib is now implemented as a set of components and you only need to install what your program will use. So adding hashlib-ripemd160 (or any other algo) is relatively easy.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied