Skip to content

Commit 9be3902

Browse files
authored
Adding support for dual key/signature certificates. (#7112)
Adding support for dual key/signature certificates with X9.146. Enabled with `--enable-dual-alg-certs` or `WOLFSSL_DUAL_ALG_CERTS`.
1 parent 8a45f43 commit 9be3902

19 files changed

Lines changed: 2262 additions & 125 deletions

File tree

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8097,6 +8097,12 @@ AC_ARG_ENABLE([sys-ca-certs],
80978097
[ ENABLED_SYS_CA_CERTS=yes ]
80988098
)
80998099

8100+
AC_ARG_ENABLE([dual-alg-certs],
8101+
[AS_HELP_STRING([--enable-dual-alg-certs],[Enable support for dual key/signature certificates in TLS 1.3 as defined in X9.146 (default: disabled)])],
8102+
[ ENABLED_DUAL_ALG_CERTS=$enableval ],
8103+
[ ENABLED_DUAL_ALG_CERTS=no ]
8104+
)
8105+
81008106
# check if should run the trusted peer certs test
81018107
# (for now checking both C_FLAGS and C_EXTRA_FLAGS)
81028108
AS_CASE(["$CFLAGS $CPPFLAGS"],[*'WOLFSSL_TRUST_PEER_CERT'*],[ENABLED_TRUSTED_PEER_CERT=yes])
@@ -8462,6 +8468,9 @@ AS_IF([test "x$ENABLED_ASN" = "xno"],
84628468
AS_IF([test "x$ENABLED_SYS_CA_CERTS" = "xyes"],
84638469
[AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SYS_CA_CERTS"])
84648470

8471+
AS_IF([test "x$ENABLED_DUAL_ALG_CERTS" = "xyes"],
8472+
[AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DUAL_ALG_CERTS"])
8473+
84658474
AS_IF([test "x$ENABLED_ALTNAMES" = "xyes"],
84668475
[AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ALT_NAMES"])
84678476

@@ -9579,6 +9588,7 @@ echo " * NXP SE050: $ENABLED_SE050"
95799588
echo " * Maxim Integrated MAXQ10XX: $ENABLED_MAXQ10XX"
95809589
echo " * PSA: $ENABLED_PSA"
95819590
echo " * System CA certs: $ENABLED_SYS_CA_CERTS"
9591+
echo " * Dual alg cert support: $ENABLED_DUAL_ALG_CERTS"
95829592
echo " * ERR Queues per Thread: $ENABLED_ERRORQUEUEPERTHREAD"
95839593
echo " * rwlock: $ENABLED_RWLOCK"
95849594
echo " * keylog export: $ENABLED_KEYLOG_EXPORT"

examples/client/client.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,24 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
35583558
err_sys("unable to get SSL object");
35593559
}
35603560

3561+
#ifdef WOLFSSL_DUAL_ALG_CERTS
3562+
/* Set our preference for verfication to be for both the native and
3563+
* alternative chains. Ultimately, its the server's choice.
3564+
*/
3565+
{
3566+
byte cks_order[3] = {
3567+
WOLFSSL_CKS_SIGSPEC_BOTH,
3568+
WOLFSSL_CKS_SIGSPEC_ALTERNATIVE,
3569+
WOLFSSL_CKS_SIGSPEC_NATIVE,
3570+
};
3571+
3572+
if (!wolfSSL_UseCKS(ssl, cks_order, sizeof(cks_order))) {
3573+
wolfSSL_CTX_free(ctx); ctx = NULL;
3574+
err_sys("unable to set the CKS order.");
3575+
}
3576+
}
3577+
#endif /* WOLFSSL_DUAL_ALG_CERTS */
3578+
35613579
#ifndef NO_PSK
35623580
if (usePsk) {
35633581
#if defined(OPENSSL_EXTRA) && defined(WOLFSSL_TLS13) && defined(TEST_PSK_USE_SESSION)

examples/server/server.c

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,11 +969,15 @@ static const char* server_usage_msg[][65] = {
969969
#endif
970970
#ifdef HAVE_SUPPORTED_CURVES
971971
"--onlyPskDheKe Must use DHE key exchange with PSK\n", /* 64 */
972+
#endif
973+
#ifdef WOLFSSL_DUAL_ALG_CERTS
974+
"--altPrivKey <file> Generate alternative signature with this key.\n",
975+
/* 65 */
972976
#endif
973977
"\n"
974978
"For simpler wolfSSL TLS server examples, visit\n"
975979
"https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n",
976-
/* 65 */
980+
/* 66 */
977981
NULL,
978982
},
979983
#ifndef NO_MULTIBYTE_PRINT
@@ -1159,11 +1163,16 @@ static const char* server_usage_msg[][65] = {
11591163
#endif
11601164
#ifdef HAVE_SUPPORTED_CURVES
11611165
"--onlyPskDheKe Must use DHE key exchange with PSK\n", /* 64 */
1166+
#endif
1167+
#ifdef WOLFSSL_DUAL_ALG_CERTS
1168+
"--altPrivKey <file> Generate alternative signature with this key.\n",
1169+
/* 65 */
11621170
#endif
11631171
"\n"
11641172
"より簡単なwolfSSL TSL クライアントの例については"
11651173
"下記にアクセスしてください\n"
1166-
"https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 65 */
1174+
"https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n",
1175+
/* 66 */
11671176
NULL,
11681177
},
11691178
#endif
@@ -1320,7 +1329,10 @@ static void Usage(void)
13201329
#ifdef HAVE_SUPPORTED_CURVES
13211330
printf("%s", msg[++msgId]); /* --onlyPskDheKe */
13221331
#endif
1323-
printf("%s", msg[++msgId]); /* Examples repo link */
1332+
#ifdef WOLFSSL_DUAL_ALG_CERTS
1333+
printf("%s", msg[++msgId]); /* --altPrivKey */
1334+
#endif
1335+
printf("%s", msg[++msgId]); /* Examples repo link */
13241336
}
13251337

13261338
#ifdef WOLFSSL_SRTP
@@ -1436,6 +1448,9 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
14361448
{"crl-dir", 1, 265},
14371449
#endif
14381450
{"quieter", 0, 266},
1451+
#ifdef WOLFSSL_DUAL_ALG_CERTS
1452+
{ "altPrivKey", 1, 267},
1453+
#endif
14391454
{ 0, 0, 0 }
14401455
};
14411456
#endif
@@ -1600,6 +1615,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
16001615
int useX448 = 0;
16011616
int usePqc = 0;
16021617
char* pqcAlg = NULL;
1618+
char* altPrivKey = NULL;
16031619
int exitWithRet = 0;
16041620
int loadCertKeyIntoSSLObj = 0;
16051621

@@ -1674,6 +1690,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
16741690
(void)nonBlocking;
16751691
(void)pqcAlg;
16761692
(void)usePqc;
1693+
(void)altPrivKey;
16771694

16781695
#ifdef WOLFSSL_TIRTOS
16791696
fdOpenSession(Task_self());
@@ -2320,6 +2337,12 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
23202337
quieter = 1;
23212338
break;
23222339

2340+
#ifdef WOLFSSL_DUAL_ALG_CERTS
2341+
case 267:
2342+
altPrivKey = myoptarg;
2343+
break;
2344+
#endif
2345+
23232346
case -1:
23242347
default:
23252348
Usage();
@@ -2697,6 +2720,14 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
26972720
!= WOLFSSL_SUCCESS)
26982721
err_sys_ex(catastrophic, "can't load server private key file, "
26992722
"check file and run from wolfSSL home dir");
2723+
#ifdef WOLFSSL_DUAL_ALG_CERTS
2724+
if ((altPrivKey != NULL) &&
2725+
wolfSSL_CTX_use_AltPrivateKey_file(ctx, altPrivKey,
2726+
WOLFSSL_FILETYPE_PEM)
2727+
!= WOLFSSL_SUCCESS)
2728+
err_sys_ex(catastrophic, "can't load alt private key file, "
2729+
"check file and run from wolfSSL home dir");
2730+
#endif /* WOLFSSL_DUAL_ALG_CERTS */
27002731
#else
27012732
/* loads private key file using buffer API */
27022733
load_buffer(ctx, ourKey, WOLFSSL_KEY);

0 commit comments

Comments
 (0)