From b6937626b436acf871f7d87ae3ecafab56cf68c5 Mon Sep 17 00:00:00 2001 From: toddouska Date: Tue, 13 Sep 2016 17:01:50 -0700 Subject: [PATCH] don't require uneeded temp with WC_NO_CACHE_RESISTANT --- wolfcrypt/src/tfm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index c3da84b61..7079fb9f3 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -1061,7 +1061,11 @@ const wolfssl_word wc_off_on_addr[2] = */ static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y) { - fp_int R[3]; +#ifdef WC_NO_CACHE_RESISTANT + fp_int R[2]; +#else + fp_int R[3]; /* need a temp for cache resistance */ +#endif fp_digit buf, mp; int err, bitcnt, digidx, y; @@ -1072,7 +1076,9 @@ static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y) fp_init(&R[0]); fp_init(&R[1]); +#ifndef WC_NO_CACHE_RESISTANT fp_init(&R[2]); +#endif /* now we need R mod m */ fp_montgomery_calc_normalization (&R[0], P);