From 5935cf7a7e393fc57964c432a1c380e262ce8de2 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 24 Oct 2017 21:57:30 +0200 Subject: [PATCH] Use uint instead of uint64_t for SHA* padding Workaround for a clang bug --- src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c | 6 +++--- src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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 302d32a1..264054f9 100644 --- a/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c +++ b/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c @@ -153,10 +153,10 @@ static const uint8_t PAD[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, static void SHA256_Pad(crypto_hash_sha256_state *state, uint32_t tmp32[64 + 8]) { - uint64_t r; - uint64_t i; + unsigned int r; + unsigned int i; - r = (state->count >> 3) & 0x3f; + r = (unsigned int) ((state->count >> 3) & 0x3f); if (r < 56) { for (i = 0; i < 56 - r; i++) { state->buf[r + i] = PAD[i]; 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 8d0f2536..8e0f36fb 100644 --- a/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c +++ b/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c @@ -172,10 +172,10 @@ static const uint8_t PAD[128] = { static void SHA512_Pad(crypto_hash_sha512_state *state, uint64_t tmp64[80 + 8]) { - uint64_t r; - uint64_t i; + unsigned int r; + unsigned int i; - r = (state->count[1] >> 3) & 0x7f; + r = (unsigned int) ((state->count[1] >> 3) & 0x7f); if (r < 112) { for (i = 0; i < 112 - r; i++) { state->buf[r + i] = PAD[i];