Skip to content

Commit 62cc505

Browse files
committed
feat(wps): optimization wps code
1 parent 0a7d44c commit 62cc505

9 files changed

+2
-139
lines changed

components/esp8266/include/esp_wifi_crypto_types.h

-3
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,6 @@ typedef int (*esp_wps_is_selected_pin_registrar_t)(const void *msg, unsigned cha
691691
*/
692692
typedef int (*esp_wps_is_selected_pbc_registrar_t)(const void *msg, unsigned char *bssid);
693693

694-
695-
696694
/**
697695
* @brief The crypto callback function structure used when do station security connect.
698696
* The structure can be set as software crypto or the crypto optimized by ESP32
@@ -750,7 +748,6 @@ typedef struct{
750748
esp_eap_msg_alloc_t eap_msg_alloc;
751749
}wps_crypto_funcs_t;
752750

753-
754751
#ifdef __cplusplus
755752
}
756753
#endif

components/wpa_supplicant/src/fast_crypto/fast_aes-cbc.c

-29
Original file line numberDiff line numberDiff line change
@@ -78,34 +78,5 @@ fast_aes_128_cbc_decrypt(const uint8_t *key, const uint8_t *iv, uint8_t *data, s
7878

7979
return ret;
8080

81-
}
82-
#else
83-
/**
84-
* fast_aes_128_cbc_encrypt - AES-128 CBC encryption
85-
* @key: Encryption key
86-
* @iv: Encryption IV for CBC mode (16 bytes)
87-
* @data: Data to encrypt in-place
88-
* @data_len: Length of data in bytes (must be divisible by 16)
89-
* Returns: 0 on success, -1 on failure
90-
*/
91-
int
92-
fast_aes_128_cbc_encrypt(const uint8_t *key, const uint8_t *iv, uint8_t *data, size_t data_len)
93-
{
94-
return 0;
95-
}
96-
97-
/**
98-
* fast_aes_128_cbc_decrypt - AES-128 CBC decryption
99-
* @key: Decryption key
100-
* @iv: Decryption IV for CBC mode (16 bytes)
101-
* @data: Data to decrypt in-place
102-
* @data_len: Length of data in bytes (must be divisible by 16)
103-
* Returns: 0 on success, -1 on failure
104-
*/
105-
int
106-
fast_aes_128_cbc_decrypt(const uint8_t *key, const uint8_t *iv, uint8_t *data, size_t data_len)
107-
{
108-
return 0;
109-
11081
}
11182
#endif

components/wpa_supplicant/src/fast_crypto/fast_aes-unwrap.c

-15
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,4 @@ fast_aes_unwrap(const uint8_t *kek, int n, const uint8_t *cipher, uint8_t *plain
8484

8585
return ret;
8686
}
87-
#else
88-
/**
89-
* fast_aes_unwrap - Unwrap key with AES Key Wrap Algorithm (128-bit KEK) (RFC3394)
90-
* @kek: Key encryption key (KEK)
91-
* @n: Length of the plaintext key in 64-bit units; e.g., 2 = 128-bit = 16
92-
* bytes
93-
* @cipher: Wrapped key to be unwrapped, (n + 1) * 64 bits
94-
* @plain: Plaintext key, n * 64 bits
95-
* Returns: 0 on success, -1 on failure (e.g., integrity verification failed)
96-
*/
97-
int
98-
fast_aes_unwrap(const uint8_t *kek, int n, const uint8_t *cipher, uint8_t *plain)
99-
{
100-
return 0;
101-
}
10287
#endif

components/wpa_supplicant/src/fast_crypto/fast_aes-wrap.c

-14
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,4 @@ int fast_aes_wrap(const uint8_t *kek, int n, const uint8_t *plain, uint8_t *ciph
8585

8686
return ret;
8787
}
88-
#else
89-
/**
90-
* fast_aes_wrap - Wrap keys with AES Key Wrap Algorithm (128-bit KEK) (RFC3394)
91-
* @kek: 16-octet Key encryption key (KEK)
92-
* @n: Length of the plaintext key in 64-bit units; e.g., 2 = 128-bit = 16
93-
* bytes
94-
* @plain: Plaintext key to be wrapped, n * 64 bits
95-
* @cipher: Wrapped key, (n + 1) * 64 bits
96-
* Returns: 0 on success, -1 on failure
97-
*/
98-
int fast_aes_wrap(const uint8_t *kek, int n, const uint8_t *plain, uint8_t *cipher)
99-
{
100-
return 0;
101-
}
10288
#endif

components/wpa_supplicant/src/fast_crypto/fast_crypto_internal-modexp.c

-8
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,4 @@ int fast_crypto_mod_exp(const uint8_t *base, size_t base_len,
6161

6262
return ret;
6363
}
64-
#else
65-
int fast_crypto_mod_exp(const uint8_t *base, size_t base_len,
66-
const uint8_t *power, size_t power_len,
67-
const uint8_t *modulus, size_t modulus_len,
68-
uint8_t *result, size_t *result_len)
69-
{
70-
return 0;
71-
}
7264
#endif

components/wpa_supplicant/src/fast_crypto/fast_crypto_internal.c

-2
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,4 @@ int fast_crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len)
282282

