• Jon Griffiths's avatar
    sha256: Move 'bytes' to the end of sha256_ctx and make it a size_t · fe21b246
    Jon Griffiths authored
    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: default avatarJon Griffiths <jon_p_griffiths@yahoo.com>
    fe21b246
sha256.c 10.6 KB