diff options
Diffstat (limited to 'src/crypto/sha/sha256.c')
-rw-r--r-- | src/crypto/sha/sha256.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/crypto/sha/sha256.c b/src/crypto/sha/sha256.c index 8d4106e..8276bbb 100644 --- a/src/crypto/sha/sha256.c +++ b/src/crypto/sha/sha256.c @@ -144,10 +144,13 @@ int SHA224_Final(uint8_t *md, SHA256_CTX *ctx) { * to truncate to amount of bytes not divisible by 4. I bet not, but if it is, * then default: case shall be extended. For reference. Idea behind separate * cases for pre-defined lenghts is to let the compiler decide if it's - * appropriate to unroll small loops. */ + * appropriate to unroll small loops. + * + * TODO(davidben): The small |md_len| case is one of the few places a low-level + * hash 'final' function can fail. This should never happen. */ #define HASH_MAKE_STRING(c, s) \ do { \ - unsigned long ll; \ + uint32_t ll; \ unsigned int nn; \ switch ((c)->md_len) { \ case SHA224_DIGEST_LENGTH: \ @@ -163,8 +166,9 @@ int SHA224_Final(uint8_t *md, SHA256_CTX *ctx) { } \ break; \ default: \ - if ((c)->md_len > SHA256_DIGEST_LENGTH) \ + if ((c)->md_len > SHA256_DIGEST_LENGTH) { \ return 0; \ + } \ for (nn = 0; nn < (c)->md_len / 4; nn++) { \ ll = (c)->h[nn]; \ (void) HOST_l2c(ll, (s)); \ @@ -232,7 +236,7 @@ static const HASH_LONG K256[64] = { static void sha256_block_data_order(SHA256_CTX *ctx, const void *in, size_t num) { - unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1; + uint32_t a, b, c, d, e, f, g, h, s0, s1, T1; HASH_LONG X[16]; int i; const uint8_t *data = in; |