Fix SSL_export_keying_material for QUIC
authorHugo Landau <hlandau@openssl.org>
Tue, 13 Feb 2024 11:29:53 +0000 (11:29 +0000)
committerTomas Mraz <tomas@openssl.org>
Wed, 14 Feb 2024 17:14:52 +0000 (18:14 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23567)

(cherry picked from commit 498d4e4c4f4a1e220cfa64cfcc76174e2f656fd0)

ssl/ssl_lib.c
test/quicapitest.c

index 7d618bd7006a53395316e83528e01c939696c316..f44a1bfe33650a398f7572ca9d625e94d3c2d3aa 100644 (file)
@@ -3766,9 +3766,10 @@ int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,
         || (sc->version < TLS1_VERSION && sc->version != DTLS1_BAD_VER))
         return -1;
 
-    return s->method->ssl3_enc->export_keying_material(sc, out, olen, label,
-                                                       llen, context,
-                                                       contextlen, use_context);
+    return sc->ssl.method->ssl3_enc->export_keying_material(sc, out, olen, label,
+                                                            llen, context,
+                                                            contextlen,
+                                                            use_context);
 }
 
 int SSL_export_keying_material_early(SSL *s, unsigned char *out, size_t olen,
index 41cf0fc7a87ead0ed948634ab3863b49ba1f5578..9a1034b7b7cc5933a9f44f22d5295be0d9a8d08d 100644 (file)
@@ -53,7 +53,7 @@ static int test_quic_write_read(int idx)
     SSL *clientquic = NULL;
     QUIC_TSERVER *qtserv = NULL;
     int j, k, ret = 0;
-    unsigned char buf[20];
+    unsigned char buf[20], scratch[64];
     static char *msg = "A test message";
     size_t msglen = strlen(msg);
     size_t numbytes = 0;
@@ -153,6 +153,12 @@ static int test_quic_write_read(int idx)
                 goto end;
         }
 
+        /* Test that exporters work. */
+        if (!TEST_true(SSL_export_keying_material(clientquic, scratch,
+                        sizeof(scratch), "test", 4, (unsigned char *)"ctx", 3,
+                        1)))
+            goto end;
+
         if (sess == NULL) {
             /* We didn't supply a session so we're not expecting resumption */
             if (!TEST_false(SSL_session_reused(clientquic)))