diff --git a/tests/api.c b/tests/api.c index db28adb1e..c6bd6ef5e 100644 --- a/tests/api.c +++ b/tests/api.c @@ -27834,11 +27834,11 @@ static int test_wc_PKCS7_VerifySignedData_RSA(void) struct tm tmpTimeStorage; struct tm* tmpTime = &tmpTimeStorage; #endif - #ifndef NO_PKCS7_STREAM - word32 z; - int ret; - #endif /* !NO_PKCS7_STREAM */ #endif /* !NO_ASN && !NO_ASN_TIME */ +#ifndef NO_PKCS7_STREAM + word32 z; + int ret; +#endif /* !NO_PKCS7_STREAM */ XMEMSET(&hash, 0, sizeof(wc_HashAlg)); diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 652d3fc76..2f51aeffc 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -8768,12 +8768,12 @@ void bench_rsa(int useDeviceID) #elif defined(USE_CERT_BUFFERS_2048) || defined(USE_CERT_BUFFERS_3072) bytes = 12; #endif - ret = mp_read_unsigned_bin(rsaKey[i].n, &tmp[bytes], rsaKeySz/8); + ret = mp_read_unsigned_bin(&rsaKey[i]->n, &tmp[bytes], rsaKeySz/8); if (ret != 0) { printf("wc_RsaPrivateKeyDecode failed! %d\n", ret); goto exit; } - ret = mp_set_int(rsaKey[i].e, WC_RSA_EXPONENT); + ret = mp_set_int(&rsaKey[i]->e, WC_RSA_EXPONENT); if (ret != 0) { printf("wc_RsaPrivateKeyDecode failed! %d\n", ret); goto exit; diff --git a/wolfcrypt/src/cmac.c b/wolfcrypt/src/cmac.c index 2065213f8..c1edfc3ab 100644 --- a/wolfcrypt/src/cmac.c +++ b/wolfcrypt/src/cmac.c @@ -460,7 +460,8 @@ int wc_AesCmacVerify(const byte* check, word32 checkSz, Cmac cmac[1]; #endif - if (check == NULL || (in == NULL && inSz > 0) || key == NULL || keySz == 0) { + if (check == NULL || checkSz == 0 || (in == NULL && inSz > 0) || + key == NULL || keySz == 0) { return BAD_FUNC_ARG; } diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index ebe6d4fb3..de6d695d5 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -16134,8 +16134,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void) #ifdef WOLFSSL_CERT_GEN static const char* rsaCaCertFile = CERT_ROOT "ca-cert.pem"; #endif - #if (defined(WOLFSSL_ALT_NAMES) || defined(HAVE_PKCS7)) \ - && !defined(NO_ASN_TIME) + #if defined(WOLFSSL_ALT_NAMES) || defined(HAVE_PKCS7) static const char* rsaCaCertDerFile = CERT_ROOT "ca-cert.der"; #endif #ifdef HAVE_PKCS7 diff --git a/wolfssl/test.h b/wolfssl/test.h index d0b961a83..47abb74af 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -2541,10 +2541,42 @@ static WC_INLINE void CRL_CallBack(const char* url) #endif #ifndef NO_DH -static WC_INLINE void SetDH(WOLFSSL* ssl) -{ +#if defined(WOLFSSL_SP_MATH) && !defined(WOLFSS_SP_MATH_ALL) + /* dh2048 p */ + static const unsigned char test_dh_p[] = + { + 0xD3, 0xB2, 0x99, 0x84, 0x5C, 0x0A, 0x4C, 0xE7, 0x37, 0xCC, 0xFC, 0x18, + 0x37, 0x01, 0x2F, 0x5D, 0xC1, 0x4C, 0xF4, 0x5C, 0xC9, 0x82, 0x8D, 0xB7, + 0xF3, 0xD4, 0xA9, 0x8A, 0x9D, 0x34, 0xD7, 0x76, 0x57, 0xE5, 0xE5, 0xC3, + 0xE5, 0x16, 0x85, 0xCA, 0x4D, 0xD6, 0x5B, 0xC1, 0xF8, 0xCF, 0x89, 0x26, + 0xD0, 0x38, 0x8A, 0xEE, 0xF3, 0xCD, 0x33, 0xE5, 0x56, 0xBB, 0x90, 0x83, + 0x9F, 0x97, 0x8E, 0x71, 0xFB, 0x27, 0xE4, 0x35, 0x15, 0x45, 0x86, 0x09, + 0x71, 0xA8, 0x9A, 0xB9, 0x3E, 0x0F, 0x51, 0x8A, 0xC2, 0x75, 0x51, 0x23, + 0x12, 0xFB, 0x94, 0x31, 0x44, 0xBF, 0xCE, 0xF6, 0xED, 0xA6, 0x3A, 0xB7, + 0x92, 0xCE, 0x16, 0xA9, 0x14, 0xB3, 0x88, 0xB7, 0x13, 0x81, 0x71, 0x83, + 0x88, 0xCD, 0xB1, 0xA2, 0x37, 0xE1, 0x59, 0x5C, 0xD0, 0xDC, 0xCA, 0x82, + 0x87, 0xFA, 0x43, 0x44, 0xDD, 0x78, 0x3F, 0xCA, 0x27, 0x7E, 0xE1, 0x6B, + 0x93, 0x19, 0x7C, 0xD9, 0xA6, 0x96, 0x47, 0x0D, 0x12, 0xC1, 0x13, 0xD7, + 0xB9, 0x0A, 0x40, 0xD9, 0x1F, 0xFF, 0xB8, 0xB4, 0x00, 0xC8, 0xAA, 0x5E, + 0xD2, 0x66, 0x4A, 0x05, 0x8E, 0x9E, 0xF5, 0x34, 0xE7, 0xD7, 0x09, 0x7B, + 0x15, 0x49, 0x1D, 0x76, 0x31, 0xD6, 0x71, 0xEC, 0x13, 0x4E, 0x89, 0x8C, + 0x09, 0x22, 0xD8, 0xE7, 0xA3, 0xE9, 0x7D, 0x21, 0x51, 0x26, 0x6E, 0x9F, + 0x30, 0x8A, 0xBB, 0xBC, 0x74, 0xC1, 0xC3, 0x27, 0x6A, 0xCE, 0xA3, 0x12, + 0x60, 0x68, 0x01, 0xD2, 0x34, 0x07, 0x80, 0xCC, 0x2D, 0x7F, 0x5C, 0xAE, + 0xA2, 0x97, 0x40, 0xC8, 0x3C, 0xAC, 0xDB, 0x6F, 0xFE, 0x6C, 0x6D, 0xD2, + 0x06, 0x1C, 0x43, 0xA2, 0xB2, 0x2B, 0x82, 0xB7, 0xD0, 0xAB, 0x3F, 0x2C, + 0xE7, 0x9C, 0x19, 0x16, 0xD1, 0x5E, 0x26, 0x86, 0xC7, 0x92, 0xF9, 0x16, + 0x0B, 0xFA, 0x66, 0x83 + }; + + /* dh2048 g */ + static const unsigned char test_dh_g[] = + { + 0x02, + }; +#else /* dh1024 p */ - static const unsigned char p[] = + static const unsigned char test_dh_p[] = { 0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3, 0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E, @@ -2560,39 +2592,22 @@ static WC_INLINE void SetDH(WOLFSSL* ssl) }; /* dh1024 g */ - static const unsigned char g[] = + static const unsigned char test_dh_g[] = { 0x02, }; +#endif - wolfSSL_SetTmpDH(ssl, p, sizeof(p), g, sizeof(g)); +static WC_INLINE void SetDH(WOLFSSL* ssl) +{ + wolfSSL_SetTmpDH(ssl, test_dh_p, sizeof(test_dh_p), test_dh_g, + sizeof(test_dh_g)); } static WC_INLINE void SetDHCtx(WOLFSSL_CTX* ctx) { - /* dh1024 p */ - static const unsigned char p[] = - { - 0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3, - 0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E, - 0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59, - 0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2, - 0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD, - 0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF, - 0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02, - 0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C, - 0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7, - 0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50, - 0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B, - }; - - /* dh1024 g */ - static const unsigned char g[] = - { - 0x02, - }; - - wolfSSL_CTX_SetTmpDH(ctx, p, sizeof(p), g, sizeof(g)); + wolfSSL_CTX_SetTmpDH(ctx, test_dh_p, sizeof(test_dh_p), test_dh_g, + sizeof(test_dh_g)); } #endif /* NO_DH */