summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsteve <steve>2007-02-21 13:48:05 +0000
committersteve <steve>2007-02-21 13:48:05 +0000
commit9507a1a926877d244e6ffbecc538536bc40af3f6 (patch)
treec2bc9e5baa7232ae10818eadf08dd3e51ee2aad9
parent83fb86ce06b97782b47a2ddfa8c4697a11aa83c1 (diff)
downloadopenssl-9507a1a926877d244e6ffbecc538536bc40af3f6.tar.gz
Cleanse PEM buffers before freeing them.
Submitted by: Benjamin Bennett <ben@psc.edu>
-rw-r--r--CHANGES4
-rw-r--r--crypto/pem/pem_lib.c5
-rw-r--r--crypto/pem/pem_pkey.c1
3 files changed, 9 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index e32b08cff..ecef9b6e2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,10 @@
Changes between 0.9.7l and 0.9.7m [xx XXX xxxx]
+ *) Cleanse PEM buffers before freeing them since they may contain
+ sensitive data.
+ [Benjamin Bennett <ben@psc.edu>]
+
*) Include "!eNULL" in SSL_DEFAULT_CIPHER_LIST to make sure that
a ciphersuite string such as "DEFAULT:RSA" cannot enable
authentication-only ciphersuites.
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index 0dcbab6f3..54262cc8f 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -577,6 +577,7 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data,
}
EVP_EncodeFinal(&ctx,buf,&outl);
if ((outl > 0) && (BIO_write(bp,(char *)buf,outl) != outl)) goto err;
+ OPENSSL_cleanse(buf, PEM_BUFSIZE*8);
OPENSSL_free(buf);
buf = NULL;
if ( (BIO_write(bp,"-----END ",9) != 9) ||
@@ -585,8 +586,10 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data,
goto err;
return(i+outl);
err:
- if (buf)
+ if (buf) {
+ OPENSSL_cleanse(buf, PEM_BUFSIZE*8);
OPENSSL_free(buf);
+ }
PEMerr(PEM_F_PEM_WRITE_BIO,reason);
return(0);
}
diff --git a/crypto/pem/pem_pkey.c b/crypto/pem/pem_pkey.c
index 9ecdbd541..69300ba5e 100644
--- a/crypto/pem/pem_pkey.c
+++ b/crypto/pem/pem_pkey.c
@@ -122,6 +122,7 @@ p8err:
PEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB);
err:
OPENSSL_free(nm);
+ OPENSSL_cleanse(data, len);
OPENSSL_free(data);
return(ret);
}