Skip to contentSkip to conversation

eapol: Use constant-time comparison

PATCH In review Joseph Benden 2 participants 2 messages Jun 13, 2021 – Jun 14, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eapol: Use constant-time comparison

This closes the possibility of a timing attack against PMKIDs.

---
 src/eapol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/eapol.c +2 -2
index f587e708..51fb3c92 100644
@@ -1142,7 +1142,7 @@ static void eapol_handle_ptk_1_of_4(struct eapol_sm *sm,
 			goto error_unspecified;
 
 		for (i = 0; i < rsn_info.num_pmkids; i++)
-			if (!memcmp(rsn_info.pmkids + i * 16, pmkid, 16)) {
+			if (!l_secure_memcmp(rsn_info.pmkids + i * 16, pmkid, 16)) {
 				found = true;
 				break;
 			}
@@ -1155,7 +1155,7 @@ static void eapol_handle_ptk_1_of_4(struct eapol_sm *sm,
 		if (!handshake_state_get_pmkid(sm->handshake, own_pmkid))
 			goto error_unspecified;
 
-		if (memcmp(pmkid, own_pmkid, 16)) {
+		if (l_secure_memcmp(pmkid, own_pmkid, 16)) {
 			l_debug("Authenticator sent a PMKID that didn't match");
 
 			/*
Signature · 1 line
2.32.0
#1 lore raw

Hi Joseph,

Quoted 5 lines · Joseph Benden

This closes the possibility of a timing attack against PMKIDs.

---
  src/eapol.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

Applied with a minor formatting tweak to the first chunk (>80 chars / line)

Regards,
-Denis