QUIC: Define error code for stateless reset
authorHugo Landau <hlandau@openssl.org>
Thu, 15 Feb 2024 09:14:41 +0000 (09:14 +0000)
committerHugo Landau <hlandau@openssl.org>
Thu, 7 Mar 2024 23:48:49 +0000 (23:48 +0000)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23598)

doc/man3/SSL_get_conn_close_info.pod
include/openssl/quic.h
ssl/quic/quic_channel.c
util/other.syms

index bb5bc72b7a6c0ada1abe820a45a5276d38c88d75..badb3bf7a64d594ed12dc6185383b546d377a14f 100644 (file)
@@ -23,7 +23,8 @@ OSSL_QUIC_ERR_AEAD_LIMIT_REACHED,
 OSSL_QUIC_ERR_NO_VIABLE_PATH,
 OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN,
 OSSL_QUIC_ERR_CRYPTO_ERR_END,
-OSSL_QUIC_ERR_CRYPTO_ERR
+OSSL_QUIC_ERR_CRYPTO_ERR,
+OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT
 - get information about why a QUIC connection was closed
 
 =head1 SYNOPSIS
@@ -67,6 +68,8 @@ OSSL_QUIC_ERR_CRYPTO_ERR
 
  #define OSSL_QUIC_ERR_CRYPTO_ERR(X)
 
+ #define OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT
+
 =head1 DESCRIPTION
 
 The SSL_get_conn_close_info() function provides information about why and how a
@@ -124,6 +127,29 @@ by the local or remote application.
 
 =back
 
+The B<OSSL_QUIC_ERR> macro definitions provide the QUIC transport error codes as
+defined by RFC 9000. The OSSL_QUIC_ERR_CRYPTO_ERR() macro can be used to convert
+a TLS alert code into a QUIC transport error code by mapping it into the range
+reserved for such codes by RFC 9000. This range begins at
+B<OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN> and ends at B<OSSL_QUIC_ERR_CRYPTO_ERR_END>
+inclusive.
+
+=head1 NON-STANDARD TRANSPORT ERROR CODES
+
+Some conditions which can cause QUIC connection termination are not signalled on
+the wire and therefore do not have standard error codes. OpenSSL indicates these
+errors via SSL_get_conn_close_info() by setting B<SSL_CONN_CLOSE_FLAG_TRANSPORT>
+and using one of the following error values. These codes are specific to
+OpenSSL, and cannot be sent over the wire, as they are above 2**62.
+
+=over 4
+
+=item B<OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT>
+
+The connection was terminated immediately due to the idle timeout expiring.
+
+=back
+
 =head1 RETURN VALUES
 
 SSL_get_conn_close_info() returns 1 on success and 0 on failure. This function
index 853b944316ea265397742137ceafecd64b3c01e9..f66d643261804a5b92b0b8505973fd4f8bda40bf 100644 (file)
@@ -58,6 +58,10 @@ __owur const SSL_METHOD *OSSL_QUIC_client_thread_method(void);
 #  define OSSL_QUIC_ERR_CRYPTO_ERR(X) \
     (OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN + (X))
 
+/* Local errors. */
+#  define OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT        \
+    ((uint64_t)0xFFFFFFFFFFFFFFFFULL)
+
 #  ifdef __cplusplus
 }
 #  endif
index 9bab5d005b5c9882e0e3faaca1286260c1d96c4c..5bc08fad9157375918727fede0be92399c6fde30 100644 (file)
@@ -3325,7 +3325,7 @@ static void ch_on_idle_timeout(QUIC_CHANNEL *ch)
      * TERMINATED anyway.
      */
     ch->terminate_cause.app         = 0;
-    ch->terminate_cause.error_code  = UINT64_MAX;
+    ch->terminate_cause.error_code  = OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT;
     ch->terminate_cause.frame_type  = 0;
 
     ch_record_state_transition(ch, QUIC_CHANNEL_STATE_TERMINATED);
index b12aba44e66a747866df2d32692fdacdf2f8e633..e8a813c9bb0a42fa44b3d74a3c7626594ee3635c 100644 (file)
@@ -510,6 +510,7 @@ OSSL_QUIC_ERR_NO_VIABLE_PATH            define
 OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN          define
 OSSL_QUIC_ERR_CRYPTO_ERR_END            define
 OSSL_QUIC_ERR_CRYPTO_ERR                define
+OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT        define
 PEM_FLAG_EAY_COMPATIBLE                 define
 PEM_FLAG_ONLY_B64                       define
 PEM_FLAG_SECURE                         define