Skip to content

Commit

Permalink
Merge branch 'bugfix/dpp_bugs' into 'master'
Browse files Browse the repository at this point in the history
esp_wifi: Fix few dpp bugs.

Closes WIFIBUG-155 and WIFIBUG-154

See merge request espressif/esp-idf!26340
  • Loading branch information
jack0c committed Oct 16, 2023
2 parents dbc33ca + 236fa50 commit 8023a2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion components/wpa_supplicant/esp_supplicant/src/esp_dpp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -379,6 +379,10 @@ static void esp_dpp_task(void *pvParameters )
static int counter;
int channel;

if (p->num_chan <= 0) {
wpa_printf(MSG_ERROR, "Listen channel not set");
break;
}
channel = p->chan_list[counter++ % p->num_chan];
esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_REQ, channel,
BOOTSTRAP_ROC_WAIT_TIME, s_action_rx_cb);
Expand Down
17 changes: 10 additions & 7 deletions components/wpa_supplicant/src/common/dpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct dpp_global {
static const struct dpp_curve_params dpp_curves[] = {
/* The mandatory to support and the default NIST P-256 curve needs to
* be the first entry on this list. */
{ "sec256r1", 32, 32, 16, 32, "P-256", 19, "ES256" },
{ "secp256r1", 32, 32, 16, 32, "P-256", 19, "ES256" },
{ "secp384r1", 48, 48, 24, 48, "P-384", 20, "ES384" },
{ "secp521r1", 64, 64, 32, 66, "P-521", 21, "ES512" },
{ "brainpoolP256r1", 32, 32, 16, 32, "BP-256", 28, "BS256" },
Expand Down Expand Up @@ -4669,7 +4669,8 @@ static struct crypto_key * dpp_parse_jwk(struct json_token *jwk,
{
struct json_token *token;
const struct dpp_curve_params *curve;
struct wpabuf *x = NULL, *y = NULL, *a = NULL;
struct wpabuf *x = NULL, *y = NULL;
unsigned char *a = NULL;
struct crypto_ec_group *group;
struct crypto_key *pkey = NULL;
size_t len;
Expand Down Expand Up @@ -4731,17 +4732,19 @@ static struct crypto_key * dpp_parse_jwk(struct json_token *jwk,
goto fail;
}

len = wpabuf_len(x);
a = wpabuf_concat(x, y);
pkey = crypto_ec_set_pubkey_point(group, wpabuf_head(a),
len);
len = wpabuf_len(x) + wpabuf_len(y);
a = os_zalloc(len);
os_memcpy(a, wpabuf_head(x), wpabuf_len(x));
os_memcpy(a + wpabuf_len(x), wpabuf_head(y), wpabuf_len(y));
pkey = crypto_ec_set_pubkey_point(group, a, len);

crypto_ec_deinit((struct crypto_ec *)group);
*key_curve = curve;

fail:
wpabuf_free(a);
wpabuf_free(x);
wpabuf_free(y);
os_free(a);

return pkey;
}
Expand Down

0 comments on commit 8023a2b

Please sign in to comment.