]> git.ozlabs.org Git - ccan/commitdiff
sha256: Move 'bytes' to the end of sha256_ctx and make it a size_t
authorJon Griffiths <jon_p_griffiths@yahoo.com>
Tue, 22 Mar 2016 22:54:50 +0000 (11:54 +1300)
committerJon Griffiths <jon_p_griffiths@yahoo.com>
Mon, 22 Aug 2016 12:30:25 +0000 (00:30 +1200)
The code already assigns to/from bytes as a size_t, so make it
official (and better on platforms with a 32 bit size_t).

Moving bytes makes it act as a canary in the event that there is a rogue
write/off by one somewhere - since it ends up in the hash we are
more likely to detect this should we corrupt it. This also makes the
working buffer better aligned which can't hurt.

Also, initialise the buffer to zero while we are changing the initialisation
macro anyway. It costs little compared to the hashing overhead, should be
optimised away if redundant in most cases, and it removes a warning from both
gcc and clang about unititialised struct members.

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>

No differences found