summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_lib.c
diff options
context:
space:
mode:
authorderaadt <>2017-05-02 03:59:45 +0000
committerderaadt <>2017-05-02 03:59:45 +0000
commit2b561cb0e87f2ee535e8c64907883cd275ad3fec (patch)
treebb9d050c5c2984047e6475e087694d6764f24157 /src/lib/libcrypto/bn/bn_lib.c
parent024e2580a5280d4df3724dab76ce52e14fe2060c (diff)
downloadopenbsd-2b561cb0e87f2ee535e8c64907883cd275ad3fec.tar.gz
openbsd-2b561cb0e87f2ee535e8c64907883cd275ad3fec.tar.bz2
openbsd-2b561cb0e87f2ee535e8c64907883cd275ad3fec.zip
use freezero() instead of memset/explicit_bzero + free. Substantially
reduces conditional logic (-218, +82). MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH cache alignment calculation bn/bn_exp.c wasn'tt quite right. Two other tricky bits with ASN1_STRING_FLAG_NDEF and BN_FLG_STATIC_DATA where the condition cannot be collapsed completely. Passes regress. ok beck
Diffstat (limited to 'src/lib/libcrypto/bn/bn_lib.c')
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index f2736e31c3..8aeeb5304f 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_lib.c,v 1.37 2017/01/29 17:49:22 beck Exp $ */ 1/* $OpenBSD: bn_lib.c,v 1.38 2017/05/02 03:59:44 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -220,10 +220,8 @@ BN_clear_free(BIGNUM *a)
220 if (a == NULL) 220 if (a == NULL)
221 return; 221 return;
222 bn_check_top(a); 222 bn_check_top(a);
223 if (a->d != NULL && !(BN_get_flags(a, BN_FLG_STATIC_DATA))) { 223 if (a->d != NULL && !(BN_get_flags(a, BN_FLG_STATIC_DATA)))
224 explicit_bzero(a->d, a->dmax * sizeof(a->d[0])); 224 freezero(a->d, a->dmax * sizeof(a->d[0]));
225 free(a->d);
226 }
227 i = BN_get_flags(a, BN_FLG_MALLOCED); 225 i = BN_get_flags(a, BN_FLG_MALLOCED);
228 explicit_bzero(a, sizeof(BIGNUM)); 226 explicit_bzero(a, sizeof(BIGNUM));
229 if (i) 227 if (i)
@@ -393,10 +391,8 @@ bn_expand2(BIGNUM *b, int words)
393 BN_ULONG *a = bn_expand_internal(b, words); 391 BN_ULONG *a = bn_expand_internal(b, words);
394 if (!a) 392 if (!a)
395 return NULL; 393 return NULL;
396 if (b->d) { 394 if (b->d)
397 explicit_bzero(b->d, b->dmax * sizeof(b->d[0])); 395 freezero(b->d, b->dmax * sizeof(b->d[0]));
398 free(b->d);
399 }
400 b->d = a; 396 b->d = a;
401 b->dmax = words; 397 b->dmax = words;
402 } 398 }