diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2012-08-28 23:17:28 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2012-08-28 23:17:28 +0000 |
commit | 1cf218bcaa77b8d069af7587585f150575339d54 (patch) | |
tree | 0cab2b04b31ad50086dc1ed3d682f4493978087a /ssl/s3_enc.c | |
parent | 093050b66025c9cffb115c0a7472b4ce2de49d62 (diff) |
New compile time option OPENSSL_SSL_TRACE_CRYPTO, when set this passes
all derived keys to the message callback.
Add code to SSL_trace to include support for printing out keys.
Diffstat (limited to 'ssl/s3_enc.c')
-rw-r--r-- | ssl/s3_enc.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c index c5df2cb90a..d54babc96d 100644 --- a/ssl/s3_enc.c +++ b/ssl/s3_enc.c @@ -375,6 +375,27 @@ int ssl3_change_cipher_state(SSL *s, int which) EVP_CipherInit_ex(dd,c,NULL,key,iv,(which & SSL3_CC_WRITE)); +#ifdef OPENSSL_SSL_TRACE_CRYPTO + if (s->msg_callback) + { + + int wh = which & SSL3_CC_WRITE ? + TLS1_RT_CRYPTO_WRITE : TLS1_RT_CRYPTO_READ; + s->msg_callback(2, s->version, wh | TLS1_RT_CRYPTO_MAC, + mac_secret, EVP_MD_size(m), + s, s->msg_callback_arg); + if (c->key_len) + s->msg_callback(2, s->version, wh | TLS1_RT_CRYPTO_KEY, + key, c->key_len, + s, s->msg_callback_arg); + if (k) + { + s->msg_callback(2, s->version, wh | TLS1_RT_CRYPTO_IV, + iv, k, s, s->msg_callback_arg); + } + } +#endif + OPENSSL_cleanse(&(exp_key[0]),sizeof(exp_key)); OPENSSL_cleanse(&(exp_iv[0]),sizeof(exp_iv)); EVP_MD_CTX_cleanup(&md); @@ -797,6 +818,9 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, EVP_MD_CTX ctx; int i,ret=0; unsigned int n; +#ifdef SSL_TRACE_CRYPTO_DEBUG + unsigned char *tmpout = out; +#endif EVP_MD_CTX_init(&ctx); for (i=0; i<3; i++) @@ -818,6 +842,23 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, ret+=n; } EVP_MD_CTX_cleanup(&ctx); + +#ifdef SSL_TRACE_CRYPTO_DEBUG + if (s->msg_callback) + { + s->msg_callback(2, s->version, TLS1_RT_CRYPTO_PREMASTER, + p, len, s, s->msg_callback_arg); + s->msg_callback(2, s->version, TLS1_RT_CRYPTO_CLIENT_RANDOM, + s->s3->client_random, SSL3_RANDOM_SIZE, + s, s->msg_callback_arg); + s->msg_callback(2, s->version, TLS1_RT_CRYPTO_SERVER_RANDOM, + s->s3->server_random, SSL3_RANDOM_SIZE, + s, s->msg_callback_arg); + s->msg_callback(2, s->version, TLS1_RT_CRYPTO_MASTER, + tmpout, SSL3_MASTER_SECRET_SIZE, + s, s->msg_callback_arg); + } +#endif return(ret); } |