mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-20 09:51:44 +00:00
wpa_supplicant: Write Crypto API based on mbedtls
This commit add following crypto changes 1. Update current crypto code with upstream supplicant code 2. Add a proper porting layer to use mbedtls APIs for all the crypto operations used by supplicant. Internal crypto will be used when USE_MBEDLTS flag is disabled in supplicant's menuconfig. This commit also removes the clutter in crypto files due to partial porting of some APIs to mbedtls, all the code from those files have been removed and rewritten in a generic way, this is inspired from current upstream code. This also reduces the lib size significantly, supplicant's lib size reduces around ~567kb after this change(NB: lib size doesn't indicate reduction in final bin size).
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_err.h"
|
||||
#include "supplicant_opt.h"
|
||||
|
||||
typedef time_t os_time_t;
|
||||
|
||||
@@ -308,4 +309,27 @@ static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size)
|
||||
return NULL;
|
||||
return os_realloc(ptr, nmemb * size);
|
||||
}
|
||||
|
||||
#ifdef USE_MBEDTLS_CRYPTO
|
||||
void forced_memzero(void *ptr, size_t len);
|
||||
#else
|
||||
/* Try to prevent most compilers from optimizing out clearing of memory that
|
||||
* becomes unaccessible after this function is called. This is mostly the case
|
||||
* for clearing local stack variables at the end of a function. This is not
|
||||
* exactly perfect, i.e., someone could come up with a compiler that figures out
|
||||
* the pointer is pointing to memset and then end up optimizing the call out, so
|
||||
* try go a bit further by storing the first octet (now zero) to make this even
|
||||
* a bit more difficult to optimize out. Once memset_s() is available, that
|
||||
* could be used here instead. */
|
||||
static void * (* const volatile memset_func)(void *, int, size_t) = memset;
|
||||
static uint8_t forced_memzero_val;
|
||||
|
||||
static inline void forced_memzero(void *ptr, size_t len)
|
||||
{
|
||||
memset_func(ptr, 0, len);
|
||||
if (len) {
|
||||
forced_memzero_val = ((uint8_t *) ptr)[0];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* OS_H */
|
||||
|
Reference in New Issue
Block a user