Skip to content

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

Closed
@doc-hex

Description

@doc-hex

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions