blob: 361f72614696e59075930101ac198c3a02a14d87 [file] [log] [blame]
developer29c4d2d2022-12-26 19:41:22 +08001From 33afce36c54b0cad38643629ded10ff5d727f077 Mon Sep 17 00:00:00 2001
2From: Glenn Strauss <gstrauss@gluelogic.com>
3Date: Fri, 12 Aug 2022 05:34:47 -0400
4Subject: [PATCH 5/7] add NULL checks (encountered during tests/hwsim)
5
6sae_derive_commit_element_ecc NULL pwe_ecc check
7dpp_gen_keypair() NULL curve check
8
9Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
10---
11 src/common/dpp_crypto.c | 6 ++++++
12 src/common/sae.c | 7 +++++++
13 2 files changed, 13 insertions(+)
14
15--- a/src/common/dpp_crypto.c
16+++ b/src/common/dpp_crypto.c
17@@ -248,6 +248,12 @@ struct crypto_ec_key * dpp_set_pubkey_po
18
19 struct crypto_ec_key * dpp_gen_keypair(const struct dpp_curve_params *curve)
20 {
21+ if (curve == NULL) {
22+ wpa_printf(MSG_DEBUG,
23+ "DPP: %s curve must be initialized", __func__);
24+ return NULL;
25+ }
26+
27 struct crypto_ec_key *key;
28
29 wpa_printf(MSG_DEBUG, "DPP: Generating a keypair");
30--- a/src/common/sae.c
31+++ b/src/common/sae.c
32@@ -1278,6 +1278,13 @@ void sae_deinit_pt(struct sae_pt *pt)
33 static int sae_derive_commit_element_ecc(struct sae_data *sae,
34 struct crypto_bignum *mask)
35 {
36+ if (sae->tmp->pwe_ecc == NULL) {
37+ wpa_printf(MSG_DEBUG,
38+ "SAE: %s sae->tmp->pwe_ecc must be initialized",
39+ __func__);
40+ return -1;
41+ }
42+
43 /* COMMIT-ELEMENT = inverse(scalar-op(mask, PWE)) */
44 if (!sae->tmp->own_commit_element_ecc) {
45 sae->tmp->own_commit_element_ecc =