cmac+hash: change parameter types

For consistency and safety, change the CMC and HSH functions to accept
signed lengths and handle negative values as errors. Also, change the
input data type to void * to not require casting in the caller.
This commit is contained in:
Miroslav Lichvar
2020-07-08 12:02:12 +02:00
parent de4ecc72d1
commit d93aa10bac
13 changed files with 64 additions and 53 deletions

View File

@@ -84,14 +84,16 @@ HSH_GetHashId(HSH_Algorithm algorithm)
return id;
}
unsigned int
HSH_Hash(int id, const unsigned char *in1, unsigned int in1_len,
const unsigned char *in2, unsigned int in2_len,
unsigned char *out, unsigned int out_len)
int
HSH_Hash(int id, const void *in1, int in1_len, const void *in2, int in2_len,
unsigned char *out, int out_len)
{
const struct nettle_hash *hash;
void *context;
if (in1_len < 0 || in2_len < 0 || out_len < 0)
return 0;
hash = hashes[id].nettle_hash;
context = hashes[id].context;