hashes/sha2{24,56}: Remove static variables from sha256#20116
hashes/sha2{24,56}: Remove static variables from sha256#20116mguetschow merged 2 commits intoRIOT-OS:masterfrom
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.
You'd need to adapt the documentation as well (in other places, too).
There was a problem hiding this comment.
Thanks! I just did a quick scan for a doxygen @return and nothing showed up.
4ef7b88 to
d1b197a
Compare
|
And removed the return argument from |
mguetschow
left a comment
There was a problem hiding this comment.
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