core: replace SHA1() function by SHA1_uint32()

The SHA1() helper function was only used when calculating a
SHA1 hash and taking the first four bytes of it as uint32.

Make that explicit by renaming the function into SHA1_uint32()
and directly returning an uint32_t.

Note that the usage in cochran.cpp is sketchy: it generates
a four-byte hash out of two-byte data. Why!?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-04-23 15:28:11 +08:00 committed by bstoeger
parent 0b817e468a
commit b24f37fb4f
4 changed files with 17 additions and 18 deletions

View file

@ -29,15 +29,8 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
#define SHA1_Update blk_SHA1_Update
#define SHA1_Final blk_SHA1_Final
/* Trivial helper function */
static inline void SHA1(const void *dataIn, unsigned long len, unsigned char hashout[20])
{
SHA_CTX ctx;
SHA1_Init(&ctx);
SHA1_Update(&ctx, dataIn, len);
SHA1_Final(hashout, &ctx);
}
/* Helper function that calculates an SHA1 has and returns the first 4 bytes as uint32_t */
uint32_t SHA1_uint32(const void *dataIn, unsigned long len);
#ifdef __cplusplus
}