From f95bf0159b9d317656e04f36a7b45f5984a04918 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 20 Jul 2010 15:36:04 +0000 Subject: Switch some obvious network stack MAC comparisons from bcmp() to timingsafe_bcmp(). ok deraadt@; committed over WPA. --- sys/net80211/ieee80211_crypto.c | 4 ++-- sys/net80211/ieee80211_crypto_bip.c | 4 ++-- sys/net80211/ieee80211_crypto_ccmp.c | 4 ++-- sys/net80211/ieee80211_crypto_tkip.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'sys/net80211') diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index 64ab098eae5..28afffa824c 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto.c,v 1.58 2009/02/13 17:24:54 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto.c,v 1.59 2010/07/20 15:36:03 matthew Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini @@ -485,7 +485,7 @@ ieee80211_eapol_key_check_mic(struct ieee80211_eapol_key *key, memset(key->mic, 0, EAPOL_KEY_MIC_LEN); ieee80211_eapol_key_mic(key, kck); - return memcmp(key->mic, mic, EAPOL_KEY_MIC_LEN) != 0; + return timingsafe_bcmp(key->mic, mic, EAPOL_KEY_MIC_LEN) != 0; } #ifndef IEEE80211_STA_ONLY diff --git a/sys/net80211/ieee80211_crypto_bip.c b/sys/net80211/ieee80211_crypto_bip.c index efa96835521..b69fac41d73 100644 --- a/sys/net80211/ieee80211_crypto_bip.c +++ b/sys/net80211/ieee80211_crypto_bip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto_bip.c,v 1.2 2009/01/26 19:09:41 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto_bip.c,v 1.3 2010/07/20 15:36:03 matthew Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini @@ -201,7 +201,7 @@ ieee80211_bip_decap(struct ieee80211com *ic, struct mbuf *m0, AES_CMAC_Final(mic, &ctx->cmac); /* check that MIC matches the one in MMIE */ - if (memcmp(mic, mic0, 8) != 0) { + if (timingsafe_bcmp(mic, mic0, 8) != 0) { ic->ic_stats.is_cmac_icv_errs++; m_freem(m0); return NULL; diff --git a/sys/net80211/ieee80211_crypto_ccmp.c b/sys/net80211/ieee80211_crypto_ccmp.c index d491c20168f..4b246d088aa 100644 --- a/sys/net80211/ieee80211_crypto_ccmp.c +++ b/sys/net80211/ieee80211_crypto_ccmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto_ccmp.c,v 1.10 2009/09/24 16:03:10 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto_ccmp.c,v 1.11 2010/07/20 15:36:03 matthew Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini @@ -445,7 +445,7 @@ ieee80211_ccmp_decrypt(struct ieee80211com *ic, struct mbuf *m0, /* check that it matches the MIC in received frame */ m_copydata(m, moff, IEEE80211_CCMP_MICLEN, mic0); - if (memcmp(mic0, b, IEEE80211_CCMP_MICLEN) != 0) { + if (timingsafe_bcmp(mic0, b, IEEE80211_CCMP_MICLEN) != 0) { ic->ic_stats.is_ccmp_dec_errs++; m_freem(m0); m_freem(n0); diff --git a/sys/net80211/ieee80211_crypto_tkip.c b/sys/net80211/ieee80211_crypto_tkip.c index ffd04f79e87..08375f263ad 100644 --- a/sys/net80211/ieee80211_crypto_tkip.c +++ b/sys/net80211/ieee80211_crypto_tkip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto_tkip.c,v 1.17 2009/10/30 20:32:25 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto_tkip.c,v 1.18 2010/07/20 15:36:03 matthew Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini @@ -454,7 +454,7 @@ ieee80211_tkip_decrypt(struct ieee80211com *ic, struct mbuf *m0, /* compute TKIP MIC over decrypted message */ ieee80211_tkip_mic(n0, hdrlen, ctx->rxmic, mic); /* check that it matches the MIC in received frame */ - if (memcmp(mic0, mic, IEEE80211_TKIP_MICLEN) != 0) { + if (timingsafe_bcmp(mic0, mic, IEEE80211_TKIP_MICLEN) != 0) { m_freem(m0); m_freem(n0); ic->ic_stats.is_rx_locmicfail++; -- cgit v1.2.3