ssl_log_secret call in tls13_key_update
authorvisbjn <Jochen.Kreissl@vector.com>
Mon, 19 Sep 2022 08:27:34 +0000 (10:27 +0200)
committerMatt Caswell <matt@openssl.org>
Tue, 27 Sep 2022 14:56:51 +0000 (15:56 +0100)
Newly computed traffic secrets are now logged upon key update

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19241)

(cherry picked from commit 2f7e61b8b21ed472a3667b8922843851f94a3d93)

ssl/ssl_local.h
ssl/tls13_enc.c

index 5471e900b82d3b44559af41f01c407144fae16ec..5fb1feb801635aaa408744c61a90383a50af55dd 100644 (file)
@@ -2752,7 +2752,9 @@ __owur int ssl_log_secret(SSL *ssl, const char *label,
 #define CLIENT_HANDSHAKE_LABEL "CLIENT_HANDSHAKE_TRAFFIC_SECRET"
 #define SERVER_HANDSHAKE_LABEL "SERVER_HANDSHAKE_TRAFFIC_SECRET"
 #define CLIENT_APPLICATION_LABEL "CLIENT_TRAFFIC_SECRET_0"
+#define CLIENT_APPLICATION_N_LABEL "CLIENT_TRAFFIC_SECRET_N"
 #define SERVER_APPLICATION_LABEL "SERVER_TRAFFIC_SECRET_0"
+#define SERVER_APPLICATION_N_LABEL "SERVER_TRAFFIC_SECRET_N"
 #define EARLY_EXPORTER_SECRET_LABEL "EARLY_EXPORTER_SECRET"
 #define EXPORTER_SECRET_LABEL "EXPORTER_SECRET"
 
index b186cb3897608bf36e5057cc0c36fed5fd94d71d..ddcff5eb89119cf9ea49f48f8cf454655de4cc3c 100644 (file)
@@ -755,6 +755,7 @@ int tls13_update_key(SSL *s, int sending)
     unsigned char key[EVP_MAX_KEY_LENGTH];
     unsigned char *insecret, *iv;
     unsigned char secret[EVP_MAX_MD_SIZE];
+    char *log_label;
     EVP_CIPHER_CTX *ciph_ctx;
     int ret = 0, l;
 
@@ -791,6 +792,13 @@ int tls13_update_key(SSL *s, int sending)
 
     memcpy(insecret, secret, hashlen);
 
+    /* Call Key log on successful traffic secret update */
+    log_label = s->server == sending ? SERVER_APPLICATION_N_LABEL : CLIENT_APPLICATION_N_LABEL;
+    if (!ssl_log_secret(s, log_label, secret, hashlen)) {
+        /* SSLfatal() already called */
+        goto err;
+    }
+
     s->statem.enc_write_state = ENC_WRITE_STATE_VALID;
     ret = 1;
  err: