From 1681cb2d7e5ca7b4a1061d6f199870aa012ccc26 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Tue, 30 Jul 2024 09:09:26 +1000 Subject: [PATCH] Dilithium: DER encoding fix Underlying function SetAsymKeyDer() changed semantics. Update tests to reflect new behaviour. --- tests/api.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/api.c b/tests/api.c index 161590af2..275df0b29 100644 --- a/tests/api.c +++ b/tests/api.c @@ -33388,7 +33388,7 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_PublicKeyToDer(NULL, der , DILITHIUM_MAX_DER_SIZE, 0), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_PublicKeyToDer(key , der , 0 , - 0), BUFFER_E); + 0), BUFFER_E ); /* Get length only. */ ExpectIntEQ(wc_Dilithium_PublicKeyToDer(key , NULL, 0 , 0), pubLen); @@ -33401,8 +33401,8 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, NULL, 0 ), BAD_FUNC_ARG); - ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , NULL, - 0 ), BAD_FUNC_ARG); + ExpectIntGT(wc_Dilithium_PrivateKeyToDer(key , NULL, + 0 ), 0); ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, der , 0 ), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, NULL, @@ -33410,15 +33410,15 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(NULL, der , DILITHIUM_MAX_DER_SIZE), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , der , - 0 ), BAD_FUNC_ARG); + 0 ), BUFFER_E); /* Get length only. */ ExpectIntEQ(wc_Dilithium_PrivateKeyToDer(key , NULL, DILITHIUM_MAX_DER_SIZE), privDerLen); ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, NULL, 0 ), BAD_FUNC_ARG); - ExpectIntEQ(wc_Dilithium_KeyToDer(key , NULL, 0 ), - BAD_FUNC_ARG); + ExpectIntGT(wc_Dilithium_KeyToDer(key , NULL, 0 ), + 0 ); ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, der , 0 ), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, NULL, DILITHIUM_MAX_DER_SIZE), @@ -33426,7 +33426,7 @@ static int test_wc_dilithium_der(void) ExpectIntEQ(wc_Dilithium_KeyToDer(NULL, der , DILITHIUM_MAX_DER_SIZE), BAD_FUNC_ARG); ExpectIntEQ(wc_Dilithium_KeyToDer(key , der , 0 ), - BAD_FUNC_ARG); + BUFFER_E ); /* Get length only. */ ExpectIntEQ(wc_Dilithium_KeyToDer(key , NULL, DILITHIUM_MAX_DER_SIZE), keyDerLen);