diff options
| author | Cy Schubert <cy@FreeBSD.org> | 2019-08-22 02:58:49 +0000 | 
|---|---|---|
| committer | Cy Schubert <cy@FreeBSD.org> | 2019-08-22 02:58:49 +0000 | 
| commit | 61ba7d6203bdf21c1e14dda217e1bcbe7b35abf6 (patch) | |
| tree | 1a98b35c0a77ae6d183c5ad2e1f4322ad057f642 /src/ap/wpa_auth.c | |
| parent | 6e6d0eb51ef7b7487340bae7f20097ee5a57dbf4 (diff) | |
Diffstat (limited to 'src/ap/wpa_auth.c')
| -rw-r--r-- | src/ap/wpa_auth.c | 43 | 
1 files changed, 32 insertions, 11 deletions
| diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index f2e028c1599e8..c56077001efa4 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -934,6 +934,7 @@ static int wpa_try_alt_snonce(struct wpa_state_machine *sm, u8 *data,  	os_memcpy(sm->SNonce, sm->alt_SNonce, WPA_NONCE_LEN);  	os_memcpy(&sm->PTK, &PTK, sizeof(PTK)); +	forced_memzero(&PTK, sizeof(PTK));  	sm->PTK_valid = TRUE;  	return 0; @@ -1407,6 +1408,8 @@ static int wpa_gmk_to_gtk(const u8 *gmk, const char *label, const u8 *addr,  #endif /* CONFIG_SHA256 */  #endif /* CONFIG_SHA384 */ +	forced_memzero(data, sizeof(data)); +  	return ret;  } @@ -2046,7 +2049,7 @@ SM_STATE(WPA_PTK, INITPMK)  		sm->Disconnect = TRUE;  		return;  	} -	os_memset(msk, 0, sizeof(msk)); +	forced_memzero(msk, sizeof(msk));  	sm->req_replay_counter_used = 0;  	/* IEEE 802.11i does not set keyRun to FALSE, but not doing this @@ -2285,12 +2288,12 @@ int fils_auth_pmk_to_ptk(struct wpa_state_machine *sm, const u8 *pmk,  		wpa_hexdump(MSG_DEBUG, "FILS+FT: PMKR0Name",  			    pmk_r0_name, WPA_PMK_NAME_LEN);  		wpa_ft_store_pmk_fils(sm, pmk_r0, pmk_r0_name); -		os_memset(fils_ft, 0, sizeof(fils_ft)); +		forced_memzero(fils_ft, sizeof(fils_ft));  		res = wpa_derive_pmk_r1_name(pmk_r0_name, conf->r1_key_holder,  					     sm->addr, sm->pmk_r1_name,  					     use_sha384); -		os_memset(pmk_r0, 0, PMK_LEN_MAX); +		forced_memzero(pmk_r0, PMK_LEN_MAX);  		if (res < 0)  			return -1;  		wpa_hexdump(MSG_DEBUG, "FILS+FT: PMKR1Name", sm->pmk_r1_name, @@ -2308,7 +2311,7 @@ int fils_auth_pmk_to_ptk(struct wpa_state_machine *sm, const u8 *pmk,  			       sm->wpa_key_mgmt, sm->fils_key_auth_sta,  			       sm->fils_key_auth_ap,  			       &sm->fils_key_auth_len); -	os_memset(ick, 0, sizeof(ick)); +	forced_memzero(ick, sizeof(ick));  	/* Store nonces for (Re)Association Request/Response frame processing */  	os_memcpy(sm->SNonce, snonce, FILS_NONCE_LEN); @@ -2610,7 +2613,7 @@ int fils_encrypt_assoc(struct wpa_state_machine *sm, u8 *buf,  	if (pos + wpabuf_len(plain) + AES_BLOCK_SIZE > end) {  		wpa_printf(MSG_DEBUG,  			   "FILS: Not enough room for FILS elements"); -		wpabuf_free(plain); +		wpabuf_clear_free(plain);  		return -1;  	} @@ -2620,7 +2623,7 @@ int fils_encrypt_assoc(struct wpa_state_machine *sm, u8 *buf,  	if (aes_siv_encrypt(sm->PTK.kek, sm->PTK.kek_len,  			    wpabuf_head(plain), wpabuf_len(plain),  			    5, aad, aad_len, pos) < 0) { -		wpabuf_free(plain); +		wpabuf_clear_free(plain);  		return -1;  	} @@ -2628,7 +2631,7 @@ int fils_encrypt_assoc(struct wpa_state_machine *sm, u8 *buf,  		    "FILS: Encrypted Association Response elements",  		    pos, AES_BLOCK_SIZE + wpabuf_len(plain));  	current_len += wpabuf_len(plain) + AES_BLOCK_SIZE; -	wpabuf_free(plain); +	wpabuf_clear_free(plain);  	sm->fils_completed = 1; @@ -2682,7 +2685,7 @@ static struct wpabuf * fils_prepare_plainbuf(struct wpa_state_machine *sm,  		 * of GTK in the BSS.  		 */  		if (random_get_bytes(dummy_gtk, gtk_len) < 0) { -			wpabuf_free(plain); +			wpabuf_clear_free(plain);  			return NULL;  		}  		gtk = dummy_gtk; @@ -2709,13 +2712,13 @@ static struct wpabuf * fils_prepare_plainbuf(struct wpa_state_machine *sm,  		if (wpa_channel_info(sm->wpa_auth, &ci) != 0) {  			wpa_printf(MSG_WARNING,  				   "FILS: Failed to get channel info for OCI element"); -			wpabuf_free(plain); +			wpabuf_clear_free(plain);  			return NULL;  		}  		pos = wpabuf_put(plain, OCV_OCI_EXTENDED_LEN);  		if (ocv_insert_extended_oci(&ci, pos) < 0) { -			wpabuf_free(plain); +			wpabuf_clear_free(plain);  			return NULL;  		}  	} @@ -2778,7 +2781,7 @@ u8 * hostapd_eid_assoc_fils_session(struct wpa_state_machine *sm, u8 *buf,  	wpa_printf(MSG_DEBUG, "%s: plain buf_len: %u", __func__,  		   (unsigned int) wpabuf_len(plain)); -	wpabuf_free(plain); +	wpabuf_clear_free(plain);  	sm->fils_completed = 1;  	return pos;  } @@ -3030,6 +3033,7 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)  	sm->MICVerified = TRUE;  	os_memcpy(&sm->PTK, &PTK, sizeof(PTK)); +	forced_memzero(&PTK, sizeof(PTK));  	sm->PTK_valid = TRUE;  } @@ -4246,8 +4250,12 @@ int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen)  	/* Private MIB */  	ret = os_snprintf(buf + len, buflen - len, +			  "wpa=%d\n" +			  "AKMSuiteSelector=" RSN_SUITE "\n"  			  "hostapdWPAPTKState=%d\n"  			  "hostapdWPAPTKGroupState=%d\n", +			  sm->wpa, +			  RSN_SUITE_ARG(wpa_akm_to_suite(sm->wpa_key_mgmt)),  			  sm->wpa_ptk_state,  			  sm->wpa_ptk_group_state);  	if (os_snprintf_error(buflen - len, ret)) @@ -4359,6 +4367,15 @@ int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk,  	    sm->wpa_auth->conf.disable_pmksa_caching)  		return -1; +#ifdef CONFIG_IEEE80211R_AP +	if (pmk_len >= 2 * PMK_LEN && wpa_key_mgmt_ft(sm->wpa_key_mgmt) && +	    wpa_key_mgmt_wpa_ieee8021x(sm->wpa_key_mgmt) && +	    !wpa_key_mgmt_sha384(sm->wpa_key_mgmt)) { +		/* Cache MPMK/XXKey instead of initial part from MSK */ +		pmk = pmk + PMK_LEN; +		pmk_len = PMK_LEN; +	} else +#endif /* CONFIG_IEEE80211R_AP */  	if (wpa_key_mgmt_sha384(sm->wpa_key_mgmt)) {  		if (pmk_len > PMK_LEN_SUITE_B_192)  			pmk_len = PMK_LEN_SUITE_B_192; @@ -4366,6 +4383,7 @@ int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk,  		pmk_len = PMK_LEN;  	} +	wpa_hexdump_key(MSG_DEBUG, "RSN: Cache PMK", pmk, pmk_len);  	if (pmksa_cache_auth_add(sm->wpa_auth->pmksa, pmk, pmk_len, NULL,  				 sm->PTK.kck, sm->PTK.kck_len,  				 sm->wpa_auth->addr, sm->addr, session_timeout, @@ -4384,6 +4402,7 @@ int wpa_auth_pmksa_add_preauth(struct wpa_authenticator *wpa_auth,  	if (wpa_auth == NULL)  		return -1; +	wpa_hexdump_key(MSG_DEBUG, "RSN: Cache PMK from preauth", pmk, len);  	if (pmksa_cache_auth_add(wpa_auth->pmksa, pmk, len, NULL,  				 NULL, 0,  				 wpa_auth->addr, @@ -4401,6 +4420,7 @@ int wpa_auth_pmksa_add_sae(struct wpa_authenticator *wpa_auth, const u8 *addr,  	if (wpa_auth->conf.disable_pmksa_caching)  		return -1; +	wpa_hexdump_key(MSG_DEBUG, "RSN: Cache PMK from SAE", pmk, PMK_LEN);  	if (pmksa_cache_auth_add(wpa_auth->pmksa, pmk, PMK_LEN, pmkid,  				 NULL, 0,  				 wpa_auth->addr, addr, 0, NULL, @@ -4425,6 +4445,7 @@ int wpa_auth_pmksa_add2(struct wpa_authenticator *wpa_auth, const u8 *addr,  	if (wpa_auth->conf.disable_pmksa_caching)  		return -1; +	wpa_hexdump_key(MSG_DEBUG, "RSN: Cache PMK (2)", pmk, PMK_LEN);  	if (pmksa_cache_auth_add(wpa_auth->pmksa, pmk, pmk_len, pmkid,  				 NULL, 0, wpa_auth->addr, addr, session_timeout,  				 NULL, akmp)) | 
