Skip to content

Commit 55ec736

Browse files
committed
TLS Extensions: add more extensions and improve current
Added support for record_size_limit in TLS 1.3 and TLS 1.2. Added compress_certificate support for TLS 1.3. Added signed_certificate_timestamp TLS 1.2 send and TLS 1.2 and 1.3 receive. Accepts server_name in CertificateRequest. Added API for setting signature algorithms for signature_algorithms_cert. Tests added and interop performed where possible.
1 parent ee45da0 commit 55ec736

25 files changed

Lines changed: 5226 additions & 192 deletions

.github/configs/os-check-linux.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
[
2+
{"name": "record-size-limit",
3+
"comment": "RFC 8449 on its own. --enable-all covers it alongside everything else; this is the minimal build, which is where the extension's own guards get exercised.",
4+
"configure": ["--enable-recordsizelimit"]},
5+
{"name": "record-size-limit-tls12",
6+
"comment": "RFC 8449 defines the extension for TLS 1.2 too, where the server answers in the ServerHello. Guards the parse dispatch staying outside the WOLFSSL_TLS13 block.",
7+
"configure": ["--enable-recordsizelimit", "--disable-tls13"]},
8+
{"name": "signed-cert-timestamp",
9+
"comment": "RFC 6962 on its own.",
10+
"configure": ["--enable-sct"]},
11+
{"name": "signed-cert-timestamp-tls12",
12+
"comment": "RFC 6962 is a TLS 1.2 extension that TLS 1.3 relocated, so it must build with TLS 1.3 off. Guards the dispatch case staying outside the WOLFSSL_TLS13 block, and TLSX_SetResponse() staying behind NO_WOLFSSL_SERVER.",
13+
"configure": ["--enable-sct", "--disable-tls13"]},
14+
{"name": "cert-compression",
15+
"comment": "RFC 8879 on its own, with the zlib it requires.",
16+
"configure": ["--enable-certcomp", "--with-libz"]},
17+
{"name": "cert-compression-no-client-auth",
18+
"comment": "Server-only build without client auth: DoTls13CompressedCertificate() calls a static function guarded on exactly this combination, so it is the config that catches the guard drifting.",
19+
"configure": ["--enable-certcomp", "--with-libz",
20+
"CPPFLAGS=-DNO_WOLFSSL_CLIENT -DWOLFSSL_NO_CLIENT_AUTH"]},
221
{"name": "user-settings-all-compat", "minutes": 9.5,
322
"comment": "user_settings_all.h with the compatibility layer enabled by flipping its \"#if 0\" block, as a build-dir copy.",
423
"user_settings": "examples/configs/user_settings_all.h",

.github/workflows/os-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
- name: Install dependencies
102102
uses: ./.github/actions/install-apt-deps
103103
with:
104-
packages: autoconf automake libtool build-essential bubblewrap ccache gcc-multilib
104+
packages: autoconf automake libtool build-essential bubblewrap ccache gcc-multilib zlib1g-dev
105105
ghcr-debs-tag: ubuntu-24.04-minimal
106106

107107
# Ubuntu 24.04 can restrict unprivileged user namespaces via AppArmor,

CMakeLists.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4051,6 +4051,53 @@ if(WOLFSSL_LIBZ)
40514051
list(APPEND WOLFSSL_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
40524052
endif()
40534053

4054+
# Signed certificate timestamp (RFC 6962). Carries a Certificate Transparency
4055+
# SCT list between peers; validating it is left to the application.
4056+
add_option("WOLFSSL_SCT"
4057+
"Enable RFC 6962 signed_certificate_timestamp (default: disabled)"
4058+
"no" "yes;no")
4059+
if(WOLFSSL_SCT)
4060+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_TLS_EXTENSIONS")
4061+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_SIGNED_CERT_TIMESTAMP")
4062+
endif()
4063+
4064+
# Record size limit (RFC 8449). Applies to TLS 1.2 as well as TLS 1.3, where
4065+
# the server answers in the ServerHello rather than EncryptedExtensions, so
4066+
# unlike certificate compression below it imposes no TLS 1.3 requirement.
4067+
add_option("WOLFSSL_RECORDSIZELIMIT"
4068+
"Enable RFC 8449 record_size_limit (default: disabled)"
4069+
"no" "yes;no")
4070+
if(WOLFSSL_RECORDSIZELIMIT)
4071+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_TLS_EXTENSIONS")
4072+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_RECORD_SIZE_LIMIT")
4073+
endif()
4074+
4075+
# Certificate compression (RFC 8879); needs zlib and TLS 1.3
4076+
add_option("WOLFSSL_CERTCOMP"
4077+
"Enable RFC 8879 TLS 1.3 certificate compression (default: disabled)"
4078+
"no" "yes;no")
4079+
if(WOLFSSL_CERTCOMP)
4080+
if(NOT WOLFSSL_LIBZ)
4081+
message(FATAL_ERROR
4082+
"WOLFSSL_CERTCOMP requires WOLFSSL_LIBZ.")
4083+
endif()
4084+
if(NOT WOLFSSL_TLS13)
4085+
message(FATAL_ERROR
4086+
"WOLFSSL_CERTCOMP requires WOLFSSL_TLS13.")
4087+
endif()
4088+
# WOLFSSL_CERTS is not an option in this file; what actually produces
4089+
# -DNO_CERTS is WOLFSSL_ASN=no or WOLFSSL_LEAN_PSK, both resolved well
4090+
# before this point. Testing those is what makes this the configure-time
4091+
# equivalent of configure.ac's ENABLED_CERTS check.
4092+
if(NOT WOLFSSL_ASN OR WOLFSSL_LEAN_PSK)
4093+
message(FATAL_ERROR
4094+
"WOLFSSL_CERTCOMP requires certificate support "
4095+
"(WOLFSSL_ASN=yes, and not WOLFSSL_LEAN_PSK).")
4096+
endif()
4097+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_TLS_EXTENSIONS")
4098+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CERTIFICATE_COMPRESSION")
4099+
endif()
4100+
40544101

40554102
####################################################
40564103
# Maximum key size options (parity with configure.ac)

cmake/options.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ extern "C" {
8787
#cmakedefine HAVE_ALPN
8888
#undef HAVE_ARIA
8989
#cmakedefine HAVE_ARIA
90+
#undef HAVE_CERTIFICATE_COMPRESSION
91+
#cmakedefine HAVE_CERTIFICATE_COMPRESSION
9092
#undef HAVE_CERTIFICATE_STATUS_REQUEST
9193
#cmakedefine HAVE_CERTIFICATE_STATUS_REQUEST
9294
#undef HAVE_CERTIFICATE_STATUS_REQUEST_V2
@@ -159,8 +161,12 @@ extern "C" {
159161
#cmakedefine HAVE_PTHREAD 1
160162
#undef HAVE_REPRODUCIBLE_BUILD
161163
#cmakedefine HAVE_REPRODUCIBLE_BUILD
164+
#undef HAVE_RECORD_SIZE_LIMIT
165+
#cmakedefine HAVE_RECORD_SIZE_LIMIT
162166
#undef HAVE_SESSION_TICKET
163167
#cmakedefine HAVE_SESSION_TICKET
168+
#undef HAVE_SIGNED_CERT_TIMESTAMP
169+
#cmakedefine HAVE_SIGNED_CERT_TIMESTAMP
164170
#undef HAVE_SNI
165171
#cmakedefine HAVE_SNI
166172
#undef HAVE_SUPPORTED_CURVES

configure.ac

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,21 @@ then
14241424
test "$enable_earlydata" = "" && enable_earlydata=yes
14251425
test "$enable_rpk" = "" && enable_rpk=yes
14261426

1427+
test "$enable_sct" = "" && enable_sct=yes
1428+
test "$enable_recordsizelimit" = "" && enable_recordsizelimit=yes
1429+
# Certificate compression needs zlib, and --enable-all deliberately does
1430+
# NOT pull libz in. Doing so gave every --enable-all build a link-time
1431+
# dependency on libz.so and made wolfio.h include zlib.h: that broke the
1432+
# OpenWrt image (no zlib on the target) and the Linux kernel module (no
1433+
# userspace zlib.h), among others. So it joins only when libz was asked
1434+
# for - and even then as an implicit enable, which steps aside with a
1435+
# warning if its other requirements are missing rather than stopping
1436+
# configure.
1437+
if test "$enable_certcomp" = "" && test "$with_libz" = "yes"; then
1438+
enable_certcomp=yes
1439+
certcomp_implicit=yes
1440+
fi
1441+
14271442
if test "$KERNEL_MODE_DEFAULTS" != "yes"
14281443
then
14291444
# Disable QUIC with JNI since incompatible with WOLFSSL_TLS13_MIDDLEBOX_COMPAT
@@ -10726,8 +10741,8 @@ AC_ARG_WITH([libz],
1072610741
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <zlib.h>]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ])
1072710742
1072810743
if test "x$libz_linked" = "xno" ; then
10729-
AC_MSG_ERROR([libz isn't found.
10730-
If it's already installed, specify its path using --with-libz=/dir/])
10744+
AC_MSG_ERROR([libz isn't found. If it's already
10745+
installed, specify its path using --with-libz=/dir/])
1073110746
fi
1073210747
AC_MSG_RESULT([yes])
1073310748
else
@@ -10737,6 +10752,67 @@ AC_ARG_WITH([libz],
1073710752
]
1073810753
)
1073910754
10755+
# Signed Certificate Timestamp (RFC 6962)
10756+
AC_ARG_ENABLE([sct],
10757+
[AS_HELP_STRING([--enable-sct],[Enable RFC 6962 signed_certificate_timestamp. Carries a Certificate Transparency SCT list between peers; validating it is left to the application (default: disabled)])],
10758+
[ ENABLED_SCT=$enableval ],
10759+
[ ENABLED_SCT=no ]
10760+
)
10761+
if test "$ENABLED_SCT" = "yes"
10762+
then
10763+
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SIGNED_CERT_TIMESTAMP"
10764+
fi
10765+
10766+
# Record Size Limit (RFC 8449)
10767+
AC_ARG_ENABLE([recordsizelimit],
10768+
[AS_HELP_STRING([--enable-recordsizelimit],[Enable RFC 8449 record_size_limit, the byte-exact replacement for max_fragment_length. Applies to TLS 1.2 and TLS 1.3 (default: disabled)])],
10769+
[ ENABLED_RECORD_SIZE_LIMIT=$enableval ],
10770+
[ ENABLED_RECORD_SIZE_LIMIT=no ]
10771+
)
10772+
dnl RFC 8449 defines the extension for TLS 1.2 as well as TLS 1.3, where the
10773+
dnl server answers in the ServerHello rather than EncryptedExtensions, so no
10774+
dnl TLS 1.3 dependency is imposed here.
10775+
if test "$ENABLED_RECORD_SIZE_LIMIT" = "yes"
10776+
then
10777+
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_RECORD_SIZE_LIMIT"
10778+
fi
10779+
10780+
# Certificate Compression (RFC 8879)
10781+
AC_ARG_ENABLE([certcomp],
10782+
[AS_HELP_STRING([--enable-certcomp],[Enable RFC 8879 TLS 1.3 certificate compression. Accepts a CompressedCertificate from the peer, and sends one when the certificate has been compressed with wolfSSL_CTX_compress_certs(). Needs --with-libz (default: disabled)])],
10783+
[ ENABLED_CERTCOMP=$enableval ],
10784+
[ ENABLED_CERTCOMP=no ]
10785+
)
10786+
if test "$ENABLED_CERTCOMP" = "yes"
10787+
then
10788+
certcomp_missing=""
10789+
if test "x$ENABLED_TLS13" = "xno"
10790+
then
10791+
certcomp_missing="TLS 1.3"
10792+
fi
10793+
if test "x$ENABLED_LIBZ" = "xno"
10794+
then
10795+
certcomp_missing="libz"
10796+
fi
10797+
if test "x$certcomp_missing" != "x"
10798+
then
10799+
if test "x$certcomp_implicit" = "xyes"
10800+
then
10801+
dnl Switched on by --enable-all rather than asked for, so its
10802+
dnl requirements are not the user's to satisfy.
10803+
AC_MSG_WARN([certificate compression needs $certcomp_missing;
10804+
turning it off])
10805+
ENABLED_CERTCOMP=no
10806+
else
10807+
AC_MSG_ERROR([Certificate compression requires $certcomp_missing.])
10808+
fi
10809+
fi
10810+
fi
10811+
if test "$ENABLED_CERTCOMP" = "yes"
10812+
then
10813+
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_CERTIFICATE_COMPRESSION"
10814+
fi
10815+
1074010816
1074110817
# PKCS#11
1074210818
AC_ARG_ENABLE([pkcs11],
@@ -12578,6 +12654,18 @@ AS_IF([test "x$ENABLED_MAXSTRENGTH" = "xyes" && \
1257812654
test "x$ENABLED_LEANPSK" = "xyes"],
1257912655
[AC_MSG_ERROR([Cannot use Max Strength and Lean PSK at the same time.])])
1258012656
12657+
dnl Certificate compression carries a Certificate message, so it needs
12658+
dnl certificates. Checked here, not beside the option: ENABLED_CERTS is still
12659+
dnl being assigned well past that point.
12660+
AS_IF([test "x$ENABLED_CERTCOMP" = "xyes" && test "x$ENABLED_CERTS" = "xno"],
12661+
[AS_IF([test "x$certcomp_implicit" = "xyes"],
12662+
[AC_MSG_WARN([certificate compression needs certificates;
12663+
turning it off])
12664+
ENABLED_CERTCOMP=no
12665+
AM_CFLAGS=`echo "$AM_CFLAGS" | \
12666+
sed 's/ -DHAVE_CERTIFICATE_COMPRESSION//'`],
12667+
[AC_MSG_ERROR([Certificate compression requires certificates.])])])
12668+
1258112669
AS_IF([test "x$ENABLED_CRYPTONLY" = "xno" && \
1258212670
test "x$ENABLED_PSK" = "xno" && \
1258312671
test "x$ENABLED_ASN" = "xno"],
@@ -14056,6 +14144,9 @@ echo " * Whitewood netRandom: $ENABLED_WNR"
1405614144
echo " * Server Name Indication: $ENABLED_SNI"
1405714145
echo " * ALPN: $ENABLED_ALPN"
1405814146
echo " * Maximum Fragment Length: $ENABLED_MAX_FRAGMENT"
14147+
echo " * Record Size Limit: $ENABLED_RECORD_SIZE_LIMIT"
14148+
echo " * Certificate Compression: $ENABLED_CERTCOMP"
14149+
echo " * Signed Cert Timestamps: $ENABLED_SCT"
1405914150
echo " * Trusted CA Indication: $ENABLED_TRUSTED_CA"
1406014151
echo " * Truncated HMAC: $ENABLED_TRUNCATED_HMAC"
1406114152
echo " * Supported Elliptic Curves: $ENABLED_SUPPORTED_CURVES"

0 commit comments

Comments
 (0)