summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortedu <>2014-05-07 21:06:05 +0000
committertedu <>2014-05-07 21:06:05 +0000
commit38032d526b500060215164962909684100dc4bdc (patch)
tree12cd88c23032ad7586ab59e31ffae76e6118e809 /src
parentd4f5f3aa4283881df0366f88a495f1c26c1867cb (diff)
downloadopenbsd-38032d526b500060215164962909684100dc4bdc.tar.gz
openbsd-38032d526b500060215164962909684100dc4bdc.tar.bz2
openbsd-38032d526b500060215164962909684100dc4bdc.zip
in BN_clear_free, don't cleanse the data if the static data flag is set.
much debugging work done by otto. ok miod otto. side note: BN_FLG_STATIC_DATA doesn't actually mean the data is static. it's also used to indicate the data may be secretly shared behind your back as a sort of poor man's refcounting, but without the refcounting.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c5
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_lib.c5
2 files changed, 4 insertions, 6 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index 9787a31dbb..6ec9282653 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -214,11 +214,10 @@ void BN_clear_free(BIGNUM *a)
214 214
215 if (a == NULL) return; 215 if (a == NULL) return;
216 bn_check_top(a); 216 bn_check_top(a);
217 if (a->d != NULL) 217 if (a->d != NULL && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
218 { 218 {
219 OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0])); 219 OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0]));
220 if (!(BN_get_flags(a,BN_FLG_STATIC_DATA))) 220 free(a->d);
221 free(a->d);
222 } 221 }
223 i=BN_get_flags(a,BN_FLG_MALLOCED); 222 i=BN_get_flags(a,BN_FLG_MALLOCED);
224 OPENSSL_cleanse(a,sizeof(BIGNUM)); 223 OPENSSL_cleanse(a,sizeof(BIGNUM));
diff --git a/src/lib/libssl/src/crypto/bn/bn_lib.c b/src/lib/libssl/src/crypto/bn/bn_lib.c
index 9787a31dbb..6ec9282653 100644
--- a/src/lib/libssl/src/crypto/bn/bn_lib.c
+++ b/src/lib/libssl/src/crypto/bn/bn_lib.c
@@ -214,11 +214,10 @@ void BN_clear_free(BIGNUM *a)
214 214
215 if (a == NULL) return; 215 if (a == NULL) return;
216 bn_check_top(a); 216 bn_check_top(a);
217 if (a->d != NULL) 217 if (a->d != NULL && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
218 { 218 {
219 OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0])); 219 OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0]));
220 if (!(BN_get_flags(a,BN_FLG_STATIC_DATA))) 220 free(a->d);
221 free(a->d);
222 } 221 }
223 i=BN_get_flags(a,BN_FLG_MALLOCED); 222 i=BN_get_flags(a,BN_FLG_MALLOCED);
224 OPENSSL_cleanse(a,sizeof(BIGNUM)); 223 OPENSSL_cleanse(a,sizeof(BIGNUM));