Skip to content

Commit

Permalink
TLS: add support for ECH (Encrypted Client Hello)
Browse files Browse the repository at this point in the history
An EXPERIMENTAL feature used with CURLOPT_ECH and --ech.

Closes curl#11922
  • Loading branch information
sftcd authored and bagder committed Apr 16, 2024
1 parent 565d28d commit a362962
Show file tree
Hide file tree
Showing 40 changed files with 3,122 additions and 16 deletions.
23 changes: 23 additions & 0 deletions .github/scripts/spellcheck.words
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: curl
#
AAAA
ABI
accessor
ACK
Expand All @@ -10,6 +11,7 @@ AIA
AIX
al
Alessandro
aliasMode
allocator
alnum
ALPN
Expand Down Expand Up @@ -109,13 +111,16 @@ CLA
CLAs
cleartext
CLI
ClientHello
clientp
cliget
closesocket
CMake
cmake
CMake's
cmake's
CNAME
CNAMEs
CMakeLists
CNA
CodeQL
Expand Down Expand Up @@ -146,6 +151,7 @@ cURL
CURLcode
curldown
CURLE
CURLECH
CURLH
curlimages
CURLINFO
Expand All @@ -164,6 +170,7 @@ dbg
Debian
DEBUGBUILD
decrypt
decrypting
deepcode
DELE
DER
Expand All @@ -190,6 +197,7 @@ DNS
dns
dnsop
DoH
DoT
doxygen
drftpd
dsa
Expand All @@ -201,6 +209,9 @@ EBCDIC
ECC
ECDHE
ECH
ecl
ECHConfig
ECHConfigList
ECONNREFUSED
eCOS
EFnet
Expand Down Expand Up @@ -284,6 +295,8 @@ GOST
GPG
GPL
GPLed
GREASE
GREASEing
Greear
groff
gsasl
Expand All @@ -307,6 +320,7 @@ Hards
Haxx
haxx
Heimdal
HelloRetryRequest
HELO
HH
HMAC
Expand All @@ -316,6 +330,7 @@ homebrew
hostname
hostnames
Housley
HRR
Hruska
HSTS
hsts
Expand Down Expand Up @@ -460,6 +475,7 @@ Marek
Mavrogiannopoulos
Mbed
mbedTLS
md
Meglio
memdebug
MesaLink
Expand All @@ -470,6 +486,7 @@ Michal
Micrium
MicroBlaze
MicroOS
middlebox
mingw
MinGW
MINIX
Expand Down Expand Up @@ -590,6 +607,7 @@ pkcs
PKGBUILD
PKI
pluggable
pn
PolarSSL
Polhem
pollset
Expand Down Expand Up @@ -625,6 +643,7 @@ py
pycurl
pytest
Pytest
qname
QNX
QoS
Qubes
Expand Down Expand Up @@ -668,6 +687,9 @@ Roadmap
Rockbox
roffit
RPG
RR
RRs
RRtype
RSA
RTMP
rtmp
Expand Down Expand Up @@ -784,6 +806,7 @@ SunSSH
superset
svc
svcb
SVCB
Svyatoslav
Swisscom
sws
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -65,3 +65,4 @@ curl_fuzzer_seed_corpus.zip
libstandaloneengine.a
tests/string
tests/config
tests/ech-log/
28 changes: 28 additions & 0 deletions CMakeLists.txt
Expand Up @@ -37,6 +37,7 @@
# HAVE_GNUTLS_SRP: `gnutls_srp_verifier` present in GnuTLS
# HAVE_SSL_CTX_SET_QUIC_METHOD: `SSL_CTX_set_quic_method` present in OpenSSL/wolfSSL
# HAVE_QUICHE_CONN_SET_QLOG_FD: `quiche_conn_set_qlog_fd` present in QUICHE
# HAVE_ECH: ECH API checks for OpenSSL, boringssl or wolfSSL
#
# For each of the above variables, if the variable is DEFINED (either
# to ON or OFF), the symbol detection will be skipped. If the
Expand Down Expand Up @@ -654,6 +655,31 @@ if(USE_OPENSSL OR USE_WOLFSSL)
endif()
endif()

option(USE_HTTPSRR "Enable HTTPS RR support for ECH (experimental)" OFF)
option(USE_ECH "Enable ECH support" OFF)
if(USE_ECH)
if(USE_OPENSSL OR USE_WOLFSSL)
# Be sure that the OpenSSL/wolfSSL library actually supports ECH.
if(NOT DEFINED HAVE_ECH)
if(USE_OPENSSL AND HAVE_BORINGSSL)
openssl_check_symbol_exists(SSL_set1_ech_config_list "openssl/ssl.h" HAVE_ECH)
elseif(USE_OPENSSL)
openssl_check_symbol_exists(SSL_ech_set1_echconfig "openssl/ech.h" HAVE_ECH)
elseif(USE_WOLFSSL)
openssl_check_symbol_exists(wolfSSL_CTX_GenerateEchConfig "wolfssl/options.h;wolfssl/ssl.h" HAVE_ECH)
endif()
endif()
if(NOT HAVE_ECH)
message(FATAL_ERROR "ECH support missing in OpenSSL/BoringSSL/wolfSSL")
else()
message("ECH enabled.")
endif()
else()
message(FATAL_ERROR "ECH requires ECH-enablded OpenSSL, BoringSSL or wolfSSL")
endif()
endif()


