From 6c4726189c5844fe39e3be0d4f1206ba8b4c8c36 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 8 Oct 2017 16:35:29 +0300 Subject: [PATCH] OWE: Extend shared helper functions to support other DH curves This extends the helper functions for determining OWE key lengths and Key MIC values to support other DH curves beyond the mandatory group 19. Signed-off-by: Jouni Malinen --- src/common/wpa_common.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c index 13323bf9f..966d737c9 100644 --- a/src/common/wpa_common.c +++ b/src/common/wpa_common.c @@ -33,6 +33,8 @@ static unsigned int wpa_kck_len(int akmp, size_t pmk_len) return 0; case WPA_KEY_MGMT_DPP: return pmk_len / 2; + case WPA_KEY_MGMT_OWE: + return pmk_len / 2; default: return 16; } @@ -51,6 +53,8 @@ static unsigned int wpa_kek_len(int akmp, size_t pmk_len) return 32; case WPA_KEY_MGMT_DPP: return pmk_len <= 32 ? 16 : 32; + case WPA_KEY_MGMT_OWE: + return pmk_len <= 32 ? 16 : 32; default: return 16; } @@ -69,6 +73,8 @@ unsigned int wpa_mic_len(int akmp, size_t pmk_len) return 0; case WPA_KEY_MGMT_DPP: return pmk_len / 2; + case WPA_KEY_MGMT_OWE: + return pmk_len / 2; default: return 16; } @@ -146,10 +152,24 @@ int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver, #ifdef CONFIG_OWE case WPA_KEY_MGMT_OWE: wpa_printf(MSG_DEBUG, - "WPA: EAPOL-Key MIC using HMAC-SHA256 (AKM-defined - OWE)"); - if (hmac_sha256(key, key_len, buf, len, hash)) + "WPA: EAPOL-Key MIC using HMAC-SHA%u (AKM-defined - OWE)", + (unsigned int) key_len * 8 * 2); + if (key_len == 128 / 8) { + if (hmac_sha256(key, key_len, buf, len, hash)) + return -1; + } else if (key_len == 192 / 8) { + if (hmac_sha384(key, key_len, buf, len, hash)) + return -1; + } else if (key_len == 256 / 8) { + if (hmac_sha512(key, key_len, buf, len, hash)) + return -1; + } else { + wpa_printf(MSG_INFO, + "OWE: Unsupported KCK length: %u", + (unsigned int) key_len); return -1; - os_memcpy(mic, hash, MD5_MAC_LEN); + } + os_memcpy(mic, hash, key_len); break; #endif /* CONFIG_OWE */ #ifdef CONFIG_DPP