@@ -64893,6 +64893,90 @@ static int test_dtls_client_hello_timeout(void)
6489364893 return EXPECT_RESULT();
6489464894}
6489564895
64896+ /**
64897+ * Make sure we don't send RSA Signature Hash Algorithms in the
64898+ * CertificateRequest when we don't have any such ciphers set.
64899+ * @return EXPECT_RESULT()
64900+ */
64901+ static int test_certreq_sighash_algos(void)
64902+ {
64903+ EXPECT_DECLS;
64904+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES)
64905+ WOLFSSL_CTX *ctx_c = NULL;
64906+ WOLFSSL_CTX *ctx_s = NULL;
64907+ WOLFSSL *ssl_c = NULL;
64908+ WOLFSSL *ssl_s = NULL;
64909+ struct test_memio_ctx test_ctx;
64910+ int idx = 0;
64911+ int maxIdx = 0;
64912+
64913+ XMEMSET(&test_ctx, 0, sizeof(test_ctx));
64914+ test_ctx.c_ciphers = test_ctx.s_ciphers = "TLS_ECDHE_ECDSA_WITH_NULL_SHA:"
64915+ "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384";
64916+ ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
64917+ wolfTLSv1_2_client_method, wolfTLSv1_2_server_method), 0);
64918+
64919+ ExpectIntEQ(wolfSSL_CTX_load_verify_locations(ctx_c,
64920+ "./certs/ca-ecc-cert.pem", NULL), WOLFSSL_SUCCESS);
64921+
64922+ wolfSSL_set_verify(ssl_s, SSL_VERIFY_PEER, NULL);
64923+ ExpectIntEQ(wolfSSL_use_PrivateKey_file(ssl_s, "./certs/ecc-key.pem",
64924+ WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS);
64925+ ExpectIntEQ(wolfSSL_use_certificate_file(ssl_s, "./certs/server-ecc.pem",
64926+ WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS);
64927+
64928+ ExpectIntEQ(wolfSSL_connect(ssl_c), WOLFSSL_FATAL_ERROR);
64929+ ExpectIntEQ(wolfSSL_get_error(ssl_c, WOLFSSL_FATAL_ERROR),
64930+ WOLFSSL_ERROR_WANT_READ);
64931+
64932+ ExpectIntEQ(wolfSSL_accept(ssl_s), WOLFSSL_FATAL_ERROR);
64933+ ExpectIntEQ(wolfSSL_get_error(ssl_s, WOLFSSL_FATAL_ERROR),
64934+ WOLFSSL_ERROR_WANT_READ);
64935+
64936+ /* Find the CertificateRequest message */
64937+ for (idx = 0; idx < test_ctx.c_len && EXPECT_SUCCESS();) {
64938+ word16 len;
64939+ ExpectIntEQ(test_ctx.c_buff[idx++], handshake);
64940+ ExpectIntEQ(test_ctx.c_buff[idx++], SSLv3_MAJOR);
64941+ ExpectIntEQ(test_ctx.c_buff[idx++], TLSv1_2_MINOR);
64942+ ato16(test_ctx.c_buff + idx, &len);
64943+ idx += OPAQUE16_LEN;
64944+ if (test_ctx.c_buff[idx] == certificate_request) {
64945+ idx++;
64946+ /* length */
64947+ idx += OPAQUE24_LEN;
64948+ /* cert types */
64949+ idx += 1 + test_ctx.c_buff[idx];
64950+ /* Sig algos */
64951+ ato16(test_ctx.c_buff + idx, &len);
64952+ idx += OPAQUE16_LEN;
64953+ maxIdx = idx + (int)len;
64954+ for (; idx < maxIdx && EXPECT_SUCCESS(); idx += OPAQUE16_LEN) {
64955+ if (test_ctx.c_buff[idx+1] == ED25519_SA_MINOR ||
64956+ test_ctx.c_buff[idx+1] == ED448_SA_MINOR)
64957+ ExpectIntEQ(test_ctx.c_buff[idx], NEW_SA_MAJOR);
64958+ else
64959+ ExpectIntEQ(test_ctx.c_buff[idx+1], ecc_dsa_sa_algo);
64960+ }
64961+ break;
64962+ }
64963+ else {
64964+ idx += (int)len;
64965+ }
64966+ }
64967+ ExpectIntLT(idx, test_ctx.c_len);
64968+
64969+
64970+ ExpectIntEQ(test_memio_do_handshake(ssl_c, ssl_s, 10, NULL), 0);
64971+
64972+ wolfSSL_free(ssl_c);
64973+ wolfSSL_free(ssl_s);
64974+ wolfSSL_CTX_free(ctx_c);
64975+ wolfSSL_CTX_free(ctx_s);
64976+ #endif
64977+ return EXPECT_RESULT();
64978+ }
64979+
6489664980/*----------------------------------------------------------------------------*
6489764981 | Main
6489864982 *----------------------------------------------------------------------------*/
@@ -66155,6 +66239,7 @@ TEST_CASE testCases[] = {
6615566239 TEST_DECL(test_dtls_downgrade_scr),
6615666240 TEST_DECL(test_dtls_client_hello_timeout_downgrade),
6615766241 TEST_DECL(test_dtls_client_hello_timeout),
66242+ TEST_DECL(test_certreq_sighash_algos),
6615866243 /* This test needs to stay at the end to clean up any caches allocated. */
6615966244 TEST_DECL(test_wolfSSL_Cleanup)
6616066245};
0 commit comments