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

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