@@ -7181,7 +7181,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
71817181 ERROR_OUT (MATCH_SUITE_ERROR , exit_dch );
71827182 }
71837183
7184- #ifdef HAVE_SESSION_TICKET
7184+ #if defined( HAVE_SESSION_TICKET ) || !defined( NO_PSK )
71857185 if (ssl -> options .resuming ) {
71867186 ssl -> options .resuming = 0 ;
71877187 ssl -> arrays -> psk_keySz = 0 ;
@@ -9145,41 +9145,12 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
91459145 #endif
91469146 #if defined(HAVE_FALCON )
91479147 else if (ssl -> hsType == DYNAMIC_TYPE_FALCON ) {
9148- falcon_key * fkey = (falcon_key * )ssl -> hsKey ;
9149- byte level = 0 ;
9150- if (wc_falcon_get_level (fkey , & level ) != 0 ) {
9151- ERROR_OUT (ALGO_ID_E , exit_scv );
9152- }
9153- if (level == 1 ) {
9154- args -> sigAlgo = falcon_level1_sa_algo ;
9155- }
9156- else if (level == 5 ) {
9157- args -> sigAlgo = falcon_level5_sa_algo ;
9158- }
9159- else {
9160- ERROR_OUT (ALGO_ID_E , exit_scv );
9161- }
9148+ args -> sigAlgo = ssl -> buffers .keyType ;
91629149 }
91639150 #endif /* HAVE_FALCON */
91649151 #if defined(HAVE_DILITHIUM )
91659152 else if (ssl -> hsType == DYNAMIC_TYPE_DILITHIUM ) {
9166- dilithium_key * fkey = (dilithium_key * )ssl -> hsKey ;
9167- byte level = 0 ;
9168- if (wc_dilithium_get_level (fkey , & level ) != 0 ) {
9169- ERROR_OUT (ALGO_ID_E , exit_scv );
9170- }
9171- if (level == 2 ) {
9172- args -> sigAlgo = dilithium_level2_sa_algo ;
9173- }
9174- else if (level == 3 ) {
9175- args -> sigAlgo = dilithium_level3_sa_algo ;
9176- }
9177- else if (level == 5 ) {
9178- args -> sigAlgo = dilithium_level5_sa_algo ;
9179- }
9180- else {
9181- ERROR_OUT (ALGO_ID_E , exit_scv );
9182- }
9153+ args -> sigAlgo = ssl -> buffers .keyType ;
91839154 }
91849155 #endif /* HAVE_DILITHIUM */
91859156 else {
@@ -9463,9 +9434,11 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
94639434 #endif /* HAVE_FALCON */
94649435 #if defined(HAVE_DILITHIUM ) && !defined(WOLFSSL_DILITHIUM_NO_SIGN )
94659436 if (ssl -> hsType == DYNAMIC_TYPE_DILITHIUM ) {
9466- ret = wc_dilithium_sign_msg (args -> sigData , args -> sigDataSz ,
9467- sigOut , & args -> sigLen ,
9468- (dilithium_key * )ssl -> hsKey , ssl -> rng );
9437+ ret = wc_dilithium_sign_ctx_msg (NULL , 0 , args -> sigData ,
9438+ args -> sigDataSz , sigOut ,
9439+ & args -> sigLen ,
9440+ (dilithium_key * )ssl -> hsKey ,
9441+ ssl -> rng );
94699442 args -> length = (word16 )args -> sigLen ;
94709443 }
94719444 #endif /* HAVE_DILITHIUM */
@@ -9557,11 +9530,9 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
95579530 #endif /* HAVE_FALCON */
95589531 #if defined(HAVE_DILITHIUM ) && !defined(WOLFSSL_DILITHIUM_NO_SIGN )
95599532 if (ssl -> hsAltType == DYNAMIC_TYPE_DILITHIUM ) {
9560- ret = wc_dilithium_sign_msg (args -> altSigData ,
9561- args -> altSigDataSz , sigOut ,
9562- & args -> altSigLen ,
9563- (dilithium_key * )ssl -> hsAltKey ,
9564- ssl -> rng );
9533+ ret = wc_dilithium_sign_ctx_msg (NULL , 0 , args -> altSigData ,
9534+ args -> altSigDataSz , sigOut , & args -> altSigLen ,
9535+ (dilithium_key * )ssl -> hsAltKey , ssl -> rng );
95659536 }
95669537 #endif /* HAVE_DILITHIUM */
95679538
@@ -10546,6 +10517,10 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
1054610517 (void * * )& ssl -> peerFalconKey );
1054710518 ssl -> peerFalconKeyPresent = 0 ;
1054810519 }
10520+ else if ((ret >= 0 ) && (res == 0 )) {
10521+ WOLFSSL_MSG ("Falcon signature verification failed" );
10522+ ret = SIG_VERIFY_E ;
10523+ }
1054910524 }
1055010525 #endif /* HAVE_FALCON */
1055110526 #if defined(HAVE_DILITHIUM ) && !defined(WOLFSSL_DILITHIUM_NO_VERIFY )
@@ -10555,9 +10530,9 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
1055510530 (ssl -> peerDilithiumKeyPresent )) {
1055610531 int res = 0 ;
1055710532 WOLFSSL_MSG ("Doing Dilithium peer cert verify" );
10558- ret = wc_dilithium_verify_msg (sig , args -> sigSz ,
10559- args -> sigData , args -> sigDataSz ,
10560- & res , ssl -> peerDilithiumKey );
10533+ ret = wc_dilithium_verify_ctx_msg (sig , args -> sigSz , NULL , 0 ,
10534+ args -> sigData , args -> sigDataSz ,
10535+ & res , ssl -> peerDilithiumKey );
1056110536
1056210537 if ((ret >= 0 ) && (res == 1 )) {
1056310538 /* CLIENT/SERVER: data verified with public key from
@@ -10568,6 +10543,10 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
1056810543 (void * * )& ssl -> peerDilithiumKey );
1056910544 ssl -> peerDilithiumKeyPresent = 0 ;
1057010545 }
10546+ else if ((ret >= 0 ) && (res == 0 )) {
10547+ WOLFSSL_MSG ("Dilithium signature verification failed" );
10548+ ret = SIG_VERIFY_E ;
10549+ }
1057110550 }
1057210551 #endif /* HAVE_DILITHIUM */
1057310552
@@ -10648,6 +10627,10 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
1064810627 (void * * )& ssl -> peerFalconKey );
1064910628 ssl -> peerFalconKeyPresent = 0 ;
1065010629 }
10630+ else if ((ret >= 0 ) && (res == 0 )) {
10631+ WOLFSSL_MSG ("Falcon signature verification failed" );
10632+ ret = SIG_VERIFY_E ;
10633+ }
1065110634 }
1065210635 #endif /* HAVE_FALCON */
1065310636 #if defined(HAVE_DILITHIUM ) && !defined(WOLFSSL_DILITHIUM_NO_VERIFY )
@@ -10657,9 +10640,10 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
1065710640 (ssl -> peerDilithiumKeyPresent )) {
1065810641 int res = 0 ;
1065910642 WOLFSSL_MSG ("Doing Dilithium peer cert alt verify" );
10660- ret = wc_dilithium_verify_msg (sig , args -> altSignatureSz ,
10661- args -> altSigData , args -> altSigDataSz ,
10662- & res , ssl -> peerDilithiumKey );
10643+ ret = wc_dilithium_verify_ctx_msg (sig , args -> altSignatureSz ,
10644+ NULL , 0 , args -> altSigData ,
10645+ args -> altSigDataSz , & res ,
10646+ ssl -> peerDilithiumKey );
1066310647
1066410648 if ((ret >= 0 ) && (res == 1 )) {
1066510649 /* CLIENT/SERVER: data verified with public key from
@@ -10670,6 +10654,10 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
1067010654 (void * * )& ssl -> peerDilithiumKey );
1067110655 ssl -> peerDilithiumKeyPresent = 0 ;
1067210656 }
10657+ else if ((ret >= 0 ) && (res == 0 )) {
10658+ WOLFSSL_MSG ("Dilithium signature verification failed" );
10659+ ret = SIG_VERIFY_E ;
10660+ }
1067310661 }
1067410662 #endif /* HAVE_DILITHIUM */
1067510663
0 commit comments