QUIC DISPATCH/APL: Implement SSL_get0_connection
authorHugo Landau <hlandau@openssl.org>
Tue, 18 Apr 2023 18:30:54 +0000 (19:30 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 12 May 2023 13:47:11 +0000 (14:47 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20765)

include/internal/quic_ssl.h
include/openssl/ssl.h.in
ssl/quic/quic_impl.c
ssl/ssl_lib.c
util/libssl.num

index 97ee2c921874d717ab91ac39a07aac0e2628ed6a..86dca6bb30bedf3f315cc3f9ac7669983902750e 100644 (file)
@@ -66,6 +66,7 @@ BIO *ossl_quic_conn_get_net_wbio(const SSL *s);
 __owur int ossl_quic_conn_set_initial_peer_addr(SSL *s,
                                                 const BIO_ADDR *peer_addr);
 __owur SSL *ossl_quic_conn_stream_new(SSL *s, uint64_t flags);
+__owur SSL *ossl_quic_get0_connection(SSL *s);
 
 /*
  * Used to override ossl_time_now() for debug purposes. Must be called before
index 9593e6bfed29c8068d326dc85b58110c672cdc53..869a74ae850cca22739f0eeb794335386be87799 100644 (file)
@@ -2266,6 +2266,7 @@ __owur int SSL_net_write_desired(SSL *s);
 __owur int SSL_set_blocking_mode(SSL *s, int blocking);
 __owur int SSL_get_blocking_mode(SSL *s);
 __owur int SSL_set_initial_peer_addr(SSL *s, const BIO_ADDR *peer_addr);
+__owur SSL *SSL_get0_connection(SSL *s);
 
 #define SSL_STREAM_FLAG_UNI     (1U << 0)
 __owur SSL *SSL_new_stream(SSL *s, uint64_t flags);
index 01b99c54613b6d2305037fc3139c1e22f6d8a6f7..3ed03b1c866d2d68b7a6702624a98eee2a279f86 100644 (file)
@@ -1821,6 +1821,20 @@ int SSL_inject_net_dgram(SSL *s, const unsigned char *buf,
     return ret;
 }
 
+/*
+ * SSL_get0_connection
+ * -------------------
+ */
+SSL *ossl_quic_get0_connection(SSL *s)
+{
+    QCTX ctx;
+
+    if (!expect_quic(s, &ctx))
+        return NULL;
+
+    return &ctx.qc->ssl;
+}
+
 /*
  * QUIC Front-End I/O API: SSL_CTX Management
  * ==========================================
index 56cbbac5f89d5d9f7d774683c9a5341e6632fcf3..31905a23d426b2b432bcbc2c1c55b005201ec622 100644 (file)
@@ -7311,6 +7311,18 @@ SSL *SSL_new_stream(SSL *s, uint64_t flags)
 #endif
 }
 
+SSL *SSL_get0_connection(SSL *s)
+{
+#ifndef OPENSSL_NO_QUIC
+    if (!IS_QUIC(s))
+        return s;
+
+    return ossl_quic_get0_connection(s);
+#else
+    return s;
+#endif
+}
+
 int SSL_add_expected_rpk(SSL *s, EVP_PKEY *rpk)
 {
     unsigned char *data = NULL;
index 635835666319ba7e357c89d8b7b95b247b8c50d1..78a2676b4de4e2686dd945776963f8867b25c5e0 100644 (file)
@@ -561,3 +561,4 @@ d2i_SSL_SESSION_ex                      ?   3_2_0   EXIST::FUNCTION:
 SSL_is_tls                              ?      3_2_0   EXIST::FUNCTION:
 SSL_is_quic                             ?      3_2_0   EXIST::FUNCTION:
 SSL_new_stream                          ?      3_2_0   EXIST::FUNCTION:
+SSL_get0_connection                     ?      3_2_0   EXIST::FUNCTION: