diff --git a/.github/workflows/async-examples.yml b/.github/workflows/async-examples.yml index f8a1a0ae56..00da6049f3 100644 --- a/.github/workflows/async-examples.yml +++ b/.github/workflows/async-examples.yml @@ -15,6 +15,14 @@ jobs: if: github.repository_owner == 'wolfssl' runs-on: ubuntu-24.04 timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + extra_cflags: + - '' + - '-DWOLFSSL_SMALL_CERT_VERIFY' + - '-DWOLFSSL_STATIC_MEMORY' + name: Async Examples (${{ matrix.extra_cflags || 'default' }}) steps: - uses: actions/checkout@v4 name: Checkout wolfSSL @@ -22,7 +30,7 @@ jobs: - name: Build async examples (no configure) run: | make -C examples/async clean - make -C examples/async + make -C examples/async EXTRA_CFLAGS="${{ matrix.extra_cflags }}" - name: Run async examples run: | diff --git a/examples/async/Makefile b/examples/async/Makefile index 340dce71ee..8747b5c462 100644 --- a/examples/async/Makefile +++ b/examples/async/Makefile @@ -14,6 +14,7 @@ CFLAGS += -Wall -Wextra -Wpedantic -Werror CFLAGS += -DWOLFSSL_USER_SETTINGS CFLAGS += -DHAVE_SYS_TIME_H CFLAGS += -DUSE_CERT_BUFFERS_256 +CFLAGS += $(EXTRA_CFLAGS) LDFLAGS ?= LDLIBS ?= diff --git a/examples/async/async_client.c b/examples/async/async_client.c index 5ebc451491..d4a8cd6d16 100644 --- a/examples/async/async_client.c +++ b/examples/async/async_client.c @@ -232,6 +232,13 @@ int client_async_test(int argc, char** argv) #ifdef WOLFSSL_DEBUG_NONBLOCK int wouldblock_count = 0; int pending_count = 0; +#endif +#ifdef WOLFSSL_STATIC_MEMORY + static byte memory[300000]; + static byte memoryIO[34500]; + #if !defined(WOLFSSL_STATIC_MEMORY_LEAN) + WOLFSSL_MEM_CONN_STATS ssl_stats; + #endif #endif const char* host = NULL; int port = 0; @@ -273,12 +280,36 @@ int client_async_test(int argc, char** argv) } #endif -#ifndef WOLFSSL_NO_TLS12 +#ifdef WOLFSSL_STATIC_MEMORY + { + wolfSSL_method_func method; + #ifndef WOLFSSL_NO_TLS12 + if (tls12) + method = wolfTLSv1_2_client_method_ex; + else + #endif + method = wolfSSLv23_client_method_ex; + if (wolfSSL_CTX_load_static_memory(&ctx, method, memory, + sizeof(memory), 0, 1) != WOLFSSL_SUCCESS) { + fprintf(stderr, "ERROR: unable to load static memory\n"); + goto out; + } + if (wolfSSL_CTX_load_static_memory(&ctx, NULL, memoryIO, + sizeof(memoryIO), + WOLFMEM_IO_POOL_FIXED | WOLFMEM_TRACK_STATS, 1) + != WOLFSSL_SUCCESS) { + fprintf(stderr, "ERROR: unable to load static IO memory\n"); + goto out; + } + } +#else + #ifndef WOLFSSL_NO_TLS12 if (tls12) ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method()); else -#endif + #endif ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); +#endif /* WOLFSSL_STATIC_MEMORY */ if (ctx == NULL) { goto out; } @@ -495,6 +526,21 @@ int client_async_test(int argc, char** argv) ret = 0; out: +#if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY_LEAN) + if (ssl != NULL && + wolfSSL_is_static_memory(ssl, &ssl_stats) == 1) { + fprintf(stderr, "peak connection memory = %d\n", + ssl_stats.peakMem); + fprintf(stderr, "current memory in use = %d\n", + ssl_stats.curMem); + fprintf(stderr, "peak connection allocs = %d\n", + ssl_stats.peakAlloc); + fprintf(stderr, "total connection allocs = %d\n", + ssl_stats.totalAlloc); + fprintf(stderr, "total connection frees = %d\n", + ssl_stats.totalFr); + } +#endif if (ssl != NULL) { wolfSSL_shutdown(ssl); wolfSSL_free(ssl); diff --git a/examples/async/async_server.c b/examples/async/async_server.c index db669377e9..541e9a8429 100644 --- a/examples/async/async_server.c +++ b/examples/async/async_server.c @@ -191,6 +191,13 @@ int server_async_test(int argc, char** argv) int wouldblock_count = 0; int pending_count = 0; #endif +#ifdef WOLFSSL_STATIC_MEMORY + static byte memory[300000]; + static byte memoryIO[34500]; + #if !defined(WOLFSSL_STATIC_MEMORY_LEAN) + WOLFSSL_MEM_CONN_STATS ssl_stats; + #endif +#endif /* declare wolfSSL objects */ WOLFSSL_CTX* ctx = NULL; @@ -279,12 +286,36 @@ int server_async_test(int argc, char** argv) #endif /* Create and initialize WOLFSSL_CTX */ -#ifndef WOLFSSL_NO_TLS12 +#ifdef WOLFSSL_STATIC_MEMORY + { + wolfSSL_method_func method; + #ifndef WOLFSSL_NO_TLS12 + if (tls12) + method = wolfTLSv1_2_server_method_ex; + else + #endif + method = wolfSSLv23_server_method_ex; + if (wolfSSL_CTX_load_static_memory(&ctx, method, memory, + sizeof(memory), 0, 1) != WOLFSSL_SUCCESS) { + fprintf(stderr, "ERROR: unable to load static memory\n"); + goto exit; + } + if (wolfSSL_CTX_load_static_memory(&ctx, NULL, memoryIO, + sizeof(memoryIO), + WOLFMEM_IO_POOL_FIXED | WOLFMEM_TRACK_STATS, 1) + != WOLFSSL_SUCCESS) { + fprintf(stderr, "ERROR: unable to load static IO memory\n"); + goto exit; + } + } +#else + #ifndef WOLFSSL_NO_TLS12 if (tls12) ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method()); else -#endif + #endif ctx = wolfSSL_CTX_new(wolfSSLv23_server_method()); +#endif /* WOLFSSL_STATIC_MEMORY */ if (ctx == NULL) { fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n"); ret = -1; @@ -535,6 +566,21 @@ int server_async_test(int argc, char** argv) #endif /* Cleanup after this connection */ +#if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY_LEAN) + if (ssl != NULL && + wolfSSL_is_static_memory(ssl, &ssl_stats) == 1) { + fprintf(stderr, "peak connection memory = %d\n", + ssl_stats.peakMem); + fprintf(stderr, "current memory in use = %d\n", + ssl_stats.curMem); + fprintf(stderr, "peak connection allocs = %d\n", + ssl_stats.peakAlloc); + fprintf(stderr, "total connection allocs = %d\n", + ssl_stats.totalAlloc); + fprintf(stderr, "total connection frees = %d\n", + ssl_stats.totalFr); + } +#endif wolfSSL_shutdown(ssl); if (ssl) { wolfSSL_free(ssl); diff --git a/examples/configs/include.am b/examples/configs/include.am index 2266215bc1..9def0850c8 100644 --- a/examples/configs/include.am +++ b/examples/configs/include.am @@ -6,6 +6,7 @@ EXTRA_DIST += examples/configs/user_settings_all.h EXTRA_DIST += examples/configs/user_settings_arduino.h EXTRA_DIST += examples/configs/user_settings_baremetal.h EXTRA_DIST += examples/configs/user_settings_ca.h +EXTRA_DIST += examples/configs/user_settings_curve25519nonblock.h EXTRA_DIST += examples/configs/user_settings_dtls13.h EXTRA_DIST += examples/configs/user_settings_EBSnet.h EXTRA_DIST += examples/configs/user_settings_eccnonblock.h diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index 411b693709..9bd9f81e4b 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -74917,6 +74917,9 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, int err = FP_WOULDBLOCK; sp_256_proj_point_add_8_ctx* ctx = (sp_256_proj_point_add_8_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_256_proj_point_add_8_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_256* a = p; @@ -74924,9 +74927,6 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, q = a; } - typedef char ctx_size_test[sizeof(sp_256_proj_point_add_8_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -92908,6 +92908,9 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, int err = FP_WOULDBLOCK; sp_384_proj_point_add_12_ctx* ctx = (sp_384_proj_point_add_12_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_384_proj_point_add_12_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_384* a = p; @@ -92915,9 +92918,6 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, q = a; } - typedef char ctx_size_test[sizeof(sp_384_proj_point_add_12_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -119987,6 +119987,9 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, int err = FP_WOULDBLOCK; sp_521_proj_point_add_17_ctx* ctx = (sp_521_proj_point_add_17_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_521_proj_point_add_17_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_521* a = p; @@ -119994,9 +119997,6 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, q = a; } - typedef char ctx_size_test[sizeof(sp_521_proj_point_add_17_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -150008,6 +150008,9 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, int err = FP_WOULDBLOCK; sp_1024_proj_point_add_32_ctx* ctx = (sp_1024_proj_point_add_32_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_32_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_1024* a = p; @@ -150015,9 +150018,6 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, q = a; } - typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_32_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index 82ce529bd4..7bc4e8ab90 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -23532,6 +23532,9 @@ static int sp_256_proj_point_add_4_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, int err = FP_WOULDBLOCK; sp_256_proj_point_add_4_ctx* ctx = (sp_256_proj_point_add_4_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_256_proj_point_add_4_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_256* a = p; @@ -23539,9 +23542,6 @@ static int sp_256_proj_point_add_4_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, q = a; } - typedef char ctx_size_test[sizeof(sp_256_proj_point_add_4_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -44108,6 +44108,9 @@ static int sp_384_proj_point_add_6_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, int err = FP_WOULDBLOCK; sp_384_proj_point_add_6_ctx* ctx = (sp_384_proj_point_add_6_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_384_proj_point_add_6_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_384* a = p; @@ -44115,9 +44118,6 @@ static int sp_384_proj_point_add_6_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, q = a; } - typedef char ctx_size_test[sizeof(sp_384_proj_point_add_6_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -72055,6 +72055,9 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, int err = FP_WOULDBLOCK; sp_521_proj_point_add_9_ctx* ctx = (sp_521_proj_point_add_9_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_521_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_521* a = p; @@ -72062,9 +72065,6 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, q = a; } - typedef char ctx_size_test[sizeof(sp_521_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -115721,6 +115721,9 @@ static int sp_1024_proj_point_add_16_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, int err = FP_WOULDBLOCK; sp_1024_proj_point_add_16_ctx* ctx = (sp_1024_proj_point_add_16_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_16_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_1024* a = p; @@ -115728,9 +115731,6 @@ static int sp_1024_proj_point_add_16_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, q = a; } - typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_16_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index efcdca728a..872ea8be7e 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -100369,6 +100369,9 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, int err = FP_WOULDBLOCK; sp_256_proj_point_add_8_ctx* ctx = (sp_256_proj_point_add_8_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_256_proj_point_add_8_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_256* a = p; @@ -100376,9 +100379,6 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, q = a; } - typedef char ctx_size_test[sizeof(sp_256_proj_point_add_8_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -110760,6 +110760,9 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, int err = FP_WOULDBLOCK; sp_384_proj_point_add_12_ctx* ctx = (sp_384_proj_point_add_12_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_384_proj_point_add_12_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_384* a = p; @@ -110767,9 +110770,6 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, q = a; } - typedef char ctx_size_test[sizeof(sp_384_proj_point_add_12_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -123926,6 +123926,9 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, int err = FP_WOULDBLOCK; sp_521_proj_point_add_17_ctx* ctx = (sp_521_proj_point_add_17_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_521_proj_point_add_17_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_521* a = p; @@ -123933,9 +123936,6 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, q = a; } - typedef char ctx_size_test[sizeof(sp_521_proj_point_add_17_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -208389,6 +208389,9 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, int err = FP_WOULDBLOCK; sp_1024_proj_point_add_32_ctx* ctx = (sp_1024_proj_point_add_32_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_32_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_1024* a = p; @@ -208396,9 +208399,6 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, q = a; } - typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_32_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 5caa829c5e..dc228c5945 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -19982,6 +19982,9 @@ static int sp_256_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, int err = FP_WOULDBLOCK; sp_256_proj_point_add_9_ctx* ctx = (sp_256_proj_point_add_9_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_256_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_256* a = p; @@ -19989,9 +19992,6 @@ static int sp_256_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, q = a; } - typedef char ctx_size_test[sizeof(sp_256_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -26983,6 +26983,9 @@ static int sp_384_proj_point_add_15_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, int err = FP_WOULDBLOCK; sp_384_proj_point_add_15_ctx* ctx = (sp_384_proj_point_add_15_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_384_proj_point_add_15_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_384* a = p; @@ -26990,9 +26993,6 @@ static int sp_384_proj_point_add_15_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, q = a; } - typedef char ctx_size_test[sizeof(sp_384_proj_point_add_15_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -34228,6 +34228,9 @@ static int sp_521_proj_point_add_21_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, int err = FP_WOULDBLOCK; sp_521_proj_point_add_21_ctx* ctx = (sp_521_proj_point_add_21_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_521_proj_point_add_21_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_521* a = p; @@ -34235,9 +34238,6 @@ static int sp_521_proj_point_add_21_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, q = a; } - typedef char ctx_size_test[sizeof(sp_521_proj_point_add_21_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -42594,6 +42594,9 @@ static int sp_1024_proj_point_add_42_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, int err = FP_WOULDBLOCK; sp_1024_proj_point_add_42_ctx* ctx = (sp_1024_proj_point_add_42_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_42_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_1024* a = p; @@ -42601,9 +42604,6 @@ static int sp_1024_proj_point_add_42_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, q = a; } - typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_42_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 7ce2ae3983..51d55f642b 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -20599,6 +20599,9 @@ static int sp_256_proj_point_add_5_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, int err = FP_WOULDBLOCK; sp_256_proj_point_add_5_ctx* ctx = (sp_256_proj_point_add_5_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_256_proj_point_add_5_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_256* a = p; @@ -20606,9 +20609,6 @@ static int sp_256_proj_point_add_5_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, q = a; } - typedef char ctx_size_test[sizeof(sp_256_proj_point_add_5_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -27087,6 +27087,9 @@ static int sp_384_proj_point_add_7_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, int err = FP_WOULDBLOCK; sp_384_proj_point_add_7_ctx* ctx = (sp_384_proj_point_add_7_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_384_proj_point_add_7_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_384* a = p; @@ -27094,9 +27097,6 @@ static int sp_384_proj_point_add_7_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, q = a; } - typedef char ctx_size_test[sizeof(sp_384_proj_point_add_7_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -34191,6 +34191,9 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, int err = FP_WOULDBLOCK; sp_521_proj_point_add_9_ctx* ctx = (sp_521_proj_point_add_9_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_521_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_521* a = p; @@ -34198,9 +34201,6 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, q = a; } - typedef char ctx_size_test[sizeof(sp_521_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -41643,6 +41643,9 @@ static int sp_1024_proj_point_add_18_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, int err = FP_WOULDBLOCK; sp_1024_proj_point_add_18_ctx* ctx = (sp_1024_proj_point_add_18_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_18_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_1024* a = p; @@ -41650,9 +41653,6 @@ static int sp_1024_proj_point_add_18_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, q = a; } - typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_18_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 1d4842f5ae..6a9b4ea913 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -36307,6 +36307,9 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, int err = FP_WOULDBLOCK; sp_256_proj_point_add_8_ctx* ctx = (sp_256_proj_point_add_8_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_256_proj_point_add_8_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_256* a = p; @@ -36314,9 +36317,6 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, q = a; } - typedef char ctx_size_test[sizeof(sp_256_proj_point_add_8_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -46218,6 +46218,9 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, int err = FP_WOULDBLOCK; sp_384_proj_point_add_12_ctx* ctx = (sp_384_proj_point_add_12_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_384_proj_point_add_12_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_384* a = p; @@ -46225,9 +46228,6 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, q = a; } - typedef char ctx_size_test[sizeof(sp_384_proj_point_add_12_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -58009,6 +58009,9 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, int err = FP_WOULDBLOCK; sp_521_proj_point_add_17_ctx* ctx = (sp_521_proj_point_add_17_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_521_proj_point_add_17_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_521* a = p; @@ -58016,9 +58019,6 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, q = a; } - typedef char ctx_size_test[sizeof(sp_521_proj_point_add_17_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -72548,6 +72548,9 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, int err = FP_WOULDBLOCK; sp_1024_proj_point_add_32_ctx* ctx = (sp_1024_proj_point_add_32_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_32_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_1024* a = p; @@ -72555,9 +72558,6 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, q = a; } - typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_32_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index dcefe798f2..bc7300364c 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -8505,6 +8505,9 @@ static int sp_256_proj_point_add_4_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, int err = FP_WOULDBLOCK; sp_256_proj_point_add_4_ctx* ctx = (sp_256_proj_point_add_4_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_256_proj_point_add_4_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_256* a = p; @@ -8512,9 +8515,6 @@ static int sp_256_proj_point_add_4_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r, q = a; } - typedef char ctx_size_test[sizeof(sp_256_proj_point_add_4_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -9606,6 +9606,9 @@ static int sp_256_proj_point_add_avx2_4_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r int err = FP_WOULDBLOCK; sp_256_proj_point_add_avx2_4_ctx* ctx = (sp_256_proj_point_add_avx2_4_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_256_proj_point_add_avx2_4_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_256* a = p; @@ -9613,9 +9616,6 @@ static int sp_256_proj_point_add_avx2_4_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r q = a; } - typedef char ctx_size_test[sizeof(sp_256_proj_point_add_avx2_4_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -27196,6 +27196,9 @@ static int sp_384_proj_point_add_6_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, int err = FP_WOULDBLOCK; sp_384_proj_point_add_6_ctx* ctx = (sp_384_proj_point_add_6_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_384_proj_point_add_6_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_384* a = p; @@ -27203,9 +27206,6 @@ static int sp_384_proj_point_add_6_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r, q = a; } - typedef char ctx_size_test[sizeof(sp_384_proj_point_add_6_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -28350,6 +28350,9 @@ static int sp_384_proj_point_add_avx2_6_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r int err = FP_WOULDBLOCK; sp_384_proj_point_add_avx2_6_ctx* ctx = (sp_384_proj_point_add_avx2_6_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_384_proj_point_add_avx2_6_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_384* a = p; @@ -28357,9 +28360,6 @@ static int sp_384_proj_point_add_avx2_6_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r q = a; } - typedef char ctx_size_test[sizeof(sp_384_proj_point_add_avx2_6_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -51673,6 +51673,9 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, int err = FP_WOULDBLOCK; sp_521_proj_point_add_9_ctx* ctx = (sp_521_proj_point_add_9_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_521_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_521* a = p; @@ -51680,9 +51683,6 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r, q = a; } - typedef char ctx_size_test[sizeof(sp_521_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -52804,6 +52804,9 @@ static int sp_521_proj_point_add_avx2_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r int err = FP_WOULDBLOCK; sp_521_proj_point_add_avx2_9_ctx* ctx = (sp_521_proj_point_add_avx2_9_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_521_proj_point_add_avx2_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_521* a = p; @@ -52811,9 +52814,6 @@ static int sp_521_proj_point_add_avx2_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r q = a; } - typedef char ctx_size_test[sizeof(sp_521_proj_point_add_avx2_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -92503,6 +92503,9 @@ static int sp_1024_proj_point_add_16_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, int err = FP_WOULDBLOCK; sp_1024_proj_point_add_16_ctx* ctx = (sp_1024_proj_point_add_16_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_16_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_1024* a = p; @@ -92510,9 +92513,6 @@ static int sp_1024_proj_point_add_16_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r, q = a; } - typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_16_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t; @@ -93604,6 +93604,9 @@ static int sp_1024_proj_point_add_avx2_16_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024 int err = FP_WOULDBLOCK; sp_1024_proj_point_add_avx2_16_ctx* ctx = (sp_1024_proj_point_add_avx2_16_ctx*)sp_ctx->data; + typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_avx2_16_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; + (void)sizeof(ctx_size_test); + /* Ensure only the first point is the same as the result. */ if (q == r) { const sp_point_1024* a = p; @@ -93611,9 +93614,6 @@ static int sp_1024_proj_point_add_avx2_16_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024 q = a; } - typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_avx2_16_ctx) >= sizeof(*sp_ctx) ? -1 : 1]; - (void)sizeof(ctx_size_test); - switch (ctx->state) { case 0: /* INIT */ ctx->t6 = t;