Skip to content

Commit b73e5bf

Browse files
committed
TLS 1.2 CertificateVerify: req sig alg to have been in CR
The signature algorithm specified in CertificateVerify must have been in the CertificateRequest. Add check. The cipher suite test cases, when client auth and RSA are built-in and use the default client certificate and use the *-ECDSA-* cipher suites, no longer work. The client certificate must be ECC when the cipher suite has ECDSA. Don't run them for that build.
1 parent 58bd6a8 commit b73e5bf

File tree

2 files changed

+67
-24
lines changed

2 files changed

+67
-24
lines changed

src/internal.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38568,10 +38568,19 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3856838568
case TLS_ASYNC_BUILD:
3856938569
{
3857038570
if (IsAtLeastTLSv1_2(ssl)) {
38571-
if ((args->idx - args->begin) + ENUM_LEN + ENUM_LEN > size) {
38571+
if ((args->idx - args->begin) + ENUM_LEN + ENUM_LEN >
38572+
size) {
3857238573
ERROR_OUT(BUFFER_ERROR, exit_dcv);
3857338574
}
3857438575

38576+
/* Check if hashSigAlgo in CertificateVerify is supported
38577+
* in our ssl->suites or ssl->ctx->suites. */
38578+
if (!SupportedHashSigAlgo(ssl, &input[args->idx])) {
38579+
WOLFSSL_MSG("Signature algorithm was not in "
38580+
"CertificateRequest");
38581+
ERROR_OUT(INVALID_PARAMETER, exit_dcv);
38582+
}
38583+
3857538584
DecodeSigAlg(&input[args->idx], &ssl->options.peerHashAlgo,
3857638585
&ssl->options.peerSigAlgo);
3857738586
args->idx += 2;

tests/suites.c

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,20 @@ static int IsNoClientCert(const char* line)
358358
}
359359
#endif
360360

361+
#if (defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448)) && \
362+
!defined(NO_RSA) && !defined(NO_CERTS) && !defined(WOLFSSL_NO_CLIENT_AUTH)
363+
static int IsEcdsaCipherSuiteDefRsaCert(const char* line)
364+
{
365+
int found;
366+
367+
found = (strstr(line, "-ECDSA-") != NULL);
368+
found &= (strstr(line, "-c ") == NULL);
369+
found &= (strstr(line, "-x") == NULL);
370+
371+
return found;
372+
}
373+
#endif
374+
361375
static int execute_test_case(int svr_argc, char** svr_argv,
362376
int cli_argc, char** cli_argv,
363377
int addNoVerify, int addNonBlocking,
@@ -529,6 +543,49 @@ static int execute_test_case(int svr_argc, char** svr_argv,
529543
svrTestShouldFail = 1;
530544
}
531545

546+
547+
commandLine[0] = '\0';
548+
added = 0;
549+
for (i = 0; i < cliArgs.argc; i++) {
550+
added += XSTRLEN(cli_argv[i]) + 2;
551+
if (added >= MAX_COMMAND_SZ) {
552+
printf("client command line too long\n");
553+
break;
554+
}
555+
XSTRLCAT(commandLine, cli_argv[i], sizeof commandLine);
556+
XSTRLCAT(commandLine, flagSep, sizeof commandLine);
557+
}
558+
if (!IsValidCA(commandLine)) {
559+
#ifdef DEBUG_SUITE_TESTS
560+
printf("certificate %s not supported in build\n", commandLine);
561+
#endif
562+
return NOT_BUILT_IN;
563+
}
564+
#ifdef WOLFSSL_NO_CLIENT_AUTH
565+
if (reqClientCert && IsNoClientCert(commandLine)) {
566+
#ifdef DEBUG_SUITE_TESTS
567+
printf("client auth on line %s not supported in build\n",
568+
commandLine);
569+
#endif
570+
return NOT_BUILT_IN;
571+
}
572+
#endif
573+
#ifdef NO_CERTS
574+
if (IsNoClientCert(commandLine)) {
575+
#ifdef DEBUG_SUITE_TESTS
576+
printf("certificate %s not supported in build\n", commandLine);
577+
#endif
578+
return NOT_BUILT_IN;
579+
}
580+
#endif
581+
#if (defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448)) && \
582+
!defined(NO_RSA) && !defined(NO_CERTS) && !defined(WOLFSSL_NO_CLIENT_AUTH)
583+
if (IsEcdsaCipherSuiteDefRsaCert(commandLine)) {
584+
return NOT_BUILT_IN;
585+
}
586+
#endif
587+
588+
532589
InitTcpReady(&ready);
533590

534591
#if defined(WOLFSSL_SRTP) && defined(WOLFSSL_COND)
@@ -596,29 +653,6 @@ static int execute_test_case(int svr_argc, char** svr_argv,
596653
XSTRLCAT(commandLine, cli_argv[i], sizeof commandLine);
597654
XSTRLCAT(commandLine, flagSep, sizeof commandLine);
598655
}
599-
if (!IsValidCA(commandLine)) {
600-
#ifdef DEBUG_SUITE_TESTS
601-
printf("certificate %s not supported in build\n", commandLine);
602-
#endif
603-
return NOT_BUILT_IN;
604-
}
605-
#ifdef WOLFSSL_NO_CLIENT_AUTH
606-
if (reqClientCert && IsNoClientCert(commandLine)) {
607-
#ifdef DEBUG_SUITE_TESTS
608-
printf("client auth on line %s not supported in build\n",
609-
commandLine);
610-
#endif
611-
return NOT_BUILT_IN;
612-
}
613-
#endif
614-
#ifdef NO_CERTS
615-
if (IsNoClientCert(commandLine)) {
616-
#ifdef DEBUG_SUITE_TESTS
617-
printf("certificate %s not supported in build\n", commandLine);
618-
#endif
619-
return NOT_BUILT_IN;
620-
}
621-
#endif
622656
printf("trying client command line[%d]: %s\n", tests, commandLine);
623657
tests++;
624658

0 commit comments

Comments
 (0)