283283
return 0;
284284
}
285-
#else
286-
287285
#endif

components/wpa_supplicant/src/fast_crypto/fast_sha256-internal.c

-16
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,4 @@ fast_sha256_vector(size_t num_elem, const uint8_t *addr[], const size_t *len,
5959

6060
return ret;
6161
}
62-
#else
63-
64-
/**
65-
* fast_sha256_vector - SHA256 hash for data vector
66-
* @num_elem: Number of elements in the data vector
67-
* @addr: Pointers to the data areas
68-
* @len: Lengths of the data blocks
69-
* @mac: Buffer for the hash
70-
* Returns: 0 on success, -1 of failure
71-
*/
72-
int
73-
fast_sha256_vector(size_t num_elem, const uint8_t *addr[], const size_t *len,
74-
uint8_t *mac)
75-
{
76-
return 0;
77-
}
7862
#endif

components/wpa_supplicant/src/fast_crypto/fast_sha256.c

-51
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "crypto/crypto.h"
2323

2424
#if CONFIG_SSL_USING_MBEDTLS
25-
2625
/**
2726
* fast_hmac_sha256_vector - HMAC-SHA256 over data vector (RFC 2104)
2827
* @key: Key for HMAC operations
@@ -165,54 +164,4 @@ fast_sha256_prf(const uint8_t *key, size_t key_len, const char *label,
165164
counter++;
166165
}
167166
}
168-
#else
169-
/**
170-
* fast_hmac_sha256_vector - HMAC-SHA256 over data vector (RFC 2104)
171-
* @key: Key for HMAC operations
172-
* @key_len: Length of the key in bytes
173-
* @num_elem: Number of elements in the data vector
174-
* @addr: Pointers to the data areas
175-
* @len: Lengths of the data blocks
176-
* @mac: Buffer for the hash (32 bytes)
177-
*/
178-
void
179-
fast_hmac_sha256_vector(const uint8_t *key, size_t key_len, size_t num_elem,
180-
const uint8_t *addr[], const size_t *len, uint8_t *mac)
181-
{
182-
}
183-
184-
185-
/**
186-
* fast_hmac_sha256 - HMAC-SHA256 over data buffer (RFC 2104)
187-
* @key: Key for HMAC operations
188-
* @key_len: Length of the key in bytes
189-
* @data: Pointers to the data area
190-
* @data_len: Length of the data area
191-
* @mac: Buffer for the hash (20 bytes)
192-
*/
193-
void
194-
fast_hmac_sha256(const uint8_t *key, size_t key_len, const uint8_t *data,
195-
size_t data_len, uint8_t *mac)
196-
{
197-
}
198-
199-
200-
/**
201-
* fast_sha256_prf - SHA256-based Pseudo-Random Function (IEEE 802.11r, 8.5.1.5.2)
202-
* @key: Key for PRF
203-
* @key_len: Length of the key in bytes
204-
* @label: A unique label for each purpose of the PRF
205-
* @data: Extra data to bind into the key
206-
* @data_len: Length of the data
207-
* @buf: Buffer for the generated pseudo-random key
208-
* @buf_len: Number of bytes of key to generate
209-
*
210-
* This function is used to derive new, cryptographically separate keys from a
211-
* given key.
212-
*/
213-
void
214-
fast_sha256_prf(const uint8_t *key, size_t key_len, const char *label,
215-
const uint8_t *data, size_t data_len, uint8_t *buf, size_t buf_len)
216-
{
217-
}
218167
#endif

components/wpa_supplicant/src/fast_crypto_ops.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ const wps_crypto_funcs_t g_wifi_default_wps_crypto_funcs = {
8585
.eap_msg_alloc = (esp_eap_msg_alloc_t)eap_msg_alloc
8686
};
8787

88-
#else
88+
#else
89+
8990
/*
9091
* The parameters is used to set the cyrpto callback function for station connect when in security mode,
9192
* every callback function can register as fast_xxx or normal one, i.e, fast_aes_wrap or aes_wrap, the

0 commit comments

Comments
 (0)