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

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