diff --git a/tests/api/test_mldsa.c b/tests/api/test_mldsa.c index 445412cff..132b797c9 100644 --- a/tests/api/test_mldsa.c +++ b/tests/api/test_mldsa.c @@ -3004,13 +3004,8 @@ int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, NULL, 0 ), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); -#ifndef WOLFSSL_ASN_TEMPLATE - ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , NULL, - 0 ), BAD_FUNC_ARG); -#else ExpectIntGT(wc_Dilithium_PrivateKeyToDer(key , NULL, 0 ), 0); -#endif ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, der , 0 ), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, NULL, @@ -3020,23 +3015,13 @@ int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , der , 0 ), WC_NO_ERR_TRACE(BUFFER_E)); /* Get length only. */ -#ifndef WOLFSSL_ASN_TEMPLATE - ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , NULL, - DILITHIUM_MAX_DER_SIZE), BAD_FUNC_ARG); -#else ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , NULL, DILITHIUM_MAX_DER_SIZE), privDerLen); -#endif ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, NULL, 0 ), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); -#ifndef WOLFSSL_ASN_TEMPLATE - ExpectIntEQ(wc_Dilithium_KeyToDer(key , NULL, 0 ), - BAD_FUNC_ARG); -#else ExpectIntGT(wc_Dilithium_KeyToDer(key , NULL, 0 ), 0 ); -#endif ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, der , 0 ), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, NULL, DILITHIUM_MAX_DER_SIZE), @@ -3046,13 +3031,8 @@ int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_KeyToDer(key , der , 0 ), WC_NO_ERR_TRACE(BUFFER_E)); /* Get length only. */ -#ifndef WOLFSSL_ASN_TEMPLATE - ExpectIntEQ(wc_Dilithium_KeyToDer(key , NULL, DILITHIUM_MAX_DER_SIZE), - BAD_FUNC_ARG); -#else ExpectIntEQ(wc_Dilithium_KeyToDer(key , NULL, DILITHIUM_MAX_DER_SIZE), keyDerLen); -#endif ExpectIntEQ(wc_Dilithium_PublicKeyDecode(NULL, NULL, NULL, 0 ), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); @@ -3101,25 +3081,15 @@ int test_wc_dilithium_der(void) idx = 0; ExpectIntEQ(wc_Dilithium_PublicKeyDecode(der, &idx, key, len), 0); -#ifndef WOLFSSL_ASN_TEMPLATE - ExpectIntEQ(len = wc_Dilithium_PrivateKeyToDer(key, der, - DILITHIUM_MAX_DER_SIZE), BAD_FUNC_ARG); -#else ExpectIntEQ(len = wc_Dilithium_PrivateKeyToDer(key, der, DILITHIUM_MAX_DER_SIZE), privDerLen); idx = 0; ExpectIntEQ(wc_Dilithium_PrivateKeyDecode(der, &idx, key, len), 0); -#endif -#ifndef WOLFSSL_ASN_TEMPLATE - ExpectIntEQ(len = wc_Dilithium_KeyToDer(key, der, DILITHIUM_MAX_DER_SIZE), - BAD_FUNC_ARG); -#else ExpectIntEQ(len = wc_Dilithium_KeyToDer(key, der, DILITHIUM_MAX_DER_SIZE), keyDerLen); idx = 0; ExpectIntEQ(wc_Dilithium_PrivateKeyDecode(der, &idx, key, len), 0); -#endif wc_dilithium_free(key); @@ -3127,8 +3097,6 @@ int test_wc_dilithium_der(void) XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); - - (void)keyDerLen; #endif return EXPECT_RESULT(); } @@ -16910,7 +16878,7 @@ int test_mldsa_pkcs8_export_import_wolfSSL_form(void) (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) && \ !defined(WOLFSSL_DILITHIUM_NO_MAKE_KEY) && \ !defined(WOLFSSL_DILITHIUM_NO_SIGN) && \ - !defined(WOLFSSL_DILITHIUM_NO_ASN1) && defined(WOLFSSL_ASN_TEMPLATE) + !defined(WOLFSSL_DILITHIUM_NO_ASN1) WOLFSSL_CTX* ctx = NULL; size_t i; diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index c366d9526..5daa44312 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -37583,11 +37583,6 @@ int SetAsymKeyDer(const byte* privKey, word32 privKeyLen, } #ifndef WOLFSSL_ASN_TEMPLATE - if (privKeyLen >= 128 || pubKeyLen >= 128) { - /* privKeyLen and pubKeyLen are assumed to be less than 128 */ - return BAD_FUNC_ARG; - } - /* calculate size */ if (pubKey) { pubSz = 2 + pubKeyLen; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 3b03179ba..b86ac6f56 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -46932,7 +46932,7 @@ static wc_test_ret_t test_dilithium_decode_level(const byte* rawKey, int isPublicOnlyKey) { int ret = 0; -#if !defined(WOLFSSL_DILITHIUM_NO_ASN1) && defined(WOLFSSL_ASN_TEMPLATE) +#ifndef WOLFSSL_DILITHIUM_NO_ASN1 /* Size the buffer to accommodate the largest encoded key size */ const word32 maxDerSz = DILITHIUM_MAX_PRV_KEY_DER_SIZE; word32 derSz; @@ -46982,7 +46982,7 @@ static wc_test_ret_t test_dilithium_decode_level(const byte* rawKey, #endif } -#if !defined(WOLFSSL_DILITHIUM_NO_ASN1) && defined(WOLFSSL_ASN_TEMPLATE) +#ifndef WOLFSSL_DILITHIUM_NO_ASN1 /* Export raw key as DER */ if (ret == 0) { #ifdef WOLFSSL_DILITHIUM_PUBLIC_KEY @@ -47056,7 +47056,7 @@ static wc_test_ret_t test_dilithium_decode_level(const byte* rawKey, ret = WC_TEST_RET_ENC_NC; } #endif /* !WOLFSSL_DILITHIUM_FIPS204_DRAFT */ -#endif /* !WOLFSSL_DILITHIUM_NO_ASN1 && WOLFSSL_ASN_TEMPLATE */ +#endif /* WOLFSSL_DILITHIUM_NO_ASN1 */ /* Cleanup */ wc_dilithium_free(key);