-
Notifications
You must be signed in to change notification settings - Fork 2k
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
hashes/sha2{24,56}: Remove static variables from sha256 #20116
Conversation
sys/include/hashes/sha256.h
Outdated
@@ -132,7 +132,7 @@ static inline void sha256_final(sha256_context_t *ctx, void *digest) | |||
* be SHA256_DIGEST_LENGTH | |||
* if digest == NULL, one static buffer is used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd need to adapt the documentation as well (in other places, too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I just did a quick scan for a doxygen @return
and nothing showed up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted the docs
4ef7b88
to
d1b197a
Compare
And removed the return argument from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM then. Since this is an API breaking change, do we need to note that somewhere for the next release notes?
Please squash |
I assume you have checked that no existing code calls the functions with passing a NULL pointer for |
That code would need to make use of the return value, which by changing the signature will result in a compilation error that Murdock should catch. |
Valid point. 😊 |
ping @bergzand for squashing |
This removes the static (thread-unsafe) variables from sha256 and hmac_sha256 to remove a potential footgun. The static variable is only used when the caller does not supply a pointer to store the digest and it is returned via the (undocumented) return value. This commit removes this option and makes the digest argument mandatory.
cb9a210
to
434e564
Compare
Done, sorry for the delay! |
Contribution description
This removes the static (thread-unsafe) variables from sha256 and hmac_sha256 to remove a potential footgun. The static variable is only used when the caller does not supply a pointer to store the digest and it is returned via the (undocumented) return value.
This commit removes this option and makes the digest argument mandatory.
Testing procedure
The tests-hashes unittest should still work:
Issues/PRs references
Introduced in #124