diff options
author | Kevin B Kenny <kennykb@acm.org> | 2005-04-10 23:54:55 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2005-04-10 23:54:55 (GMT) |
commit | d2b645df1ab7b43093f7553808c64fedaa3b3a49 (patch) | |
tree | 99103342350cd1fb4776a60684221ad722fdec52 /libtommath/bn_mp_exptmod.c | |
parent | b9cf65a08e6a59e434685e894e3189c201ac6791 (diff) | |
download | tcl-d2b645df1ab7b43093f7553808c64fedaa3b3a49.zip tcl-d2b645df1ab7b43093f7553808c64fedaa3b3a49.tar.gz tcl-d2b645df1ab7b43093f7553808c64fedaa3b3a49.tar.bz2 |
Import of tommath 0.35
Diffstat (limited to 'libtommath/bn_mp_exptmod.c')
-rw-r--r-- | libtommath/bn_mp_exptmod.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libtommath/bn_mp_exptmod.c b/libtommath/bn_mp_exptmod.c index 7309170..7c4e2f8 100644 --- a/libtommath/bn_mp_exptmod.c +++ b/libtommath/bn_mp_exptmod.c @@ -65,21 +65,29 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y) #endif } +/* modified diminished radix reduction */ +#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) + if (mp_reduce_is_2k_l(P) == MP_YES) { + return s_mp_exptmod(G, X, P, Y, 1); + } +#endif + #ifdef BN_MP_DR_IS_MODULUS_C /* is it a DR modulus? */ dr = mp_dr_is_modulus(P); #else + /* default to no */ dr = 0; #endif #ifdef BN_MP_REDUCE_IS_2K_C - /* if not, is it a uDR modulus? */ + /* if not, is it a unrestricted DR modulus? */ if (dr == 0) { dr = mp_reduce_is_2k(P) << 1; } #endif - /* if the modulus is odd or dr != 0 use the fast method */ + /* if the modulus is odd or dr != 0 use the montgomery method */ #ifdef BN_MP_EXPTMOD_FAST_C if (mp_isodd (P) == 1 || dr != 0) { return mp_exptmod_fast (G, X, P, Y, dr); @@ -87,7 +95,7 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y) #endif #ifdef BN_S_MP_EXPTMOD_C /* otherwise use the generic Barrett reduction technique */ - return s_mp_exptmod (G, X, P, Y); + return s_mp_exptmod (G, X, P, Y, 0); #else /* no exptmod for evens */ return MP_VAL; |