Skip to contentSkip to conversation

wsc: Clear the pin copy in wsc_generate_pin

PATCH In review Andrew Zaborowski 2 participants 3 messages Apr 3, 2020 – Apr 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 wsc: Clear the pin copy in wsc_generate_pin

---
 src/wsc.c | 1 +
 1 file changed, 1 insertion(+)
src/wsc.c +1 -0
index e9ebe5f5..ba58b6d4 100644
@@ -1137,6 +1137,7 @@ static struct l_dbus_message *wsc_generate_pin(struct l_dbus *dbus,
 
 	reply = l_dbus_message_new_method_return(message);
 	l_dbus_message_set_arguments(reply, "s", pin);
+	explicit_bzero(pin, 9);
 
 	return reply;
 }
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 eap-wsc: Convert memsets to explicit_bzero

---
 src/eap-wsc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
src/eap-wsc.c +6 -6
index 9fa1405f..3e0433e3 100644
@@ -843,11 +843,11 @@ static void eap_wsc_handle_m2(struct eap_state *eap,
 	l_checksum_get_digest(sha256, dhkey, sizeof(dhkey));
 	l_checksum_free(sha256);
 
-	memset(shared_secret, 0, shared_secret_len);
+	explicit_bzero(shared_secret, shared_secret_len);
 
 	hmac_sha256 = l_checksum_new_hmac(L_CHECKSUM_SHA256,
 							dhkey, sizeof(dhkey));
-	memset(dhkey, 0, sizeof(dhkey));
+	explicit_bzero(dhkey, sizeof(dhkey));
 
 	if (!hmac_sha256)
 		return;
@@ -864,7 +864,7 @@ static void eap_wsc_handle_m2(struct eap_state *eap,
 	l_checksum_free(hmac_sha256);
 
 	r = wsc_kdf(kdk, &keys, sizeof(keys));
-	memset(kdk, 0, sizeof(kdk));
+	explicit_bzero(kdk, sizeof(kdk));
 	if (!r)
 		return;
 
@@ -888,7 +888,7 @@ static void eap_wsc_handle_m2(struct eap_state *eap,
 						sizeof(keys.keywrap_key));
 
 clear_keys:
-	memset(&keys, 0, sizeof(keys));
+	explicit_bzero(&keys, sizeof(keys));
 }
 
 static void eap_wsc_handle_nack(struct eap_state *eap,
@@ -1228,12 +1228,12 @@ static bool eap_wsc_load_settings(struct eap_state *eap,
 		if (!l_key_validate_dh_payload(private_key, 192,
 						crypto_dh5_prime,
 						crypto_dh5_prime_size)) {
-			memset(private_key, 0, 192);
+			explicit_bzero(private_key, 192);
 			goto err;
 		}
 
 		wsc->private = l_key_new(L_KEY_RAW, private_key, 192);
-		memset(private_key, 0, 192);
+		explicit_bzero(private_key, 192);
 	} else
 		wsc->private = l_key_generate_dh_private(crypto_dh5_prime,
 							crypto_dh5_prime_size);
Signature · 1 line
2.20.1