diff options
author | Andy Polyakov <appro@openssl.org> | 2011-08-27 19:38:55 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2011-08-27 19:38:55 +0000 |
commit | cfdbff23ab4788fc49180b0b92404f7c986af01c (patch) | |
tree | e0f04d675c2c9e3b4e3c9531109c5b209f288b92 /crypto | |
parent | f7eb0ab9acf176519195576d7a7ff5b4e414eda7 (diff) | |
download | openssl-cfdbff23ab4788fc49180b0b92404f7c986af01c.tar.gz |
bn_exp.c: improve portability.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bn/bn_exp.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c index 5b00aa1e3c..aae00491db 100644 --- a/crypto/bn/bn_exp.c +++ b/crypto/bn/bn_exp.c @@ -654,16 +654,21 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, numPowers = 1 << window; powerbufLen = sizeof(m->d[0])*(top*numPowers + (top>numPowers?top:numPowers)); +#ifdef alloca if (powerbufLen < 3072) powerbufFree = alloca(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH); - else if ((powerbufFree=(unsigned char*)OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL) + else +#endif + if ((powerbufFree=(unsigned char*)OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL) goto err; powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree); memset(powerbuf, 0, powerbufLen); +#ifdef alloca if (powerbufLen < 3072) powerbufFree = NULL; +#endif computeTemp.d = (BN_ULONG *)(powerbuf + sizeof(m->d[0])*top*numPowers); computeTemp.top = computeTemp.dmax = top; |