From a3e4a2fd6e6ee170d1f0d4e4cfbb07aa39cdb9ab Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Fri, 28 Jun 2019 15:30:35 +1000 Subject: [PATCH] Fallback SCSV (Signaling Cipher Suite Value) support on Server only --- configure.ac | 13 +++++++++++++ src/internal.c | 14 +++++++++++++- wolfssl/internal.h | 2 ++ wolfssl/ssl.h | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d67f1ba4d..011da83d3 100644 --- a/configure.ac +++ b/configure.ac @@ -2844,6 +2844,18 @@ then AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SECURE_RENEGOTIATION -DHAVE_SERVER_RENEGOTIATION_INFO" fi +# Fallback SCSV +AC_ARG_ENABLE([fallback-scsv], + [AS_HELP_STRING([--enable-fallback-scsv],[Enable Fallback SCSV (default: disabled)])], + [ ENABLED_FALLBACK_SCSV=$enableval ], + [ ENABLED_FALLBACK_SCSV=no ] + ) + +if test "x$ENABLED_FALLBACK_SCSV" = "xyes" +then + AM_CFLAGS="$AM_CFLAGS -DHAVE_FALLBACK_SCSV" +fi + # Supported Elliptic Curves Extensions AC_ARG_ENABLE([supportedcurves], [AS_HELP_STRING([--enable-supportedcurves],[Enable Supported Elliptic Curves (default: enabled)])], @@ -4961,6 +4973,7 @@ echo " * Session Ticket: $ENABLED_SESSION_TICKET" echo " * Extended Master Secret: $ENABLED_EXTENDED_MASTER" echo " * Renegotiation Indication: $ENABLED_RENEGOTIATION_INDICATION" echo " * Secure Renegotiation: $ENABLED_SECURE_RENEGOTIATION" +echo " * Fallback SCSV: $ENABLED_FALLBACK_SCSV" echo " * All TLS Extensions: $ENABLED_TLSX" echo " * PKCS#7 $ENABLED_PKCS7" echo " * wolfSSH $ENABLED_WOLFSSH" diff --git a/src/internal.c b/src/internal.c index ea1b2e816..e0da3089e 100644 --- a/src/internal.c +++ b/src/internal.c @@ -23083,7 +23083,8 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, return ret; } -#ifdef HAVE_SERVER_RENEGOTIATION_INFO +#if defined(HAVE_SERVER_RENEGOTIATION_INFO) || defined(HAVE_FALLBACK_SCSV) || \ + defined(OPENSSL_ALL) /* search suites for specific one, idx on success, negative on error */ #ifndef WOLFSSL_TLS13 @@ -23871,6 +23872,17 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, } } #endif /* HAVE_SERVER_RENEGOTIATION_INFO */ +#if defined(HAVE_FALLBACK_SCSV) || defined(OPENSSL_ALL) + /* check for TLS_FALLBACK_SCSV suite */ + if (FindSuite(&clSuites, TLS_FALLBACK_SCSV, 0) >= 0) { + WOLFSSL_MSG("Found Fallback SCSV"); + if (ssl->ctx->method->version.minor > pv.minor) { + WOLFSSL_MSG("Client trying to connect with lesser version"); + SendAlert(ssl, alert_fatal, inappropriate_fallback); + return VERSION_ERROR; + } + } +#endif #ifdef WOLFSSL_DTLS if (IsDtlsNotSctpMode(ssl)) { diff --git a/wolfssl/internal.h b/wolfssl/internal.h index b522ee543..4737e6984 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -1066,6 +1066,8 @@ enum { TLS_AES_128_CCM_SHA256 = 0x04, TLS_AES_128_CCM_8_SHA256 = 0x05, + /* Fallback SCSV (Signaling Cipher Suite Value) */ + TLS_FALLBACK_SCSV = 0x56, /* Renegotiation Indication Extension Special Suite */ TLS_EMPTY_RENEGOTIATION_INFO_SCSV = 0xff }; diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index b8419c2e3..add3f8507 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -401,6 +401,7 @@ enum AlertDescription { #else protocol_version = 70, #endif + inappropriate_fallback = 86, no_renegotiation = 100, unsupported_extension = 110, /**< RFC 5246, section 7.2.2 */ unrecognized_name = 112, /**< RFC 6066, section 3 */