3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2025-01-03 10:32:33 +01:00

simutil: Optimize l_checksum usage

The checksum object was created / destroyed repeatedly.  It was
sufficient to simply call checksum_reset since the key was never
changed.
This commit is contained in:
Andrew Zaborowski 2019-03-19 01:25:25 +01:00 committed by Denis Kenzior
parent aa7abb44c5
commit c80b239b93

View File

@ -203,6 +203,10 @@ bool eap_aka_prf_prime(const uint8_t *ik_p, const uint8_t *ck_p,
memcpy(key, ik_p, EAP_AKA_IK_LEN);
memcpy(key + EAP_AKA_IK_LEN, ck_p, EAP_AKA_CK_LEN);
hmac = l_checksum_new_hmac(L_CHECKSUM_SHA256, key, 32);
if (!hmac)
return false;
iov[0].iov_base = digest;
/* initial iteration digest is not used */
iov[0].iov_len = 0;
@ -215,13 +219,9 @@ bool eap_aka_prf_prime(const uint8_t *ik_p, const uint8_t *ck_p,
/* need 208 bytes for all keys */
while (pos < out + 224) {
hmac = l_checksum_new_hmac(L_CHECKSUM_SHA256, key, 32);
if (!hmac)
return false;
l_checksum_reset(hmac);
l_checksum_updatev(hmac, iov, 4);
l_checksum_get_digest(hmac, digest, 32);
l_checksum_free(hmac);
memcpy(pos, digest, 32);
pos += 32;
i++;
@ -229,6 +229,8 @@ bool eap_aka_prf_prime(const uint8_t *ik_p, const uint8_t *ck_p,
iov[0].iov_len = 32;
}
l_checksum_free(hmac);
pos = out;
memcpy(k_encr, pos, EAP_SIM_K_ENCR_LEN);
pos += EAP_SIM_K_ENCR_LEN;