mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 17:59:25 +01:00
eapol: Add eapol_decrypt_key_data
This commit is contained in:
parent
a1d00805a4
commit
cd08cdfd9f
33
src/eapol.c
33
src/eapol.c
@ -68,6 +68,39 @@ bool eapol_calculate_mic(const uint8_t *kck, const struct eapol_key *frame,
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *eapol_decrypt_key_data(const uint8_t *kek,
|
||||
const struct eapol_key *frame)
|
||||
{
|
||||
size_t key_data_len = L_BE16_TO_CPU(frame->key_data_len);
|
||||
struct l_cipher *cipher;
|
||||
uint8_t *buf;
|
||||
bool ret;
|
||||
|
||||
switch (frame->key_descriptor_version) {
|
||||
case EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4:
|
||||
/* TODO: This might require an IV from frame->eapol_key_iv */
|
||||
cipher = l_cipher_new(L_CIPHER_ARC4, kek, 16);
|
||||
break;
|
||||
case EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_SHA1_AES:
|
||||
case EAPOL_KEY_DESCRIPTOR_VERSION_AES_128_CMAC_AES:
|
||||
cipher = l_cipher_new(L_CIPHER_AES, kek, 16);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
};
|
||||
|
||||
buf = l_new(uint8_t, key_data_len);
|
||||
ret = l_cipher_decrypt(cipher, frame->key_data, buf, key_data_len);
|
||||
l_cipher_free(cipher);
|
||||
|
||||
if (!ret) {
|
||||
l_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
const struct eapol_key *eapol_key_validate(const uint8_t *frame, size_t len)
|
||||
{
|
||||
const struct eapol_key *ek;
|
||||
|
@ -96,6 +96,9 @@ struct eapol_key {
|
||||
bool eapol_calculate_mic(const uint8_t *kck, const struct eapol_key *frame,
|
||||
uint8_t *mic);
|
||||
|
||||
uint8_t *eapol_decrypt_key_data(const uint8_t *kek,
|
||||
const struct eapol_key *frame);
|
||||
|
||||
const struct eapol_key *eapol_key_validate(const uint8_t *frame, size_t len);
|
||||
|
||||
const struct eapol_key *eapol_verify_ptk_1_of_4(const uint8_t *frame,
|
||||
|
Loading…
Reference in New Issue
Block a user