Skip to content

Commit a10491c

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 and 1.3. Added handshake-message fragmentation to EncryptedExtension, CertificateRequest and NewSessionTicket. Accepts server_name in CertificateRequest. Added API for setting signature algorithms for signature_algorithms_cert. SHA-1 certificate chain fix: a peer advertising ecdsa_sha1 against a chain with an RSA-SHA1 intermediates will see a failed handshake. Tests added and interop performed where possible.
1 parent a3fa44d commit a10491c

28 files changed

Lines changed: 5858 additions & 275 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
@@ -4083,6 +4083,53 @@ if(WOLFSSL_LIBZ)
40834083
list(APPEND WOLFSSL_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
40844084
endif()
40854085

4086+
# Signed certificate timestamp (RFC 6962). Carries a Certificate Transparency
4087+
# SCT list between peers; validating it is left to the application.
4088+
add_option("WOLFSSL_SCT"
4089+
"Enable RFC 6962 signed_certificate_timestamp (default: disabled)"
4090+
"no" "yes;no")
4091+
if(WOLFSSL_SCT)
4092+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_TLS_EXTENSIONS")
4093+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_SIGNED_CERT_TIMESTAMP")
4094+
endif()
4095+
4096+
# Record size limit (RFC 8449). Applies to TLS 1.2 as well as TLS 1.3, where
4097+
# the server answers in the ServerHello rather than EncryptedExtensions, so
4098+
# unlike certificate compression below it imposes no TLS 1.3 requirement.
4099+
add_option("WOLFSSL_RECORDSIZELIMIT"
4100+
"Enable RFC 8449 record_size_limit, for TLS 1.2 and TLS 1.3 (default: disabled)"
4101+
"no" "yes;no")
4102+
if(WOLFSSL_RECORDSIZELIMIT)
4103+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_TLS_EXTENSIONS")
4104+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_RECORD_SIZE_LIMIT")
4105+
endif()
4106+
4107+
# Certificate compression (RFC 8879); needs zlib and TLS 1.3
4108+
add_option("WOLFSSL_CERTCOMP"
4109+
"Enable RFC 8879 TLS 1.3 certificate compression (default: disabled)"
4110+
"no" "yes;no")
4111+
if(WOLFSSL_CERTCOMP)
4112+
if(NOT WOLFSSL_LIBZ)
4113+
message(FATAL_ERROR
4114+
"WOLFSSL_CERTCOMP requires WOLFSSL_LIBZ.")
4115+
endif()
4116+
if(NOT WOLFSSL_TLS13)
4117+
message(FATAL_ERROR
4118+
"WOLFSSL_CERTCOMP requires WOLFSSL_TLS13.")
4119+
endif()
4120+
# WOLFSSL_CERTS is not an option in this file; what actually produces
4121+
# -DNO_CERTS is WOLFSSL_ASN=no or WOLFSSL_LEAN_PSK, both resolved well
4122+
# before this point. Testing those is what makes this the configure-time
4123+
# equivalent of configure.ac's ENABLED_CERTS check.
4124+
if(NOT WOLFSSL_ASN OR WOLFSSL_LEAN_PSK)
4125+
message(FATAL_ERROR
4126+
"WOLFSSL_CERTCOMP requires certificate support "
4127+
"(WOLFSSL_ASN=yes, and not WOLFSSL_LEAN_PSK).")
4128+
endif()
4129+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_TLS_EXTENSIONS")
4130+
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CERTIFICATE_COMPRESSION")
4131+
endif()
4132+
40864133

40874134
####################################################
40884135
# 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
@@ -1427,6 +1427,21 @@ then
14271427
test "$enable_earlydata" = "" && enable_earlydata=yes
14281428
test "$enable_rpk" = "" && enable_rpk=yes
14291429

1430+
test "$enable_sct" = "" && enable_sct=yes
1431+
test "$enable_recordsizelimit" = "" && enable_recordsizelimit=yes
1432+
# Certificate compression needs zlib, and --enable-all deliberately does
1433+
# NOT pull libz in. Doing so gave every --enable-all build a link-time
1434+
# dependency on libz.so and made wolfio.h include zlib.h: that broke the
1435+
# OpenWrt image (no zlib on the target) and the Linux kernel module (no
1436+
# userspace zlib.h), among others. So it joins only when libz was asked
1437+
# for - and even then as an implicit enable, which steps aside with a
1438+
# warning if its other requirements are missing rather than stopping
1439+
# configure.
1440+
if test "$enable_certcomp" = "" && test "$with_libz" = "yes"; then
1441+
enable_certcomp=yes
1442+
certcomp_implicit=yes
1443+
fi
1444+
14301445
if test "$KERNEL_MODE_DEFAULTS" != "yes"
14311446
then
14321447
# Disable QUIC with JNI since incompatible with WOLFSSL_TLS13_MIDDLEBOX_COMPAT
@@ -10787,8 +10802,8 @@ AC_ARG_WITH([libz],
1078710802
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <zlib.h>]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ])
1078810803
1078910804
if test "x$libz_linked" = "xno" ; then
10790-
AC_MSG_ERROR([libz isn't found.
10791-
If it's already installed, specify its path using --with-libz=/dir/])
10805+
AC_MSG_ERROR([libz isn't found. If it's already
10806+
installed, specify its path using --with-libz=/dir/])
1079210807
fi
1079310808
AC_MSG_RESULT([yes])
1079410809
else
@@ -10798,6 +10813,67 @@ AC_ARG_WITH([libz],
1079810813
]
1079910814
)
1080010815
10816+
# Signed Certificate Timestamp (RFC 6962)
10817+
AC_ARG_ENABLE([sct],
10818+
[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)])],
10819+
[ ENABLED_SCT=$enableval ],
10820+
[ ENABLED_SCT=no ]
10821+
)
10822+
if test "$ENABLED_SCT" = "yes"
10823+
then
10824+
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SIGNED_CERT_TIMESTAMP"
10825+
fi
10826+
10827+
# Record Size Limit (RFC 8449)
10828+
AC_ARG_ENABLE([recordsizelimit],
10829+
[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)])],
10830+
[ ENABLED_RECORD_SIZE_LIMIT=$enableval ],
10831+
[ ENABLED_RECORD_SIZE_LIMIT=no ]
10832+
)
10833+
dnl RFC 8449 defines the extension for TLS 1.2 as well as TLS 1.3, where the
10834+
dnl server answers in the ServerHello rather than EncryptedExtensions, so no
10835+
dnl TLS 1.3 dependency is imposed here.
10836+
if test "$ENABLED_RECORD_SIZE_LIMIT" = "yes"
10837+
then
10838+
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_RECORD_SIZE_LIMIT"
10839+
fi
10840+
10841+
# Certificate Compression (RFC 8879)
10842+
AC_ARG_ENABLE([certcomp],
10843+
[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)])],
10844+
[ ENABLED_CERTCOMP=$enableval ],
10845+
[ ENABLED_CERTCOMP=no ]
10846+
)
10847+
if test "$ENABLED_CERTCOMP" = "yes"
10848+
then
10849+
certcomp_missing=""
10850+
if test "x$ENABLED_TLS13" = "xno"
10851+
then
10852+
certcomp_missing="TLS 1.3"
10853+
fi
10854+
if test "x$ENABLED_LIBZ" = "xno"
10855+
then
10856+
certcomp_missing="libz"
10857+
fi
10858+
if test "x$certcomp_missing" != "x"
10859+
then
10860+
if test "x$certcomp_implicit" = "xyes"
10861+
then
10862+
dnl Switched on by --enable-all rather than asked for, so its
10863+
dnl requirements are not the user's to satisfy.
10864+
AC_MSG_WARN([certificate compression needs $certcomp_missing;
10865+
turning it off])
10866+
ENABLED_CERTCOMP=no
10867+
else
10868+
AC_MSG_ERROR([Certificate compression requires $certcomp_missing.])
10869+
fi
10870+
fi
10871+
fi
10872+
if test "$ENABLED_CERTCOMP" = "yes"
10873+
then
10874+
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_CERTIFICATE_COMPRESSION"
10875+
fi
10876+
1080110877
1080210878
# PKCS#11
1080310879
AC_ARG_ENABLE([pkcs11],
@@ -12639,6 +12715,18 @@ AS_IF([test "x$ENABLED_MAXSTRENGTH" = "xyes" && \
1263912715
test "x$ENABLED_LEANPSK" = "xyes"],
1264012716
[AC_MSG_ERROR([Cannot use Max Strength and Lean PSK at the same time.])])
1264112717
12718+
dnl Certificate compression carries a Certificate message, so it needs
12719+
dnl certificates. Checked here, not beside the option: ENABLED_CERTS is still
12720+
dnl being assigned well past that point.
12721+
AS_IF([test "x$ENABLED_CERTCOMP" = "xyes" && test "x$ENABLED_CERTS" = "xno"],
12722+
[AS_IF([test "x$certcomp_implicit" = "xyes"],
12723+
[AC_MSG_WARN([certificate compression needs certificates;
12724+
turning it off])
12725+
ENABLED_CERTCOMP=no
12726+
AM_CFLAGS=`echo "$AM_CFLAGS" | \
12727+
sed 's/ -DHAVE_CERTIFICATE_COMPRESSION//'`],
12728+
[AC_MSG_ERROR([Certificate compression requires certificates.])])])
12729+
1264212730
AS_IF([test "x$ENABLED_CRYPTONLY" = "xno" && \
1264312731
test "x$ENABLED_PSK" = "xno" && \
1264412732
test "x$ENABLED_ASN" = "xno"],
@@ -14129,6 +14217,9 @@ echo " * Whitewood netRandom: $ENABLED_WNR"
1412914217
echo " * Server Name Indication: $ENABLED_SNI"
1413014218
echo " * ALPN: $ENABLED_ALPN"
1413114219
echo " * Maximum Fragment Length: $ENABLED_MAX_FRAGMENT"
14220+
echo " * Record Size Limit: $ENABLED_RECORD_SIZE_LIMIT"
14221+
echo " * Certificate Compression: $ENABLED_CERTCOMP"
14222+
echo " * Signed Cert Timestamps: $ENABLED_SCT"
1413214223
echo " * Trusted CA Indication: $ENABLED_TRUSTED_CA"
1413314224
echo " * Truncated HMAC: $ENABLED_TRUNCATED_HMAC"
1413414225
echo " * Supported Elliptic Curves: $ENABLED_SUPPORTED_CURVES"

0 commit comments

Comments
 (0)