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

@ -601,13 +601,10 @@ static char *str_printf(const char *fmt, ...)
*/
static uint32_t calculate_diveid(const unsigned char *fingerprint, unsigned int fsize)
{
uint32_t csum[5];
if (!fingerprint || !fsize)
return 0;
SHA1(fingerprint, fsize, (unsigned char *)csum);
return csum[0];
return SHA1_uint32(fingerprint, fsize);
}
uint32_t calculate_string_hash(const char *str)