Skip to content

Commit e58fafc

Browse files
author
gojimmypi
committed
introduce WARNING_OUT, optional WOLFSSL_ESPIDF_ERROR_PAUSE
1 parent c852347 commit e58fafc

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const byte const_byte_array[] = "A+Gd\0\0\0";
133133
#include <time.h>
134134
#include <sys/time.h>
135135
#include <esp_log.h>
136+
#include <wolfcrypt/port/Espressif/esp32-crypt.h> /* */
136137
#elif defined(WOLFSSL_ZEPHYR)
137138
#include <stdio.h>
138139

@@ -713,8 +714,25 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_eax_test(void);
713714
/* General big buffer size for many tests. */
714715
#define FOURK_BUF 4096
715716

717+
#if defined(WOLFSSL_ESPIDF_ERROR_PAUSE)
718+
/* When defined, pause at error condition rather than exit with error. */
719+
#define ERROR_OUT(err, eLabel) \
720+
do { \
721+
ret = (err); \
722+
esp_ShowExtendedSystemInfo(); \
723+
ESP_LOGE("wolfcrypt_test", "ESP Error! ret = %d ", err); \
724+
while (1) { \
725+
vTaskDelay(60000); \
726+
} \
727+
/* Just to appease compiler, don't actually go to eLabel */ \
728+
goto eLabel; \
729+
} while (0)
730+
#else
731+
#define ERROR_OUT(err, eLabel) do { ret = (err); goto eLabel; } while (0)
732+
#endif
716733

717-
#define ERROR_OUT(err, eLabel) do { ret = (err); goto eLabel; } while (0)
734+
/* Not all unexpected conditions are actually errors .*/
735+
#define WARNING_OUT(err, eLabel) do { ret = (err); goto eLabel; } while (0)
718736

719737
static void render_error_message(const char* msg, wc_test_ret_t es)
720738
{
@@ -1893,7 +1911,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
18931911
#endif
18941912
{
18951913
wc_test_ret_t ret;
1896-
func_args args;
1914+
func_args args = { 0 };
18971915
#if defined(WOLFSSL_ESPIDF) || defined(WOLFSSL_SE050)
18981916
/* set dummy wallclock time. */
18991917
struct timeval utctime;
@@ -1995,16 +2013,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
19952013
while (1);
19962014
#endif
19972015

1998-
#ifdef WOLFSSL_ESPIDF
1999-
/* ESP_LOGI to print takes up a lot less memory than printf */
2000-
ESP_LOGI("wolfcrypt_test", "Exiting main with return code: % d\n", args.return_code);
2001-
#endif
2002-
2003-
/* everything else will use printf */
2004-
#if !defined(WOLFSSL_ESPIDF)
2005-
/* gate this for target platforms wishing to avoid printf reference */
20062016
printf("Exiting main with return code: %ld\n", (long int)args.return_code);
2007-
#endif
20082017

20092018
return args.return_code;
20102019
} /* wolfcrypt_test_main or wolf_test_task */
@@ -26370,7 +26379,8 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
2637026379

2637126380
/* only perform the below tests if the key size matches */
2637226381
if (dp == NULL && keySize > 0 && wc_ecc_size(userA) != keySize)
26373-
ERROR_OUT(ECC_CURVE_OID_E, done);
26382+
/* Not an error, just not a key size match */
26383+
WARNING_OUT(ECC_CURVE_OID_E, done);
2637426384

2637526385
#ifdef HAVE_ECC_DHE
2637626386
#if defined(ECC_TIMING_RESISTANT) && (!defined(HAVE_FIPS) || \
@@ -40150,7 +40160,7 @@ static int myDecryptionFunc(PKCS7* pkcs7, int encryptOID, byte* iv, int ivSz,
4015040160
#ifdef WOLFSSL_AES_256
4015140161
case AES256CBCb:
4015240162
if ((keySz != 32 ) || (ivSz != AES_BLOCK_SIZE))
40153-
ERROR_OUT(BAD_FUNC_ARG, out);
40163+
WARNING_OUT(BAD_FUNC_ARG, out);
4015440164
break;
4015540165
#endif
4015640166
#ifdef WOLFSSL_AES_128

0 commit comments

Comments
 (0)