Skip to content

Commit

Permalink
ssl_log_secret call in tls13_key_update
Browse files Browse the repository at this point in the history
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 #19241)

(cherry picked from commit 2f7e61b)
  • Loading branch information
JochenKreissl authored and mattcaswell committed Sep 27, 2022
1 parent 61f8d46 commit 54ba0f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ssl/ssl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 8 additions & 0 deletions ssl/tls13_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 54ba0f1

Please sign in to comment.