Cleanse buffers

Cleanse various intermediate buffers used by the PRF (backported version
from master).

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 35fafc4dbc)

Conflicts:
	ssl/s3_enc.c
This commit is contained in:
Matt Caswell 2015-03-09 13:59:58 +00:00
parent 8b7e469d06
commit 58d8a271ab
2 changed files with 6 additions and 0 deletions

View File

@ -841,6 +841,7 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
ret += n; ret += n;
} }
EVP_MD_CTX_cleanup(&ctx); EVP_MD_CTX_cleanup(&ctx);
OPENSSL_cleanse(buf, sizeof buf);
return (ret); return (ret);
} }

View File

@ -958,6 +958,8 @@ int tls1_final_finish_mac(SSL *s,
err = 1; err = 1;
EVP_MD_CTX_cleanup(&ctx); EVP_MD_CTX_cleanup(&ctx);
OPENSSL_cleanse(buf, (int)(q - buf));
OPENSSL_cleanse(buf2, sizeof(buf2));
if (err) if (err)
return 0; return 0;
else else
@ -1121,6 +1123,7 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
co, col, co, col,
s->s3->server_random, SSL3_RANDOM_SIZE, s->s3->server_random, SSL3_RANDOM_SIZE,
so, sol, p, len, s->session->master_key, buff, sizeof buff); so, sol, p, len, s->session->master_key, buff, sizeof buff);
OPENSSL_cleanse(buff, sizeof buff);
#ifdef SSL_DEBUG #ifdef SSL_DEBUG
fprintf(stderr, "Premaster Secret:\n"); fprintf(stderr, "Premaster Secret:\n");
BIO_dump_fp(stderr, (char *)p, len); BIO_dump_fp(stderr, (char *)p, len);
@ -1215,6 +1218,8 @@ int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen,
NULL, 0, NULL, 0,
s->session->master_key, s->session->master_key_length, s->session->master_key, s->session->master_key_length,
out, buff, olen); out, buff, olen);
OPENSSL_cleanse(val, vallen);
OPENSSL_cleanse(buff, olen);
#ifdef KSSL_DEBUG #ifdef KSSL_DEBUG
fprintf(stderr, "tls1_export_keying_material() complete\n"); fprintf(stderr, "tls1_export_keying_material() complete\n");