[PATCH 2/6] add NULL checks (encountered during tests/hwsim)

Glenn Strauss gstrauss at gluelogic.com
Mon Nov 7 21:05:50 PST 2022


sae_derive_commit_element_ecc NULL pwe_ecc check
dpp_gen_keypair() NULL curve check

Signed-off-by: Glenn Strauss <gstrauss at gluelogic.com>
---
 src/common/dpp_crypto.c | 6 ++++++
 src/common/sae.c        | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/src/common/dpp_crypto.c b/src/common/dpp_crypto.c
index 09d4d8cf0..1fbdc86a8 100644
--- a/src/common/dpp_crypto.c
+++ b/src/common/dpp_crypto.c
@@ -248,6 +248,12 @@ struct crypto_ec_key * dpp_set_pubkey_point(struct crypto_ec_key *group_key,
 
 struct crypto_ec_key * dpp_gen_keypair(const struct dpp_curve_params *curve)
 {
+	if (curve == NULL) {
+		wpa_printf(MSG_DEBUG,
+		           "DPP: %s curve must be initialized", __func__);
+		return NULL;
+	}
+
 	struct crypto_ec_key *key;
 
 	wpa_printf(MSG_DEBUG, "DPP: Generating a keypair");
diff --git a/src/common/sae.c b/src/common/sae.c
index 1e9ea8efa..40ea11040 100644
--- a/src/common/sae.c
+++ b/src/common/sae.c
@@ -1278,6 +1278,13 @@ void sae_deinit_pt(struct sae_pt *pt)
 static int sae_derive_commit_element_ecc(struct sae_data *sae,
 					 struct crypto_bignum *mask)
 {
+	if (sae->tmp->pwe_ecc == NULL) {
+		wpa_printf(MSG_DEBUG,
+		           "SAE: %s sae->tmp->pwe_ecc must be initialized",
+		           __func__);
+		return -1;
+	}
+
 	/* COMMIT-ELEMENT = inverse(scalar-op(mask, PWE)) */
 	if (!sae->tmp->own_commit_element_ecc) {
 		sae->tmp->own_commit_element_ecc =
-- 
2.38.1



More information about the Hostap mailing list