mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Fix for ARM Keil MDK compiler issue with DECLARE_VAR_INIT
.
This commit is contained in:
21
tests/api.c
21
tests/api.c
@ -15236,10 +15236,15 @@ static int test_wc_RsaPublicEncryptDecrypt (void)
|
||||
word32 cipherLen = 256;
|
||||
#endif
|
||||
|
||||
DECLARE_VAR_INIT(in, byte, inLen, inStr, NULL);
|
||||
DECLARE_VAR(in, byte, inLen, NULL);
|
||||
DECLARE_VAR(plain, byte, plainLen, NULL);
|
||||
DECLARE_VAR(cipher, byte, cipherLen, NULL);
|
||||
|
||||
#ifdef DECLARE_VAR_IS_HEAP_ALLOC
|
||||
if (in && inStr)
|
||||
XMEMCPY(in, inStr, inLen);
|
||||
#endif
|
||||
|
||||
ret = wc_InitRsaKey(&key, NULL);
|
||||
if (ret == 0) {
|
||||
ret = wc_InitRng(&rng);
|
||||
@ -15326,10 +15331,15 @@ static int test_wc_RsaPublicEncryptDecrypt_ex (void)
|
||||
const word32 cipherSz = 256;
|
||||
#endif
|
||||
|
||||
DECLARE_VAR_INIT(in, byte, inLen, inStr, NULL);
|
||||
DECLARE_VAR(in, byte, inLen, NULL);
|
||||
DECLARE_VAR(plain, byte, plainSz, NULL);
|
||||
DECLARE_VAR(cipher, byte, cipherSz, NULL);
|
||||
|
||||
#ifdef DECLARE_VAR_IS_HEAP_ALLOC
|
||||
if (in && && inStr)
|
||||
XMEMCPY(in, inStr, inLen);
|
||||
#endif
|
||||
|
||||
/* Initialize stack structures. */
|
||||
XMEMSET(&rng, 0, sizeof(rng));
|
||||
XMEMSET(&key, 0, sizeof(key));
|
||||
@ -15443,10 +15453,15 @@ static int test_wc_RsaSSL_SignVerify (void)
|
||||
const word32 outSz = 256;
|
||||
#endif
|
||||
|
||||
DECLARE_VAR_INIT(in, byte, inLen, inStr, NULL);
|
||||
DECLARE_VAR(in, byte, inLen, NULL);
|
||||
DECLARE_VAR(out, byte, outSz, NULL);
|
||||
DECLARE_VAR(plain, byte, plainSz, NULL);
|
||||
|
||||
#ifdef DECLARE_VAR_IS_HEAP_ALLOC
|
||||
if (in && inStr)
|
||||
XMEMCPY(in, inStr, inLen);
|
||||
#endif
|
||||
|
||||
ret = wc_InitRsaKey(&key, NULL);
|
||||
|
||||
if (ret == 0) {
|
||||
|
@ -4507,7 +4507,7 @@ static void bench_rsa_helper(int doAsync, RsaKey rsaKey[BENCH_MAX_PENDING],
|
||||
double start = 0.0f;
|
||||
const char**desc = bench_desc_words[lng_index];
|
||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||
DECLARE_VAR_INIT(message, byte, len, messageStr, HEAP_HINT);
|
||||
DECLARE_VAR(message, byte, len, HEAP_HINT);
|
||||
#endif
|
||||
#if !defined(WOLFSSL_MDK5_COMPLv5)
|
||||
/* MDK5 compiler regard this as a executable statement, and does not allow declarations after the line. */
|
||||
@ -4546,6 +4546,10 @@ static void bench_rsa_helper(int doAsync, RsaKey rsaKey[BENCH_MAX_PENDING],
|
||||
ret = MEMORY_E;
|
||||
goto exit;
|
||||
}
|
||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||
if (message && messageStr)
|
||||
XMEMCPY(message, messageStr, len);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!rsa_sign_verify) {
|
||||
|
@ -12729,13 +12729,16 @@ static int rsa_pss_test(WC_RNG* rng, RsaKey* key)
|
||||
#endif
|
||||
};
|
||||
|
||||
DECLARE_VAR_INIT(in, byte, inLen, inStr, HEAP_HINT);
|
||||
DECLARE_VAR(in, byte, inLen, HEAP_HINT);
|
||||
DECLARE_VAR(out, byte, RSA_TEST_BYTES, HEAP_HINT);
|
||||
DECLARE_VAR(sig, byte, RSA_TEST_BYTES, HEAP_HINT);
|
||||
|
||||
#ifdef DECLARE_VAR_IS_HEAP_ALLOC
|
||||
if ((in == NULL) || (out == NULL) || (sig == NULL))
|
||||
ERROR_OUT(MEMORY_E, exit_rsa_pss);
|
||||
|
||||
if (in && inStr)
|
||||
XMEMCPY(in, inStr, inLen);
|
||||
#endif
|
||||
|
||||
/* Test all combinations of hash and MGF. */
|
||||
@ -14084,7 +14087,7 @@ WOLFSSL_TEST_SUBROUTINE int rsa_test(void)
|
||||
|
||||
#if (!defined(WOLFSSL_RSA_VERIFY_ONLY) || defined(WOLFSSL_PUBLIC_MP)) && \
|
||||
!defined(WC_NO_RSA_OAEP) && !defined(WC_NO_RNG)
|
||||
DECLARE_VAR_INIT(in, byte, inLen, inStr, HEAP_HINT);
|
||||
DECLARE_VAR(in, byte, inLen, HEAP_HINT);
|
||||
DECLARE_VAR(out, byte, RSA_TEST_BYTES, HEAP_HINT);
|
||||
DECLARE_VAR(plain, byte, RSA_TEST_BYTES, HEAP_HINT);
|
||||
#endif
|
||||
@ -14092,6 +14095,9 @@ WOLFSSL_TEST_SUBROUTINE int rsa_test(void)
|
||||
#ifdef DECLARE_VAR_IS_HEAP_ALLOC
|
||||
if ((in == NULL) || (out == NULL) || (plain == NULL))
|
||||
ERROR_OUT(MEMORY_E, exit_rsa);
|
||||
|
||||
if (in && inStr)
|
||||
XMEMCPY(in, inStr, inLen);
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
|
@ -412,15 +412,7 @@ decouple library dependencies with standard string, memory and so on.
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_SMALL_STACK)
|
||||
#define DECLARE_VAR_IS_HEAP_ALLOC
|
||||
#define DECLARE_VAR(VAR_NAME, VAR_TYPE, VAR_SIZE, HEAP) \
|
||||
VAR_TYPE* VAR_NAME = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT);
|
||||
#define DECLARE_VAR_INIT(VAR_NAME, VAR_TYPE, VAR_SIZE, INIT_VALUE, HEAP) \
|
||||
VAR_TYPE* VAR_NAME = ({ \
|
||||
VAR_TYPE* ptr = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); \
|
||||
if (ptr && INIT_VALUE) { \
|
||||
XMEMCPY(ptr, INIT_VALUE, sizeof(VAR_TYPE) * VAR_SIZE); \
|
||||
} \
|
||||
ptr; \
|
||||
})
|
||||
VAR_TYPE* VAR_NAME = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT)
|
||||
#define DECLARE_ARRAY(VAR_NAME, VAR_TYPE, VAR_ITEMS, VAR_SIZE, HEAP) \
|
||||
VAR_TYPE* VAR_NAME[VAR_ITEMS]; \
|
||||
int idx##VAR_NAME, inner_idx_##VAR_NAME; \
|
||||
@ -453,8 +445,6 @@ decouple library dependencies with standard string, memory and so on.
|
||||
#undef DECLARE_VAR_IS_HEAP_ALLOC
|
||||
#define DECLARE_VAR(VAR_NAME, VAR_TYPE, VAR_SIZE, HEAP) \
|
||||
VAR_TYPE VAR_NAME[VAR_SIZE]
|
||||
#define DECLARE_VAR_INIT(VAR_NAME, VAR_TYPE, VAR_SIZE, INIT_VALUE, HEAP) \
|
||||
VAR_TYPE* VAR_NAME = (VAR_TYPE*)INIT_VALUE
|
||||
#define DECLARE_ARRAY(VAR_NAME, VAR_TYPE, VAR_ITEMS, VAR_SIZE, HEAP) \
|
||||
VAR_TYPE VAR_NAME[VAR_ITEMS][VAR_SIZE]
|
||||
#define FREE_VAR(VAR_NAME, HEAP) /* nothing to free, its stack */
|
||||
|
Reference in New Issue
Block a user