From 5e7771ef66ed1ac16f807d4c1fe59c4f52af6a2c Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 26 Dec 2014 14:14:02 -0600 Subject: [PATCH] crypto: Add crypto_derive_pairwise_ptk --- src/crypto.c | 10 ++++++++++ src/crypto.h | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/crypto.c b/src/crypto.c index 9e3b0020..07c6313f 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -161,3 +161,13 @@ bool crypto_derive_ptk(const uint8_t *pmk, size_t pmk_len, const char *label, return prf_sha1(pmk, pmk_len, label, strlen(label), data, sizeof(data), out_ptk, ptk_len); } + +bool crypto_derive_pairwise_ptk(const uint8_t *pmk, + const uint8_t *addr1, const uint8_t *addr2, + const uint8_t *nonce1, const uint8_t *nonce2, + struct crypto_ptk *out_ptk, size_t ptk_len) +{ + return crypto_derive_ptk(pmk, 32, "Pairwise key expansion", + addr1, addr2, nonce1, nonce2, + (uint8_t *) out_ptk, ptk_len); +} diff --git a/src/crypto.h b/src/crypto.h index 19eb0470..1941dd27 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -31,6 +31,12 @@ enum crypto_cipher { CRYPTO_CIPHER_BIP, }; +struct crypto_ptk { + uint8_t kck[16]; + uint8_t kek[16]; + uint8_t tk[0]; +}; + int crypto_cipher_key_len(enum crypto_cipher cipher); int crypto_cipher_tk_bits(enum crypto_cipher cipher); @@ -42,3 +48,8 @@ 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, + const uint8_t *addr1, const uint8_t *addr2, + const uint8_t *nonce1, const uint8_t *nonce2, + struct crypto_ptk *out_ptk, size_t ptk_len);