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

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