Various warning fixes. ESP32S3 include and build fixes. Added optional slot support for STSAFE shared secret using WOLFSSL_STSAFE_TAKES_SLOT.

This commit is contained in:
Kareem
2023-02-28 17:11:10 -07:00
parent 2a15363033
commit aaad3980a0
5 changed files with 27 additions and 6 deletions

View File

@ -13636,9 +13636,9 @@ int GetFormattedTime(void* currTime, byte* buf, word32 len)
#if defined(NEED_TMP_TIME) #if defined(NEED_TMP_TIME)
struct tm tmpTimeStorage; struct tm tmpTimeStorage;
tmpTime = &tmpTimeStorage; tmpTime = &tmpTimeStorage;
#else
(void)tmpTime;
#endif #endif
/* Needed in case XGMTIME does not use the tmpTime argument. */
(void)tmpTime;
WOLFSSL_ENTER("GetFormattedTime"); WOLFSSL_ENTER("GetFormattedTime");

View File

@ -26,6 +26,7 @@
/* settings.h is only included for wolfSSL version and IAR build warnings /* settings.h is only included for wolfSSL version and IAR build warnings
* wolfssl/wolfcrypt/- path includes other than * wolfssl/wolfcrypt/- path includes other than
* wolfssl/wolfcrypt/port/caam/caam_* should be avoided!! */ * wolfssl/wolfcrypt/port/caam/caam_* should be avoided!! */
#undef WC_NO_HARDEN
#define WC_NO_HARDEN /* silence warning, it is irrelavent here */ #define WC_NO_HARDEN /* silence warning, it is irrelavent here */
#include <wolfssl/wolfcrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>

View File

@ -249,7 +249,7 @@ int SSL_STSAFE_SharedSecretCb(WOLFSSL* ssl, ecc_key* otherKey,
word32 otherKeyX_len = sizeof(otherKeyX); word32 otherKeyX_len = sizeof(otherKeyX);
word32 otherKeyY_len = sizeof(otherKeyY); word32 otherKeyY_len = sizeof(otherKeyY);
byte pubKeyRaw[STSAFE_MAX_PUBKEY_RAW_LEN]; byte pubKeyRaw[STSAFE_MAX_PUBKEY_RAW_LEN];
StSafeA_KeySlotNumber slot; StSafeA_KeySlotNumber slot = STSAFE_A_SLOT_0;
StSafeA_CurveId curve_id; StSafeA_CurveId curve_id;
ecc_key tmpKey; ecc_key tmpKey;
int ecc_curve; int ecc_curve;
@ -322,7 +322,11 @@ int SSL_STSAFE_SharedSecretCb(WOLFSSL* ssl, ecc_key* otherKey,
} }
/* Compute shared secret */ /* Compute shared secret */
err = stsafe_interface_shared_secret(curve_id, &otherKeyX[0], &otherKeyY[0], err = stsafe_interface_shared_secret(
#ifdef WOLFSSL_STSAFE_TAKES_SLOT
slot,
#endif
curve_id, &otherKeyX[0], &otherKeyY[0],
out, (int32_t*)outlen); out, (int32_t*)outlen);
if (err != STSAFE_A_OK) { if (err != STSAFE_A_OK) {
#ifdef USE_STSAFE_VERBOSE #ifdef USE_STSAFE_VERBOSE
@ -535,7 +539,11 @@ int wolfSSL_STSAFE_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
if (rc == 0) { if (rc == 0) {
/* Compute shared secret */ /* Compute shared secret */
*info->pk.ecdh.outlen = 0; *info->pk.ecdh.outlen = 0;
rc = stsafe_interface_shared_secret(curve_id, rc = stsafe_interface_shared_secret(
#ifdef WOLFSSL_STSAFE_TAKES_SLOT
STSAFE_A_SLOT_0,
#endif
curve_id,
otherKeyX, otherKeyY, otherKeyX, otherKeyY,
info->pk.ecdh.out, (int32_t*)info->pk.ecdh.outlen); info->pk.ecdh.out, (int32_t*)info->pk.ecdh.outlen);
if (rc != STSAFE_A_OK) { if (rc != STSAFE_A_OK) {

View File

@ -3028,7 +3028,7 @@ time_t stm32_hal_time(time_t *t1)
RTC_TimeTypeDef time; RTC_TimeTypeDef time;
RTC_DateTypeDef date; RTC_DateTypeDef date;
XMEMSET(tm_time, 0, sizeof(struct tm)); XMEMSET(&tm_time, 0, sizeof(struct tm));
/* order of GetTime followed by GetDate required here due to STM32 HW /* order of GetTime followed by GetDate required here due to STM32 HW
* requirement */ * requirement */

View File

@ -53,6 +53,8 @@
#if ESP_IDF_VERSION_MAJOR >= 4 #if ESP_IDF_VERSION_MAJOR >= 4
#include <esp32/rom/ets_sys.h> #include <esp32/rom/ets_sys.h>
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#include <esp32s3/rom/ets_sys.h>
#else #else
#include <rom/ets_sys.h> #include <rom/ets_sys.h>
#endif #endif
@ -69,6 +71,8 @@ int esp_CryptHwMutexUnLock(wolfSSL_Mutex* mutex);
#if ESP_IDF_VERSION_MAJOR >= 4 #if ESP_IDF_VERSION_MAJOR >= 4
#include "esp32/rom/aes.h" #include "esp32/rom/aes.h"
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#include "esp32s3/rom/aes.h"
#else #else
#include "rom/aes.h" #include "rom/aes.h"
#endif #endif
@ -105,6 +109,8 @@ int esp_CryptHwMutexUnLock(wolfSSL_Mutex* mutex);
#if ESP_IDF_VERSION_MAJOR >= 4 #if ESP_IDF_VERSION_MAJOR >= 4
#include "esp32/rom/sha.h" #include "esp32/rom/sha.h"
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#include "esp32s3/rom/sha.h"
#else #else
#include "rom/sha.h" #include "rom/sha.h"
#endif #endif
@ -127,7 +133,13 @@ int esp_CryptHwMutexUnLock(wolfSSL_Mutex* mutex);
* actual enable/disable only occurs for ref_counts[periph] == 0 */ * actual enable/disable only occurs for ref_counts[periph] == 0 */
int lockDepth; /* see ref_counts[periph] in periph_ctrl.c */ int lockDepth; /* see ref_counts[periph] in periph_ctrl.c */
/* ESP32S3 defines SHA_TYPE to enum, all other ESP32s define it to
typedef enum. */
#if defined(CONFIG_IDF_TARGET_ESP32S3)
SHA_TYPE sha_type;
#else
enum SHA_TYPE sha_type; enum SHA_TYPE sha_type;
#endif
} WC_ESP32SHA; } WC_ESP32SHA;
int esp_sha_try_hw_lock(WC_ESP32SHA* ctx); int esp_sha_try_hw_lock(WC_ESP32SHA* ctx);