Skip to content

Commit cab4dc1

Browse files
Aditi-Lonkarespressif-bot
authored andcommitted
feat(esp_wifi): Restructure dpp crypto Layer APIs
1) Update dpp implementation as per upstram hostapd tag hostap_2_10. 2) Move dpp crypto routines into a separate source code file.
1 parent 12cbdfe commit cab4dc1

File tree

7 files changed

+1332
-1252
lines changed

7 files changed

+1332
-1252
lines changed

components/wpa_supplicant/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ endif()
202202

203203
if(CONFIG_ESP_WIFI_DPP_SUPPORT)
204204
set(dpp_src "src/common/dpp.c"
205+
"src/common/dpp_crypto.c"
205206
"esp_supplicant/src/esp_dpp.c")
206207
else()
207208
set(dpp_src "")

components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls-ec.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ void crypto_ec_free_key(struct crypto_key *key)
564564
os_free(key);
565565
}
566566

567-
struct crypto_ec_point *crypto_ec_get_public_key(struct crypto_key *key)
567+
struct crypto_ec_point *crypto_ec_key_get_public_key(struct crypto_key *key)
568568
{
569569
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
570570

@@ -614,7 +614,7 @@ int crypto_ec_key_group(struct crypto_ec_key *key)
614614
return iana_group;
615615
}
616616

617-
struct crypto_bignum *crypto_ec_get_private_key(struct crypto_key *key)
617+
struct crypto_bignum *crypto_ec_key_get_private_key(struct crypto_key *key)
618618
{
619619
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
620620

@@ -669,7 +669,7 @@ int crypto_write_pubkey_der(struct crypto_key *key, unsigned char **key_buf)
669669
return len;
670670
}
671671

672-
struct crypto_key *crypto_ec_get_key(const u8 *privkey, size_t privkey_len)
672+
struct crypto_key *crypto_ec_key_parse_priv(const u8 *privkey, size_t privkey_len)
673673
{
674674
int ret;
675675
mbedtls_pk_context *kctx = (mbedtls_pk_context *)crypto_alloc_key();
@@ -841,7 +841,7 @@ int crypto_edcsa_sign_verify(const unsigned char *hash,
841841
return ret;
842842
}
843843

844-
void crypto_debug_print_ec_key(const char *title, struct crypto_key *key)
844+
void crypto_ec_key_debug_print(const char *title, struct crypto_key *key)
845845
{
846846
#ifdef DEBUG_PRINT
847847
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
@@ -852,12 +852,12 @@ void crypto_debug_print_ec_key(const char *title, struct crypto_key *key)
852852
int len = mbedtls_mpi_size((mbedtls_mpi *)crypto_ec_get_prime((struct crypto_ec *)crypto_ec_get_group_from_key(key)));
853853

854854
wpa_printf(MSG_ERROR, "prime len is %d", len);
855-
crypto_ec_point_to_bin((struct crypto_ec *)crypto_ec_get_group_from_key(key), crypto_ec_get_public_key(key), x, y);
856-
crypto_bignum_to_bin(crypto_ec_get_private_key(key),
857-
d, len, len);
858-
wpa_hexdump(MSG_ERROR, "Q_x:", x, 32);
859-
wpa_hexdump(MSG_ERROR, "Q_y:", y, 32);
860-
wpa_hexdump(MSG_ERROR, "d: ", d, 32);
855+
crypto_ec_point_to_bin((struct crypto_ec *)crypto_ec_get_group_from_key(key), crypto_ec_key_get_public_key(key), x, y);
856+
crypto_bignum_to_bin(crypto_ec_key_get_private_key(key),
857+
d, len, len);
858+
wpa_hexdump(MSG_INFO, "Q_x:", x, 32);
859+
wpa_hexdump(MSG_INFO, "Q_y:", y, 32);
860+
wpa_hexdump(MSG_INFO, "d: ", d , 32);
861861
#endif
862862
}
863863

@@ -885,7 +885,7 @@ int crypto_is_ec_key(struct crypto_key *key)
885885
return ret;
886886
}
887887

888-
struct crypto_key * crypto_ec_gen_keypair(u16 ike_group)
888+
struct crypto_key * crypto_ec_key_gen(u16 ike_group)
889889
{
890890
mbedtls_pk_context *kctx = (mbedtls_pk_context *)crypto_alloc_key();
891891

components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -10,7 +10,6 @@
1010
#include "esp_err.h"
1111
#include "utils/includes.h"
1212
#include "utils/common.h"
13-
1413
#include "common/dpp.h"
1514
#include "esp_dpp.h"
1615
#include "esp_wifi_driver.h"
@@ -59,6 +58,12 @@ struct esp_dpp_context_t {
5958
int esp_supp_rx_action(uint8_t *hdr, uint8_t *payload, size_t len, uint8_t channel);
6059
esp_err_t esp_dpp_post_evt(uint32_t evt_id, uint32_t data);
6160

61+
#ifdef CONFIG_TESTING_OPTIONS
62+
int dpp_test_gen_invalid_key(struct wpabuf *msg,
63+
const struct dpp_curve_params *curve);
64+
char * dpp_corrupt_connector_signature(const char *connector);
65+
#endif /* CONFIG_TESTING_OPTIONS */
66+
6267
#ifdef CONFIG_ESP_WIFI_DPP_SUPPORT
6368
bool is_dpp_enabled(void);
6469
#else

0 commit comments

Comments
 (0)