EAP-IKEv2: Check HMAC SHA1/MD5 result
Make the IKEv2 helper functions return a possible error return from the HMAC routines. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
d1341917ce
commit
5c8acf7d96
1 changed files with 7 additions and 8 deletions
|
@ -62,13 +62,15 @@ int ikev2_integ_hash(int alg, const u8 *key, size_t key_len, const u8 *data,
|
||||||
case AUTH_HMAC_SHA1_96:
|
case AUTH_HMAC_SHA1_96:
|
||||||
if (key_len != 20)
|
if (key_len != 20)
|
||||||
return -1;
|
return -1;
|
||||||
hmac_sha1(key, key_len, data, data_len, tmphash);
|
if (hmac_sha1(key, key_len, data, data_len, tmphash) < 0)
|
||||||
|
return -1;
|
||||||
os_memcpy(hash, tmphash, 12);
|
os_memcpy(hash, tmphash, 12);
|
||||||
break;
|
break;
|
||||||
case AUTH_HMAC_MD5_96:
|
case AUTH_HMAC_MD5_96:
|
||||||
if (key_len != 16)
|
if (key_len != 16)
|
||||||
return -1;
|
return -1;
|
||||||
hmac_md5(key, key_len, data, data_len, tmphash);
|
if (hmac_md5(key, key_len, data, data_len, tmphash) < 0)
|
||||||
|
return -1;
|
||||||
os_memcpy(hash, tmphash, 12);
|
os_memcpy(hash, tmphash, 12);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -98,16 +100,13 @@ int ikev2_prf_hash(int alg, const u8 *key, size_t key_len,
|
||||||
{
|
{
|
||||||
switch (alg) {
|
switch (alg) {
|
||||||
case PRF_HMAC_SHA1:
|
case PRF_HMAC_SHA1:
|
||||||
hmac_sha1_vector(key, key_len, num_elem, addr, len, hash);
|
return hmac_sha1_vector(key, key_len, num_elem, addr, len,
|
||||||
break;
|
hash);
|
||||||
case PRF_HMAC_MD5:
|
case PRF_HMAC_MD5:
|
||||||
hmac_md5_vector(key, key_len, num_elem, addr, len, hash);
|
return hmac_md5_vector(key, key_len, num_elem, addr, len, hash);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue