mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-19 11:09:25 +01:00
crypto: Add crypto_derive_pmkid
Calculates the PMKID for given PMK
This commit is contained in:
parent
2b4cb5d586
commit
0f6685bf45
17
src/crypto.c
17
src/crypto.c
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user