3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-24 15:22:34 +01:00

crypto: Add crypto_derive_pmkid

Calculates the PMKID for given PMK
This commit is contained in:
Andrew Zaborowski 2017-04-15 13:58:44 +02:00 committed by Denis Kenzior
parent 2b4cb5d586
commit 0f6685bf45
2 changed files with 21 additions and 0 deletions

View File

@ -625,3 +625,20 @@ exit:
return r;
}
/* Defined in 802.11-2012, Section 11.6.1.3 Pairwise Key Hierarchy */
bool crypto_derive_pmkid(const uint8_t *pmk,
const uint8_t *addr1, const uint8_t *addr2,
uint8_t *out_pmkid, bool use_sha256)
{
uint8_t data[20];
memcpy(data + 0, "PMK Name", 8);
memcpy(data + 8, addr2, 6);
memcpy(data + 14, addr1, 6);
if (use_sha256)
return hmac_sha256(pmk, 32, data, 20, out_pmkid, 16);
else
return hmac_sha1(pmk, 32, data, 20, out_pmkid, 16);
}

View File

@ -108,3 +108,7 @@ bool crypto_derive_ft_ptk(const uint8_t *pmk_r1, const uint8_t *pmk_r1_name,
const uint8_t *nonce1, const uint8_t *nonce2,
struct crypto_ptk *out_ptk, size_t ptk_len,
uint8_t *out_ptk_name);
bool crypto_derive_pmkid(const uint8_t *pmk,
const uint8_t *addr1, const uint8_t *addr2,
uint8_t *out_pmkid, bool use_sha256);