diff options
| author | miod <> | 2014-05-23 16:11:55 +0000 |
|---|---|---|
| committer | miod <> | 2014-05-23 16:11:55 +0000 |
| commit | 04f2b078b684bd01343fc13fa9f2e0e8f9556497 (patch) | |
| tree | fdb00013257208a983266fe45982cfcc5c4550f4 /src/lib/libcrypto/bn/bn_exp.c | |
| parent | 873964a7a3b7aa523730afa81d042448a78768c7 (diff) | |
| download | openbsd-04f2b078b684bd01343fc13fa9f2e0e8f9556497.tar.gz openbsd-04f2b078b684bd01343fc13fa9f2e0e8f9556497.tar.bz2 openbsd-04f2b078b684bd01343fc13fa9f2e0e8f9556497.zip | |
Replace (sometimes conditional) use of alloca with malloc, and clearing
through volatile pointers with explicit_bzero().
ok beck@ jsing@
Diffstat (limited to 'src/lib/libcrypto/bn/bn_exp.c')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_exp.c | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c index 5d9263e01e..a27373c97b 100644 --- a/src/lib/libcrypto/bn/bn_exp.c +++ b/src/lib/libcrypto/bn/bn_exp.c | |||
| @@ -114,11 +114,6 @@ | |||
| 114 | #include "bn_lcl.h" | 114 | #include "bn_lcl.h" |
| 115 | 115 | ||
| 116 | #include <stdlib.h> | 116 | #include <stdlib.h> |
| 117 | #if defined(__GNUC__) | ||
| 118 | # ifndef alloca | ||
| 119 | # define alloca(s) __builtin_alloca((s)) | ||
| 120 | # endif | ||
| 121 | #endif | ||
| 122 | 117 | ||
| 123 | /* maximum precomputation table size for *variable* sliding windows */ | 118 | /* maximum precomputation table size for *variable* sliding windows */ |
| 124 | #define TABLE_SIZE 32 | 119 | #define TABLE_SIZE 32 |
| @@ -632,12 +627,6 @@ BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | |||
| 632 | numPowers = 1 << window; | 627 | numPowers = 1 << window; |
| 633 | powerbufLen = sizeof(m->d[0]) * (top * numPowers + | 628 | powerbufLen = sizeof(m->d[0]) * (top * numPowers + |
| 634 | ((2*top) > numPowers ? (2*top) : numPowers)); | 629 | ((2*top) > numPowers ? (2*top) : numPowers)); |
| 635 | #ifdef alloca | ||
| 636 | if (powerbufLen < 3072) | ||
| 637 | powerbufFree = alloca(powerbufLen + | ||
| 638 | MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH); | ||
| 639 | else | ||
| 640 | #endif | ||
| 641 | if ((powerbufFree = (unsigned char*)malloc(powerbufLen + | 630 | if ((powerbufFree = (unsigned char*)malloc(powerbufLen + |
| 642 | MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL) | 631 | MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL) |
| 643 | goto err; | 632 | goto err; |
| @@ -645,11 +634,6 @@ BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | |||
| 645 | powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree); | 634 | powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree); |
| 646 | memset(powerbuf, 0, powerbufLen); | 635 | memset(powerbuf, 0, powerbufLen); |
| 647 | 636 | ||
| 648 | #ifdef alloca | ||
| 649 | if (powerbufLen < 3072) | ||
| 650 | powerbufFree = NULL; | ||
| 651 | #endif | ||
| 652 | |||
| 653 | /* lay down tmp and am right after powers table */ | 637 | /* lay down tmp and am right after powers table */ |
| 654 | tmp.d = (BN_ULONG *)(powerbuf + sizeof(m->d[0]) * top * numPowers); | 638 | tmp.d = (BN_ULONG *)(powerbuf + sizeof(m->d[0]) * top * numPowers); |
| 655 | am.d = tmp.d + top; | 639 | am.d = tmp.d + top; |
