From: Jon Griffiths Date: Tue, 22 Mar 2016 22:54:50 +0000 (+1300) Subject: sha256: Move 'bytes' to the end of sha256_ctx and make it a size_t X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=fe21b246647e4694da5f76e0fd00e9a9f9e8c72e;hp=fe21b246647e4694da5f76e0fd00e9a9f9e8c72e sha256: Move 'bytes' to the end of sha256_ctx and make it a size_t 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 ---