mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-25 08:02:38 +01:00
crypto: Prepare for SHA256 based PTK derivation
This commit is contained in:
parent
55e47c10c8
commit
e084839b4f
16
src/crypto.c
16
src/crypto.c
@ -400,10 +400,12 @@ bool kdf_sha256(const void *key, size_t key_len,
|
|||||||
* Max operations for nonces are with the nonces treated as positive integers
|
* Max operations for nonces are with the nonces treated as positive integers
|
||||||
* converted as specified in 8.2.2.
|
* converted as specified in 8.2.2.
|
||||||
*/
|
*/
|
||||||
bool crypto_derive_ptk(const uint8_t *pmk, size_t pmk_len, const char *label,
|
static bool crypto_derive_ptk(const uint8_t *pmk, size_t pmk_len,
|
||||||
|
const char *label,
|
||||||
const uint8_t *addr1, const uint8_t *addr2,
|
const uint8_t *addr1, const uint8_t *addr2,
|
||||||
const uint8_t *nonce1, const uint8_t *nonce2,
|
const uint8_t *nonce1, const uint8_t *nonce2,
|
||||||
uint8_t *out_ptk, size_t ptk_len)
|
uint8_t *out_ptk, size_t ptk_len,
|
||||||
|
bool use_sha256)
|
||||||
{
|
{
|
||||||
/* Nonce length is 32 */
|
/* Nonce length is 32 */
|
||||||
uint8_t data[ETH_ALEN * 2 + 64];
|
uint8_t data[ETH_ALEN * 2 + 64];
|
||||||
@ -431,6 +433,10 @@ bool crypto_derive_ptk(const uint8_t *pmk, size_t pmk_len, const char *label,
|
|||||||
|
|
||||||
pos += 64;
|
pos += 64;
|
||||||
|
|
||||||
|
if (use_sha256)
|
||||||
|
return kdf_sha256(pmk, pmk_len, label, strlen(label),
|
||||||
|
data, sizeof(data), out_ptk, ptk_len);
|
||||||
|
else
|
||||||
return prf_sha1(pmk, pmk_len, label, strlen(label),
|
return prf_sha1(pmk, pmk_len, label, strlen(label),
|
||||||
data, sizeof(data), out_ptk, ptk_len);
|
data, sizeof(data), out_ptk, ptk_len);
|
||||||
}
|
}
|
||||||
@ -438,9 +444,11 @@ bool crypto_derive_ptk(const uint8_t *pmk, size_t pmk_len, const char *label,
|
|||||||
bool crypto_derive_pairwise_ptk(const uint8_t *pmk,
|
bool crypto_derive_pairwise_ptk(const uint8_t *pmk,
|
||||||
const uint8_t *addr1, const uint8_t *addr2,
|
const uint8_t *addr1, const uint8_t *addr2,
|
||||||
const uint8_t *nonce1, const uint8_t *nonce2,
|
const uint8_t *nonce1, const uint8_t *nonce2,
|
||||||
struct crypto_ptk *out_ptk, size_t ptk_len)
|
struct crypto_ptk *out_ptk, size_t ptk_len,
|
||||||
|
bool use_sha256)
|
||||||
{
|
{
|
||||||
return crypto_derive_ptk(pmk, 32, "Pairwise key expansion",
|
return crypto_derive_ptk(pmk, 32, "Pairwise key expansion",
|
||||||
addr1, addr2, nonce1, nonce2,
|
addr1, addr2, nonce1, nonce2,
|
||||||
(uint8_t *) out_ptk, ptk_len);
|
(uint8_t *) out_ptk, ptk_len,
|
||||||
|
use_sha256);
|
||||||
}
|
}
|
||||||
|
@ -69,12 +69,8 @@ bool prf_sha1(const void *key, size_t key_len,
|
|||||||
const void *prefix, size_t prefix_len,
|
const void *prefix, size_t prefix_len,
|
||||||
const void *data, size_t data_len, void *output, size_t size);
|
const void *data, size_t data_len, void *output, size_t size);
|
||||||
|
|
||||||
bool crypto_derive_ptk(const uint8_t *pmk, size_t pmk_len, const char *label,
|
|
||||||
const uint8_t *addr1, const uint8_t *addr2,
|
|
||||||
const uint8_t *nonce1, const uint8_t *nonce2,
|
|
||||||
uint8_t *out_ptk, size_t ptk_len);
|
|
||||||
|
|
||||||
bool crypto_derive_pairwise_ptk(const uint8_t *pmk,
|
bool crypto_derive_pairwise_ptk(const uint8_t *pmk,
|
||||||
const uint8_t *addr1, const uint8_t *addr2,
|
const uint8_t *addr1, const uint8_t *addr2,
|
||||||
const uint8_t *nonce1, const uint8_t *nonce2,
|
const uint8_t *nonce1, const uint8_t *nonce2,
|
||||||
struct crypto_ptk *out_ptk, size_t ptk_len);
|
struct crypto_ptk *out_ptk, size_t ptk_len,
|
||||||
|
bool use_sha256);
|
||||||
|
Loading…
Reference in New Issue
Block a user