iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 3/9] eapol: implement rekey support for authenticator
Date: Wed, 11 Jan 2023 12:15:37 -0800	[thread overview]
Message-ID: <20230111201543.397692-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20230111201543.397692-1-prestwoj@gmail.com>

The only changes required was to set the secure bit for message 1,
reset the frame retry counter, and don't explicitly set ptk_complete
to false

Initiating a rekey can now be done by simply calling eapol_start().
---
 src/eapol.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/eapol.c b/src/eapol.c
index 593daf41..d31116b6 100644
--- a/src/eapol.c
+++ b/src/eapol.c
@@ -1087,8 +1087,6 @@ static void eapol_send_ptk_1_of_4(struct eapol_sm *sm)
 
 	handshake_state_new_anonce(sm->handshake);
 
-	sm->handshake->ptk_complete = false;
-
 	sm->replay_counter++;
 
 	memset(ek, 0, EAPOL_FRAME_LEN(sm->mic_len));
@@ -1112,6 +1110,11 @@ static void eapol_send_ptk_1_of_4(struct eapol_sm *sm)
 
 	eapol_key_data_append(ek, sm->mic_len, HANDSHAKE_KDE_PMKID, pmkid, 16);
 
+	if (sm->handshake->ptk_complete) {
+		ek->secure = true;
+		sm->rekey = true;
+	}
+
 	ek->header.packet_len = L_CPU_TO_BE16(EAPOL_FRAME_LEN(sm->mic_len) +
 				EAPOL_KEY_DATA_LEN(ek, sm->mic_len) - 4);
 
@@ -2129,7 +2132,8 @@ static void eapol_handle_ptk_4_of_4(struct eapol_sm *sm,
 	 * This might be a retransmission, so accept but don't install
 	 * the keys again.
 	 */
-	if (!sm->handshake->ptk_complete)
+	if (!sm->handshake->ptk_complete ||
+				(sm->handshake->ptk_complete && sm->rekey))
 		handshake_state_install_ptk(sm->handshake);
 
 	sm->handshake->ptk_complete = true;
@@ -2483,6 +2487,8 @@ static void eapol_eap_complete_cb(enum eap_result result, void *user_data)
 
 		/* sm->mic_len will have been set in eapol_eap_results_cb */
 
+		sm->frame_retry = 0;
+
 		/* Kick off 4-Way Handshake */
 		eapol_ptk_1_of_4_retry(NULL, sm);
 	}
@@ -2874,6 +2880,8 @@ bool eapol_start(struct eapol_sm *sm)
 			if (L_WARN_ON(!sm->handshake->have_pmk))
 				return false;
 
+			sm->frame_retry = 0;
+
 			/* Kick off handshake */
 			eapol_ptk_1_of_4_retry(NULL, sm);
 		}
-- 
2.34.3


  parent reply	other threads:[~2023-01-11 20:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 20:15 [PATCH 1/9] eapol: set secure on message 2/4 properly James Prestwood
2023-01-11 20:15 ` [PATCH 2/9] unit: update test-eapol with API change James Prestwood
2023-01-11 20:15 ` James Prestwood [this message]
2023-01-11 20:15 ` [PATCH 4/9] handshake: add event for rekey success James Prestwood
2023-01-11 22:30   ` Denis Kenzior
2023-01-11 20:15 ` [PATCH 5/9] netdev: unset ptk_installed flag for TK James Prestwood
2023-01-11 20:15 ` [PATCH 6/9] netdev: support HANDSHAKE_EVENT_REKEY_COMPLETE James Prestwood
2023-01-11 20:15 ` [PATCH 7/9] eapol: relax secure bit check on 2/4 James Prestwood
2023-01-11 20:15 ` [PATCH 8/9] ap: support PTK rekeys James Prestwood
2023-01-11 20:15 ` [PATCH 9/9] doc: Document RekeyTimeout for AP profiles James Prestwood
2023-01-11 22:05 ` [PATCH 1/9] eapol: set secure on message 2/4 properly Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230111201543.397692-3-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).