option(USE_NGHTTP2 "Use nghttp2 library" OFF)
if(USE_NGHTTP2)
find_package(NGHTTP2 REQUIRED)
Expand Down Expand Up @@ -1590,6 +1616,8 @@ if(NOT CURL_DISABLE_INSTALL)
_add_if("IPFS" NOT CURL_DISABLE_HTTP)
_add_if("IPNS" NOT CURL_DISABLE_HTTP)
_add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED)
_add_if("ECH" HAVE_ECH)
_add_if("HTTPSRR" HAVE_ECH)
_add_if("FTP" NOT CURL_DISABLE_FTP)
_add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED)
_add_if("FILE" NOT CURL_DISABLE_FILE)
Expand Down
37 changes: 27 additions & 10 deletions configure.ac
Expand Up @@ -51,6 +51,7 @@ CURL_CHECK_OPTION_CURLDEBUG
CURL_CHECK_OPTION_SYMBOL_HIDING
CURL_CHECK_OPTION_ARES
CURL_CHECK_OPTION_RT
CURL_CHECK_OPTION_HTTPSRR
CURL_CHECK_OPTION_ECH

XC_CHECK_PATH_SEPARATOR
Expand Down Expand Up @@ -4538,6 +4539,16 @@ if test "x$hsts" != "xyes"; then
AC_DEFINE(CURL_DISABLE_HSTS, 1, [disable alt-svc])
fi


dnl *************************************************************
dnl check whether HTTPSRR support if desired
dnl
if test "x$want_httpsrr" != "xno"; then
AC_MSG_RESULT([HTTPSRR support is available])
AC_DEFINE(USE_HTTPSRR, 1, [enable HTTPS RR support])
experimental="$experimental HTTPSRR"
fi

dnl *************************************************************
dnl check whether ECH support, if desired, is actually available
dnl
Expand All @@ -4548,18 +4559,28 @@ if test "x$want_ech" != "xno"; then
ECH_ENABLED=0
ECH_SUPPORT=''

dnl OpenSSL with a chosen ECH function should be enough
dnl so more exhaustive checking seems unnecessary for now
dnl check for OpenSSL
if test "x$OPENSSL_ENABLED" = "x1"; then
AC_CHECK_FUNCS(SSL_get_ech_status,
ECH_SUPPORT="ECH support available (OpenSSL with SSL_get_ech_status)"
AC_CHECK_FUNCS(SSL_ech_set1_echconfig,
ECH_SUPPORT="ECH support available via OpenSSL with SSL_ech_set1_echconfig"
ECH_ENABLED=1)
fi
dnl check for boringssl equivalent
if test "x$OPENSSL_ENABLED" = "x1"; then
AC_CHECK_FUNCS(SSL_set1_ech_config_list,
ECH_SUPPORT="ECH support available via boringssl with SSL_set1_ech_config_list"
ECH_ENABLED=1)
fi
if test "x$WOLFSSL_ENABLED" = "x1"; then
AC_CHECK_FUNCS(wolfSSL_CTX_GenerateEchConfig,
ECH_SUPPORT="ECH support available via WolfSSL with wolfSSL_CTX_GenerateEchConfig"
ECH_ENABLED=1)

dnl add 'elif' chain here for additional implementations
fi

dnl now deal with whatever we found
if test "x$ECH_ENABLED" = "x1"; then
dnl force pre-requisites for ECH
AC_DEFINE(USE_HTTPSRR, 1, [force HTTPS RR support for ECH])
AC_DEFINE(USE_ECH, 1, [if ECH support is available])
AC_MSG_RESULT($ECH_SUPPORT)
experimental="$experimental ECH"
Expand Down Expand Up @@ -4777,10 +4798,6 @@ else
AC_MSG_RESULT([no])
fi

if test "x$ECH_ENABLED" = "x1"; then
SUPPORT_FEATURES="$SUPPORT_FEATURES ECH"
fi

if test ${ac_cv_sizeof_curl_off_t} -gt 4; then
if test ${ac_cv_sizeof_off_t} -gt 4 -o \
"$curl_win32_file_api" = "win32_large_files"; then
Expand Down

0 comments on commit a362962

Please sign in to comment.