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 | 9c989aeec930a9251ba5eddc6a81898a5c91ee0e (patch) | |
tree | 8809a65920a763a8894572aee81a71eeff4b2c82 /libtommath/bn_mp_exptmod.c | |
parent | 2168824a1ddf134001dd68311befeb7d58dddd38 (diff) | |
download | tcl-9c989aeec930a9251ba5eddc6a81898a5c91ee0e.zip tcl-9c989aeec930a9251ba5eddc6a81898a5c91ee0e.tar.gz tcl-9c989aeec930a9251ba5eddc6a81898a5c91ee0e.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; |