Skip to content

Commit a012a8f

Browse files
committed
DTLS 1.3 client-only minimum: WOLFSSL_DTLS_ONLY + autoconf cascade
* configure.ac: --enable-dtls13 auto-enables --enable-dtls and TLS 1.3, with a targeted error if either is explicitly --disabled, plus a post-finalization sanity check that errors out if a later prerequisite test forces ENABLED_TLS13 back to "no" while ENABLED_DTLS13 is yes. * src/internal.c, src/wolfio.c, wolfssl/wolfio.h: new WOLFSSL_DTLS_ONLY compile-time flag elides the EmbedReceive / EmbedSend default callbacks. The DTLS_MAJOR runtime check stays in SetSSL_CTX so a TLS-method ctx in a DTLS-only build doesn't get datagram callbacks by default, and WriteSEQ keeps its ssl->options.dtls branch. A #error in settings.h refuses WOLFSSL_DTLS_ONLY without WOLFSSL_DTLS. * wolfcrypt/src/aes.c: add HAVE_AES_DECRYPT to the inv_col_mul definition gate to match its only caller; without it the function is emitted dead under WOLFSSL_AES_DIRECT && NO_AES_DECRYPT and -Werror=unused-function fails the build. * .github/workflows/os-check.yml: matrix entry for a minimal DTLS 1.3 client-only build.
1 parent 9aec51d commit a012a8f

7 files changed

Lines changed: 56 additions & 9 deletions

File tree

.github/workflows/os-check.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ jobs:
108108
'--enable-lms=small,verify-only --enable-xmss=small,verify-only',
109109
'--enable-curve25519=nonblock --enable-ecc=nonblock --enable-sp=yes,nonblock CPPFLAGS="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK"',
110110
'--enable-certreq --enable-certext --enable-certgen --disable-secure-renegotiation-info CPPFLAGS="-DNO_TLS"',
111+
# Minimal DTLS 1.3 client-only build. The SHA-224/384/512/3
112+
# disables are deliberately omitted: --disable-sha384 alone
113+
# trips a pre-existing wolfSSL bug in
114+
# test_tls13_duplicate_extension (reproducible on clean master).
115+
'--enable-dtls13 --disable-tlsv12 --disable-oldtls --disable-rsa --disable-dh
116+
--disable-aescbc --disable-aesecb --disable-md5 --disable-chacha
117+
--disable-poly1305 --disable-errorstrings --disable-asn-print
118+
--disable-eccshamir --disable-base64encode --disable-coding --disable-sni
119+
--enable-aesgcm=small --enable-sp-math --enable-sp=smallec256 --disable-sp-asm
120+
CPPFLAGS=''-DNO_WOLFSSL_SERVER -DWOLFSSL_NO_TLS12 -DNO_SESSION_CACHE
121+
-DWOLFSSL_AES_NO_UNROLL -DUSE_SLOW_SHA256 -DWOLFSSL_NO_ASYNC_IO
122+
-DWOLFSSL_DTLS_ONLY'' ',
111123
]
112124
name: make check linux
113125
if: github.repository_owner == 'wolfssl'

configure.ac

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5736,9 +5736,26 @@ AC_ARG_ENABLE([dtls13],
57365736
)
57375737
if test "x$ENABLED_DTLS13" = "xyes"
57385738
then
5739-
if test "x$ENABLED_DTLS" != "xyes" || test "x$ENABLED_TLS13" != "xyes"
5739+
# DTLSv1.3 implies TLS 1.3 and DTLS; auto-enable, but don't
5740+
# override explicit --disable.
5741+
if test "x$enable_tls13" = "xno" || test "x$ENABLED_TLS13" = "xno"
57405742
then
5741-
AC_MSG_ERROR([You need to enable both DTLS and TLSv1.3 to use DTLSv1.3])
5743+
AC_MSG_ERROR([--enable-dtls13 requires TLS 1.3, but TLS 1.3 is disabled])
5744+
fi
5745+
if test "x$ENABLED_TLS13" != "xyes"
5746+
then
5747+
AC_MSG_NOTICE([DTLSv1.3 is enabled, enabling TLS 1.3])
5748+
ENABLED_TLS13=yes
5749+
fi
5750+
if test "x$enable_dtls" = "xno"
5751+
then
5752+
AC_MSG_ERROR([--enable-dtls13 requires DTLS, but --disable-dtls was given])
5753+
fi
5754+
if test "x$ENABLED_DTLS" != "xyes"
5755+
then
5756+
AC_MSG_NOTICE([DTLSv1.3 is enabled, enabling DTLS])
5757+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DTLS"
5758+
ENABLED_DTLS=yes
57425759
fi
57435760
if test "x$ENABLED_SEND_HRR_COOKIE" = "xundefined"
57445761
then
@@ -8347,6 +8364,11 @@ then
83478364
# disable TLS 1.3
83488365
ENABLED_TLS13=no
83498366
fi
8367+
# DTLSv1.3 cannot survive a downgrade of TLS 1.3.
8368+
if test "x$ENABLED_DTLS13" = "xyes" && test "x$ENABLED_TLS13" = "xno"
8369+
then
8370+
AC_MSG_ERROR([--enable-dtls13 requires TLS 1.3, but TLS 1.3 was disabled by an earlier prerequisite check (no key-exchange or signature algorithms reachable). Enable at least one of ECC, RSA+DH, Curve25519+Ed25519, Curve448+Ed448, PSK, or ML-KEM.])
8371+
fi
83508372
if test "$ENABLED_TLS13" = "yes" && (test "x$ENABLED_ECC" = "xyes" || \
83518373
test "$ENABLED_DH" != "no")
83528374
then

