@@ -2909,3 +2909,45 @@ int test_dtls13_oversized_cert_chain(void)
29092909#endif
29102910 return EXPECT_RESULT ();
29112911}
2912+
2913+ /* DTLS counterpart to test_tls_set_session_min_downgrade. Exercises the
2914+ * inverted DTLS minor-version comparison (DTLS 1.2 minor 0xFD is "below"
2915+ * floor 0xFC = DTLS 1.3). */
2916+ int test_dtls_set_session_min_downgrade (void )
2917+ {
2918+ EXPECT_DECLS ;
2919+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES ) && defined(WOLFSSL_DTLS ) && \
2920+ defined(WOLFSSL_DTLS13 ) && defined(HAVE_SESSION_TICKET )
2921+ WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
2922+ WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
2923+ WOLFSSL_SESSION * sess = NULL ;
2924+ struct test_memio_ctx test_ctx ;
2925+
2926+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
2927+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
2928+ wolfDTLSv1_2_client_method , wolfDTLSv1_2_server_method ), 0 );
2929+ ExpectIntEQ (test_memio_do_handshake (ssl_c , ssl_s , 10 , NULL ), 0 );
2930+ ExpectNotNull (sess = wolfSSL_get1_session (ssl_c ));
2931+
2932+ wolfSSL_free (ssl_c ); ssl_c = NULL ;
2933+ wolfSSL_free (ssl_s ); ssl_s = NULL ;
2934+ wolfSSL_CTX_free (ctx_c ); ctx_c = NULL ;
2935+ wolfSSL_CTX_free (ctx_s ); ctx_s = NULL ;
2936+
2937+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
2938+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
2939+ wolfDTLS_client_method , wolfDTLS_server_method ), 0 );
2940+ ExpectIntEQ (wolfSSL_SetMinVersion (ssl_c , WOLFSSL_DTLSV1_3 ),
2941+ WOLFSSL_SUCCESS );
2942+ ExpectIntEQ (wolfSSL_set_session (ssl_c , sess ), WOLFSSL_FAILURE );
2943+ if (ssl_c != NULL )
2944+ ExpectIntEQ (ssl_c -> options .resuming , 0 );
2945+
2946+ wolfSSL_SESSION_free (sess );
2947+ wolfSSL_free (ssl_c );
2948+ wolfSSL_free (ssl_s );
2949+ wolfSSL_CTX_free (ctx_c );
2950+ wolfSSL_CTX_free (ctx_s );
2951+ #endif
2952+ return EXPECT_RESULT ();
2953+ }
0 commit comments