Skip to content

Commit fbd8996

Browse files
committed
Add API to choose dynamic certs based on client ciphers/sigalgs
1 parent 12ee732 commit fbd8996

6 files changed

Lines changed: 265 additions & 51 deletions

File tree

src/internal.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35403,6 +35403,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3540335403
#endif
3540435404

3540535405
#ifdef OPENSSL_EXTRA
35406+
ssl->clSuites = clSuites;
3540635407
/* Give user last chance to provide a cert for cipher selection */
3540735408
if (ret == 0 && ssl->ctx->certSetupCb != NULL)
3540835409
ret = CertSetupCbWrapper(ssl);
@@ -35426,7 +35427,9 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3542635427
#endif
3542735428

3542835429
out:
35429-
35430+
#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
35431+
ssl->clSuites = NULL;
35432+
#endif
3543035433
#ifdef WOLFSSL_SMALL_STACK
3543135434
if (clSuites != NULL)
3543235435
XFREE(clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);

src/ssl.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16296,6 +16296,33 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1629616296
ctx->certSetupCbArg = arg;
1629716297
}
1629816298

16299+
void wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
16300+
const byte** suites, word16* suiteSz,
16301+
const byte** hashSigAlgo, word16* hashSigAlgoSz)
16302+
{
16303+
WOLFSSL_ENTER("wolfSSL_get_client_suites_sigalgs");
16304+
16305+
if (suites != NULL)
16306+
*suites = NULL;
16307+
if (suiteSz != NULL)
16308+
*suiteSz = 0;
16309+
if (hashSigAlgo != NULL)
16310+
*hashSigAlgo = NULL;
16311+
if (hashSigAlgoSz != NULL)
16312+
*hashSigAlgoSz = 0;
16313+
16314+
if (ssl != NULL && ssl->clSuites != NULL) {
16315+
if (suites != NULL && suiteSz != NULL) {
16316+
*suites = ssl->clSuites->suites;
16317+
*suiteSz = ssl->clSuites->suiteSz;
16318+
}
16319+
if (hashSigAlgo != NULL && hashSigAlgoSz != NULL) {
16320+
*hashSigAlgo = ssl->clSuites->hashSigAlgo;
16321+
*hashSigAlgoSz = ssl->clSuites->hashSigAlgoSz;
16322+
}
16323+
}
16324+
}
16325+
1629916326
/**
1630016327
* Internal wrapper for calling certSetupCb
1630116328
* @param ssl The SSL/TLS Object

src/tls13.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5617,6 +5617,11 @@ static int DoTls13CertificateRequest(WOLFSSL* ssl, const byte* input,
56175617
if (ssl->toInfoOn) AddLateName("CertificateRequest", &ssl->timeoutInfo);
56185618
#endif
56195619

5620+
#ifdef OPENSSL_EXTRA
5621+
if ((ret = CertSetupCbWrapper(ssl)) != 0)
5622+
return ret;
5623+
#endif
5624+
56205625
if (OPAQUE8_LEN > size)
56215626
return BUFFER_ERROR;
56225627

@@ -6594,6 +6599,9 @@ static void FreeDch13Args(WOLFSSL* ssl, void* pArgs)
65946599
XFREE(args->clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);
65956600
args->clSuites = NULL;
65966601
}
6602+
#ifdef OPENSSL_EXTRA
6603+
ssl->clSuites = NULL;
6604+
#endif
65976605
}
65986606

65996607
int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
@@ -6978,6 +6986,11 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
69786986

69796987
case TLS_ASYNC_DO:
69806988
{
6989+
#ifdef OPENSSL_EXTRA
6990+
ssl->clSuites = args->clSuites;
6991+
if ((ret = CertSetupCbWrapper(ssl)) != 0)
6992+
goto exit_dch;
6993+
#endif
69816994
#ifndef NO_CERTS
69826995
if (!args->usingPSK) {
69836996
if ((ret = MatchSuite(ssl, args->clSuites)) < 0) {
@@ -8244,11 +8257,6 @@ static int SendTls13Certificate(WOLFSSL* ssl)
82448257
listSz = 0;
82458258
}
82468259
else {
8247-
#ifdef OPENSSL_EXTRA
8248-
if ((ret = CertSetupCbWrapper(ssl)) != 0)
8249-
return ret;
8250-
#endif
8251-
82528260
if (!ssl->buffers.certificate) {
82538261
WOLFSSL_MSG("Send Cert missing certificate buffer");
82548262
return BUFFER_ERROR;

0 commit comments

Comments
 (0)