diff --git a/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c b/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c index d60db172..e01642bd 100644 --- a/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c +++ b/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c @@ -151,7 +151,7 @@ static const uint8_t PAD[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static void -SHA256_Pad(crypto_hash_sha256_state *state, uint32_t tmp32[72]) +SHA256_Pad(crypto_hash_sha256_state *state, uint32_t tmp32[64 + 8]) { uint64_t r; uint64_t i; @@ -190,16 +190,16 @@ int crypto_hash_sha256_update(crypto_hash_sha256_state *state, const unsigned char *in, unsigned long long inlen) { - uint32_t tmp32[72]; - uint64_t i; - uint64_t r; + uint32_t tmp32[64 + 8]; + unsigned long long i; + unsigned long long r; if (inlen <= 0U) { return 0; } - r = (state->count >> 3) & 0x3f; - state->count += (uint64_t)(inlen) << 3; + r = (unsigned long long) ((state->count >> 3) & 0x3f); + state->count += ((uint64_t) inlen) << 3; if (inlen < 64 - r) { for (i = 0; i < inlen; i++) { state->buf[r + i] = in[i]; @@ -230,7 +230,7 @@ crypto_hash_sha256_update(crypto_hash_sha256_state *state, int crypto_hash_sha256_final(crypto_hash_sha256_state *state, unsigned char *out) { - uint32_t tmp32[72]; + uint32_t tmp32[64 + 8]; SHA256_Pad(state, tmp32); be32enc_vect(out, state->state, 32); diff --git a/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c b/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c index a8bdf6ec..39e658bc 100644 --- a/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c +++ b/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c @@ -170,7 +170,7 @@ static const uint8_t PAD[128] = { }; static void -SHA512_Pad(crypto_hash_sha512_state *state, uint64_t tmp64[88]) +SHA512_Pad(crypto_hash_sha512_state *state, uint64_t tmp64[80 + 8]) { uint64_t r; uint64_t i; @@ -210,15 +210,15 @@ int crypto_hash_sha512_update(crypto_hash_sha512_state *state, const unsigned char *in, unsigned long long inlen) { - uint64_t tmp64[88]; - uint64_t bitlen[2]; - uint64_t i; - uint64_t r; + uint64_t tmp64[80 + 8]; + uint64_t bitlen[2]; + unsigned long long i; + unsigned long long r; if (inlen <= 0U) { return 0; } - r = (state->count[1] >> 3) & 0x7f; + r = (unsigned long long) ((state->count[1] >> 3) & 0x7f); bitlen[1] = ((uint64_t) inlen) << 3; bitlen[0] = ((uint64_t) inlen) >> 61; @@ -256,7 +256,7 @@ crypto_hash_sha512_update(crypto_hash_sha512_state *state, int crypto_hash_sha512_final(crypto_hash_sha512_state *state, unsigned char *out) { - uint64_t tmp64[88]; + uint64_t tmp64[80 + 8]; SHA512_Pad(state, tmp64); be64enc_vect(out, state->state, 64); diff --git a/src/libsodium/include/sodium/crypto_hash_sha256.h b/src/libsodium/include/sodium/crypto_hash_sha256.h index 14115c0f..d538cf6c 100644 --- a/src/libsodium/include/sodium/crypto_hash_sha256.h +++ b/src/libsodium/include/sodium/crypto_hash_sha256.h @@ -22,9 +22,9 @@ extern "C" { #endif typedef struct crypto_hash_sha256_state { - uint32_t state[8]; - uint64_t count; - unsigned char buf[64]; + uint32_t state[8]; + uint64_t count; + uint8_t buf[64]; } crypto_hash_sha256_state; SODIUM_EXPORT size_t crypto_hash_sha256_statebytes(void); diff --git a/src/libsodium/include/sodium/crypto_hash_sha512.h b/src/libsodium/include/sodium/crypto_hash_sha512.h index ba8864bd..2af7426a 100644 --- a/src/libsodium/include/sodium/crypto_hash_sha512.h +++ b/src/libsodium/include/sodium/crypto_hash_sha512.h @@ -22,9 +22,9 @@ extern "C" { #endif typedef struct crypto_hash_sha512_state { - uint64_t state[8]; - uint64_t count[2]; - unsigned char buf[128]; + uint64_t state[8]; + uint64_t count[2]; + uint8_t buf[128]; } crypto_hash_sha512_state; SODIUM_EXPORT size_t crypto_hash_sha512_statebytes(void);