Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log for tls diffie–hellman ephemeral key #1508

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@ static void ssl_info(const SSL *ssl, int where, int ret)
const
#endif
SSL_CIPHER *cipher;
int secret, processed;
int secret, processed, i;
EVP_PKEY *key;

if (!(data = (ssl_appdata *) SSL_get_app_data(ssl)))
return;
Expand Down Expand Up @@ -770,15 +771,23 @@ static void ssl_info(const SSL *ssl, int where, int ret)
/* Display cipher information */
cipher = SSL_get_current_cipher(ssl);
processed = SSL_CIPHER_get_bits(cipher, &secret);
putlog(LOG_DEBUG, "*", "TLS: cipher used: %s %s; %d bits (%d secret)",
SSL_CIPHER_get_name(cipher), SSL_get_version(ssl),
processed, secret);
putlog(LOG_DEBUG, "*", "TLS: cipher used: %s, %d of %d secret bits used for cipher, %s",
SSL_CIPHER_get_name(cipher), processed, secret, SSL_get_version(ssl));
/* secret are the actually secret bits. If processed and secret differ,
the rest of the bits are fixed, i.e. for limited export ciphers */

/* More verbose information, for debugging only */
SSL_CIPHER_description(cipher, buf, sizeof buf);
i = strlen(buf);
if ((i > 0) && (buf[i - 1]) == '\n')
buf[i - 1] = 0;
debug1("TLS: cipher details: %s", buf);

if (SSL_get_server_tmp_key((SSL *) ssl, &key)) {
putlog(LOG_DEBUG, "*", "TLS: diffie–hellman ephemeral key used: %s, bits %d",
OBJ_nid2sn(EVP_PKEY_id(key)), EVP_PKEY_bits(key));
EVP_PKEY_free(key);
}
} else if (where & SSL_CB_ALERT) {
if (strcmp(SSL_alert_type_string(ret), "W") ||
strcmp(SSL_alert_desc_string(ret), "CN")) {
Expand Down