wok annotate wpa_supplicant/stuff/rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch @ rev 20131

wpa_supplicant: security fix for KRACK
author Richard Dunbar <mojo@slitaz.org>
date Sat Oct 28 02:35:58 2017 -0400 (2017-10-28)
parents
children
rev   line source
mojo@20131 1 From 12fac09b437a1dc8a0f253e265934a8aaf4d2f8b Mon Sep 17 00:00:00 2001
mojo@20131 2 From: Jouni Malinen <j@w1.fi>
mojo@20131 3 Date: Sun, 1 Oct 2017 12:32:57 +0300
mojo@20131 4 Subject: [PATCH 5/8] Fix PTK rekeying to generate a new ANonce
mojo@20131 5
mojo@20131 6 The Authenticator state machine path for PTK rekeying ended up bypassing
mojo@20131 7 the AUTHENTICATION2 state where a new ANonce is generated when going
mojo@20131 8 directly to the PTKSTART state since there is no need to try to
mojo@20131 9 determine the PMK again in such a case. This is far from ideal since the
mojo@20131 10 new PTK would depend on a new nonce only from the supplicant.
mojo@20131 11
mojo@20131 12 Fix this by generating a new ANonce when moving to the PTKSTART state
mojo@20131 13 for the purpose of starting new 4-way handshake to rekey PTK.
mojo@20131 14
mojo@20131 15 Signed-off-by: Jouni Malinen <j@w1.fi>
mojo@20131 16 ---
mojo@20131 17 src/ap/wpa_auth.c | 24 +++++++++++++++++++++---
mojo@20131 18 1 file changed, 21 insertions(+), 3 deletions(-)
mojo@20131 19
mojo@20131 20 diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
mojo@20131 21 index 707971d..bf10cc1 100644
mojo@20131 22 --- a/src/ap/wpa_auth.c
mojo@20131 23 +++ b/src/ap/wpa_auth.c
mojo@20131 24 @@ -1901,6 +1901,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2)
mojo@20131 25 }
mojo@20131 26
mojo@20131 27
mojo@20131 28 +static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm)
mojo@20131 29 +{
mojo@20131 30 + if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
mojo@20131 31 + wpa_printf(MSG_ERROR,
mojo@20131 32 + "WPA: Failed to get random data for ANonce");
mojo@20131 33 + sm->Disconnect = TRUE;
mojo@20131 34 + return -1;
mojo@20131 35 + }
mojo@20131 36 + wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce,
mojo@20131 37 + WPA_NONCE_LEN);
mojo@20131 38 + sm->TimeoutCtr = 0;
mojo@20131 39 + return 0;
mojo@20131 40 +}
mojo@20131 41 +
mojo@20131 42 +
mojo@20131 43 SM_STATE(WPA_PTK, INITPMK)
mojo@20131 44 {
mojo@20131 45 u8 msk[2 * PMK_LEN];
mojo@20131 46 @@ -2458,9 +2473,12 @@ SM_STEP(WPA_PTK)
mojo@20131 47 SM_ENTER(WPA_PTK, AUTHENTICATION);
mojo@20131 48 else if (sm->ReAuthenticationRequest)
mojo@20131 49 SM_ENTER(WPA_PTK, AUTHENTICATION2);
mojo@20131 50 - else if (sm->PTKRequest)
mojo@20131 51 - SM_ENTER(WPA_PTK, PTKSTART);
mojo@20131 52 - else switch (sm->wpa_ptk_state) {
mojo@20131 53 + else if (sm->PTKRequest) {
mojo@20131 54 + if (wpa_auth_sm_ptk_update(sm) < 0)
mojo@20131 55 + SM_ENTER(WPA_PTK, DISCONNECTED);
mojo@20131 56 + else
mojo@20131 57 + SM_ENTER(WPA_PTK, PTKSTART);
mojo@20131 58 + } else switch (sm->wpa_ptk_state) {
mojo@20131 59 case WPA_PTK_INITIALIZE:
mojo@20131 60 break;
mojo@20131 61 case WPA_PTK_DISCONNECT:
mojo@20131 62 --
mojo@20131 63 2.7.4
mojo@20131 64