commit 7c779956ac3346e70c9380fc5ec86cdd2e9ea487
parent 68e612573e41fdd8f6a98b1a1164b6f5069154a4
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Sat, 22 Sep 2018 18:48:15 +0200
handshake: Add handshake_util_build_gtk_kde utility
Diffstat:
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/handshake.c b/src/handshake.c
@@ -651,6 +651,21 @@ const uint8_t *handshake_util_find_pmkid_kde(const uint8_t *data,
return pmkid;
}
+/* Defined in 802.11-2016 12.7.2 j), Figure 12-34 */
+void handshake_util_build_gtk_kde(enum crypto_cipher cipher, const uint8_t *key,
+ unsigned int key_index, uint8_t *to)
+{
+ size_t key_len = crypto_cipher_key_len(cipher);
+
+ *to++ = IE_TYPE_VENDOR_SPECIFIC;
+ *to++ = 6 + key_len;
+ l_put_be32(HANDSHAKE_KDE_GTK, to);
+ to += 4;
+ *to++ = key_index;
+ *to++ = 0;
+ memcpy(to, key, key_len);
+}
+
/*
* Unwrap a GTK / IGTK included in an FTE following 802.11-2012, Section 12.8.5:
*
diff --git a/src/handshake.h b/src/handshake.h
@@ -26,6 +26,7 @@
#include <linux/types.h>
struct handshake_state;
+enum crypto_cipher;
/* 802.11-2016 Table 12-6 in section 12.7.2 */
enum handshake_kde {
@@ -194,6 +195,8 @@ const uint8_t *handshake_util_find_igtk_kde(const uint8_t *data,
size_t data_len, size_t *out_igtk_len);
const uint8_t *handshake_util_find_pmkid_kde(const uint8_t *data,
size_t data_len);
+void handshake_util_build_gtk_kde(enum crypto_cipher cipher, const uint8_t *key,
+ unsigned int key_index, uint8_t *to);
void handshake_event(struct handshake_state *hs, enum handshake_event event,
void *event_data);