@@ -3317,3 +3317,38 @@ int test_tls13_cert_req_sigalgs(void)
33173317 return EXPECT_RESULT ();
33183318}
33193319
3320+ int test_tls13_derive_keys_no_key (void )
3321+ {
3322+ EXPECT_DECLS ;
3323+ #if defined(WOLFSSL_TLS13 ) && defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES )
3324+ struct test_memio_ctx test_ctx ;
3325+ WOLFSSL_CTX * ctx_c = NULL ;
3326+ WOLFSSL_CTX * ctx_s = NULL ;
3327+ WOLFSSL * ssl_c = NULL ;
3328+ WOLFSSL * ssl_s = NULL ;
3329+
3330+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
3331+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
3332+ wolfTLSv1_3_client_method , wolfTLSv1_3_server_method ), 0 );
3333+
3334+ /* DeriveTls13Keys with no_key should succeed (skip secret derivation,
3335+ * only derive keys/IVs from existing secrets). This is used with early
3336+ * data to derive keys without re-deriving the secrets. */
3337+ ExpectIntEQ (DeriveTls13Keys (ssl_s , no_key , DECRYPT_SIDE_ONLY , 0 ), 0 );
3338+ ExpectIntEQ (DeriveTls13Keys (ssl_s , no_key , ENCRYPT_SIDE_ONLY , 0 ), 0 );
3339+ ExpectIntEQ (DeriveTls13Keys (ssl_c , no_key , ENCRYPT_AND_DECRYPT_SIDE , 0 ),
3340+ 0 );
3341+
3342+ /* Unknown secret type should return BAD_FUNC_ARG */
3343+ ExpectIntEQ (DeriveTls13Keys (ssl_c , -1 , ENCRYPT_SIDE_ONLY , 0 ),
3344+ WC_NO_ERR_TRACE (BAD_FUNC_ARG ));
3345+
3346+ wolfSSL_free (ssl_c );
3347+ wolfSSL_free (ssl_s );
3348+ wolfSSL_CTX_free (ctx_c );
3349+ wolfSSL_CTX_free (ctx_s );
3350+ #endif
3351+
3352+ return EXPECT_RESULT ();
3353+ }
3354+
0 commit comments