Cleanse buffers
authorMatt Caswell <matt@openssl.org>
Mon, 9 Mar 2015 13:59:58 +0000 (13:59 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 11 Mar 2015 10:45:23 +0000 (10:45 +0000)
Cleanse various intermediate buffers used by the PRF (backported version
from master).

Reviewed-by: Richard Levitte <levitte@openssl.org>
ssl/s3_enc.c
ssl/t1_enc.c

index cdbf0f095f4ba503f4886e430e1ca9a520f589d9..cda2d8c77603c71f40664feb81edc61b0c2d1dda 100644 (file)
@@ -877,6 +877,7 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
                         s, s->msg_callback_arg);
     }
 #endif
+    OPENSSL_cleanse(buf, sizeof buf);
     return (ret);
 }
 
index a563fe46157760a597967cbceecc663b6016fb72..84f589606be14d74bf6e816c0c4c7fc7a4847d41 100644 (file)
@@ -976,6 +976,8 @@ int tls1_final_finish_mac(SSL *s,
         err = 1;
     EVP_MD_CTX_cleanup(&ctx);
 
+    OPENSSL_cleanse(buf, (int)(q - buf));
+    OPENSSL_cleanse(buf2, sizeof(buf2));
     if (err)
         return 0;
     else
@@ -1139,6 +1141,7 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
              co, col,
              s->s3->server_random, SSL3_RANDOM_SIZE,
              so, sol, p, len, s->session->master_key, buff, sizeof buff);
+    OPENSSL_cleanse(buff, sizeof buff);
 #ifdef SSL_DEBUG
     fprintf(stderr, "Premaster Secret:\n");
     BIO_dump_fp(stderr, (char *)p, len);
@@ -1249,6 +1252,8 @@ int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen,
                   NULL, 0,
                   s->session->master_key, s->session->master_key_length,
                   out, buff, olen);
+    OPENSSL_cleanse(val, vallen);
+    OPENSSL_cleanse(buff, olen);
 
 #ifdef KSSL_DEBUG
     fprintf(stderr, "tls1_export_keying_material() complete\n");