Blame SOURCES/rh1495527-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch

d840d9
From 12fac09b437a1dc8a0f253e265934a8aaf4d2f8b Mon Sep 17 00:00:00 2001
d840d9
From: Jouni Malinen <j@w1.fi>
d840d9
Date: Sun, 1 Oct 2017 12:32:57 +0300
d840d9
Subject: [PATCH 5/8] Fix PTK rekeying to generate a new ANonce
d840d9
d840d9
The Authenticator state machine path for PTK rekeying ended up bypassing
d840d9
the AUTHENTICATION2 state where a new ANonce is generated when going
d840d9
directly to the PTKSTART state since there is no need to try to
d840d9
determine the PMK again in such a case. This is far from ideal since the
d840d9
new PTK would depend on a new nonce only from the supplicant.
d840d9
d840d9
Fix this by generating a new ANonce when moving to the PTKSTART state
d840d9
for the purpose of starting new 4-way handshake to rekey PTK.
d840d9
d840d9
Signed-off-by: Jouni Malinen <j@w1.fi>
d840d9
---
d840d9
 src/ap/wpa_auth.c | 24 +++++++++++++++++++++---
d840d9
 1 file changed, 21 insertions(+), 3 deletions(-)
d840d9
d840d9
diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
d840d9
index 707971d..bf10cc1 100644
d840d9
--- a/src/ap/wpa_auth.c
d840d9
+++ b/src/ap/wpa_auth.c
d840d9
@@ -1901,6 +1901,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2)
d840d9
 }
d840d9
 
d840d9
 
d840d9
+static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm)
d840d9
+{
d840d9
+	if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
d840d9
+		wpa_printf(MSG_ERROR,
d840d9
+			   "WPA: Failed to get random data for ANonce");
d840d9
+		sm->Disconnect = TRUE;
d840d9
+		return -1;
d840d9
+	}
d840d9
+	wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce,
d840d9
+		    WPA_NONCE_LEN);
d840d9
+	sm->TimeoutCtr = 0;
d840d9
+	return 0;
d840d9
+}
d840d9
+
d840d9
+
d840d9
 SM_STATE(WPA_PTK, INITPMK)
d840d9
 {
d840d9
 	u8 msk[2 * PMK_LEN];
d840d9
@@ -2458,9 +2473,12 @@ SM_STEP(WPA_PTK)
d840d9
 		SM_ENTER(WPA_PTK, AUTHENTICATION);
d840d9
 	else if (sm->ReAuthenticationRequest)
d840d9
 		SM_ENTER(WPA_PTK, AUTHENTICATION2);
d840d9
-	else if (sm->PTKRequest)
d840d9
-		SM_ENTER(WPA_PTK, PTKSTART);
d840d9
-	else switch (sm->wpa_ptk_state) {
d840d9
+	else if (sm->PTKRequest) {
d840d9
+		if (wpa_auth_sm_ptk_update(sm) < 0)
d840d9
+			SM_ENTER(WPA_PTK, DISCONNECTED);
d840d9
+		else
d840d9
+			SM_ENTER(WPA_PTK, PTKSTART);
d840d9
+	} else switch (sm->wpa_ptk_state) {
d840d9
 	case WPA_PTK_INITIALIZE:
d840d9
 		break;
d840d9
 	case WPA_PTK_DISCONNECT:
d840d9
-- 
d840d9
2.7.4
d840d9