diff --git a/sha1sum.c b/sha1sum.c index 934af9f..552e8d7 100644 --- a/sha1sum.c +++ b/sha1sum.c @@ -35,7 +35,7 @@ rol( u32 x, int n) } typedef struct { - u64 count; + u32 count; union { struct { u32 h0, h1, h2, h3, h4; @@ -188,7 +188,7 @@ sha1_final(SHA1_CONTEXT *hd, u8 hash[SHA1_DIGEST_SIZE]) /* append the 64 bit count */ u64 *count = (void *)&hd->buf[56]; - *count = cpu_to_be64(hd->count << 3); + *count = cpu_to_be64((u64)hd->count << 3); sha1_transform(hd, hd->buf); u32 *p = (void *)hash; diff --git a/sha256.c b/sha256.c index e32cf83..492ce3a 100644 --- a/sha256.c +++ b/sha256.c @@ -23,7 +23,7 @@ struct sha256_state { u32 state[SHA256_DIGEST_SIZE / 4]; - u64 count; + u32 count; u8 buf[SHA256_BLOCK_SIZE]; }; @@ -178,7 +178,7 @@ static void sha256_final(struct sha256_state *sctx, void *_dst) /* Append the 64 bit count */ count = (void *)&sctx->buf[56]; - *count = cpu_to_be64(sctx->count << 3); + *count = cpu_to_be64((u64)sctx->count << 3); sha256_transform(sctx->state, sctx->buf); /* Store state in digest */