src/internal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,8 +2703,10 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
27032703
}
27042704
#endif
27052705
#else
2706-
ctx->CBIORecv = EmbedReceive;
2707-
ctx->CBIOSend = EmbedSend;
2706+
#ifndef WOLFSSL_DTLS_ONLY
2707+
ctx->CBIORecv = EmbedReceive;
2708+
ctx->CBIOSend = EmbedSend;
2709+
#endif
27082710
#ifdef WOLFSSL_SESSION_EXPORT
27092711
ctx->CBGetPeer = EmbedGetPeer;
27102712
ctx->CBSetPeer = EmbedSetPeer;

src/wolfio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ int SslBioSend(WOLFSSL* ssl, char *buf, int sz, void *ctx)
402402

403403
#ifdef USE_WOLFSSL_IO
404404

405+
#ifndef WOLFSSL_DTLS_ONLY
405406
/* The receive embedded callback
406407
* return : nb bytes read, or error
407408
*/
@@ -450,6 +451,7 @@ int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx)
450451

451452
return sent;
452453
}
454+
#endif /* !WOLFSSL_DTLS_ONLY */
453455

454456

455457
#ifdef WOLFSSL_DTLS

wolfcrypt/src/aes.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,8 +1920,9 @@ static WARN_UNUSED_RESULT word32 col_mul(
19201920
return GETBYTE(t, ia) ^ GETBYTE(t, ib) ^ t3 ^ tm;
19211921
}
19221922

1923-
#if defined(HAVE_AES_CBC) || defined(HAVE_AES_ECB) || \
1924-
defined(WOLFSSL_AES_DIRECT)
1923+
#if defined(HAVE_AES_DECRYPT) && \
1924+
(defined(HAVE_AES_CBC) || defined(HAVE_AES_ECB) || \
1925+
defined(WOLFSSL_AES_DIRECT))
19251926
static WARN_UNUSED_RESULT word32 inv_col_mul(
19261927
word32 t, int i9, int ib, int id, int ie)
19271928
{
@@ -1932,7 +1933,7 @@ static WARN_UNUSED_RESULT word32 inv_col_mul(
19321933
byte t0 = t9 ^ tb ^ td;
19331934
return t0 ^ AES_XTIME(AES_XTIME(AES_XTIME(t0 ^ te) ^ td ^ te) ^ tb ^ te);
19341935
}
1935-
#endif /* HAVE_AES_CBC || WOLFSSL_AES_DIRECT */
1936+
#endif /* HAVE_AES_DECRYPT && (HAVE_AES_CBC || HAVE_AES_ECB || WOLFSSL_AES_DIRECT) */
19361937
#endif /* WOLFSSL_AES_SMALL_TABLES */
19371938
#endif
19381939
#endif

wolfssl/wolfcrypt/settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4687,6 +4687,10 @@ extern void uITRON4_free(void *p) ;
46874687
#error "DTLS v1.3 requires both WOLFSSL_TLS13 and WOLFSSL_DTLS"
46884688
#endif
46894689

4690+
#if defined(WOLFSSL_DTLS_ONLY) && !defined(WOLFSSL_DTLS)
4691+
#error "WOLFSSL_DTLS_ONLY requires WOLFSSL_DTLS"
4692+
#endif
4693+
46904694
#if defined(WOLFSSL_QUIC) && defined(WOLFSSL_CALLBACKS)
46914695
#error WOLFSSL_QUIC is incompatible with WOLFSSL_CALLBACKS.
46924696
#endif

wolfssl/wolfio.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,10 @@ WOLFSSL_LOCAL int SslBioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
674674
/* default IO callbacks */
675675

676676
#ifdef WOLFSSL_API_PREFIX_MAP
677-
#define EmbedReceive wolfSSL_EmbedReceive
678-
#define EmbedSend wolfSSL_EmbedSend
677+
#ifndef WOLFSSL_DTLS_ONLY
678+
#define EmbedReceive wolfSSL_EmbedReceive
679+
#define EmbedSend wolfSSL_EmbedSend
680+
#endif
679681
#ifdef WOLFSSL_DTLS
680682
#define EmbedReceiveFrom wolfSSL_EmbedReceiveFrom
681683
#define EmbedSendTo wolfSSL_EmbedSendTo
@@ -686,8 +688,10 @@ WOLFSSL_LOCAL int SslBioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
686688
#endif /* WOLFSSL_DTLS */
687689
#endif /* WOLFSSL_API_PREFIX_MAP */
688690

691+
#ifndef WOLFSSL_DTLS_ONLY
689692
WOLFSSL_API int EmbedReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
690693
WOLFSSL_API int EmbedSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
694+
#endif
691695

692696
#ifdef WOLFSSL_DTLS
693697
#ifdef NUCLEUS_PLUS_2_3

0 commit comments

Comments
 (0)