[Toybox] patch: add built-in versions of sha-2 family hash functions
Dan Brown
danbrown at gmail.com
Mon May 31 17:17:37 PDT 2021
Hello- here is a patch that provides these hash functions using built-in
routines instead of relying on the OpenSSL library.
sha224sum
sha256sum
sha384sum
sha512sum
Regarding the license, this is based on the wikipedia page for SHA-2
<https://en.wikipedia.org/wiki/SHA-2>, and doesn't use any existing code.
The example intermediate calculations from the NIST
<https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values>
were helpful in debugging.
Comments and suggestions are welcome. Here are a few thoughts and questions
for the list:
Tests. Do I need to add some? Please point me to an example.
How to deal with endianness? How should I test the behavior of a big-endian
system when developing on a little-endian system?
I changed the data types to be explicitly sized (eg. uint32_t instead of
int). Or is this already taken care of as part of the portability functions?
SHA512 (and SHA384) are a bit tricky. I couldn't figure out how to
calculate the constants to the full 64-bit precision needed. Let me know if
there are data types >64bit and corresponding math functions (cube root and
floor) that are possible.
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210601/308a709d/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-sha2-2021-05-31.patch
Type: text/x-patch
Size: 50821 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210601/308a709d/attachment-0002.bin>
More information about the Toybox
mailing list