-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SHA-512/224 and SHA-512/256 hash functions #55
Conversation
Ok. It isn’t as easy as I thought. Found test with longer messages, and for them it does not work (only for one block messages). I believe I’ll need to make proxy structs with 512 bits output for both hash functions and copying first bytes of result. |
I think that we should find way to achieve writing |
Use `copy_nonoverlapping` instead loops This resolves issue with strange SHA-512/224 additional struct in #55.
Could you fix the PR to not use |
Will do that soon. User cannot truncate output by himself from SHA-512 because the initial values are different. SHA-512/224 and SHA-512/256 are practically identical to SHA-384 in terms of relation to SHA-512. SHA-384 is not called SHA-512/384 probably only because there is no 384 hash function using 32 bit words. |
…a512_224 and Sha512_256 to Sha512224 and Sha512256
There were the following issues with your Pull Request
Guidelines are available at https://github.com/libOctavo/octavo/blob/master/CONTRIBUTING.md This message was auto-generated by https://gitcop.com |
@homu r+ |
📌 Commit 8be3dfc has been approved by |
⚡ Test exempted - status |
Add SHA-512/224 and SHA-512/256 hash functions SHA2-512/224 and SHA-512/256 implemented, using existing macros for sha2 functions. However, SHA2-512/224 has 224 bits, and that is not a multiple of 64. Thus, `write_u64()` used for writing state to resulting `out` slice cannot be used directly (as it would copy 4 bytes to few to out, or 4 to many). Because of that a *proxy* struct `_Sha512_224` which outputs 256 bits is created, and its methods are simply called by proper `Sha512_224` struct. In the `result()` method a new vec, `res` is created, result is written to it, and then 28 first bytes are copied to `out` using a simple for loop. SHA2-512/256 is implemented with just `impl_sha!(high Sha512_256, SHA512_256_INIT, 256)`. It closes #47.
SHA2-512/224 and SHA-512/256 implemented, using existing macros for sha2 functions. However, SHA2-512/224 has 224 bits, and that is not a multiple of 64. Thus,
write_u64()
used for writing state to resultingout
slice cannot be used directly (as it would copy 4 bytes to few to out, or 4 to many).Because of that a proxy struct
_Sha512_224
which outputs 256 bits is created, and its methods are simply called by properSha512_224
struct. In theresult()
method a new vec,res
is created, result is written to it, and then 28 first bytes are copied toout
using a simple for loop.SHA2-512/256 is implemented with just
impl_sha!(high Sha512_256, SHA512_256_INIT, 256)
.It closes #47.