diff options
author | weidai <weidai11@users.noreply.github.com> | 2007-09-24 02:54:22 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2007-09-24 02:54:22 +0000 |
commit | 8edb9adc83b32bf635967d7b3f196382158cf1f0 (patch) | |
tree | 77922ce054f5882ecdd4f998dc9c9e505aff611d /eccrypto.cpp | |
parent | 800bd3ad85a9bfc6f4a725768f520e52d771578b (diff) | |
download | cryptopp-git-8edb9adc83b32bf635967d7b3f196382158cf1f0.tar.gz |
update CheckMOVCondition() according to http://eprint.iacr.org/2007/343
Diffstat (limited to 'eccrypto.cpp')
-rw-r--r-- | eccrypto.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/eccrypto.cpp b/eccrypto.cpp index 91ec54f1..f0ff9eeb 100644 --- a/eccrypto.cpp +++ b/eccrypto.cpp @@ -46,12 +46,16 @@ static inline Integer ConvertToInteger(const Integer &x) static bool CheckMOVCondition(const Integer &q, const Integer &r) { - Integer t=1; - unsigned int n=q.BitCount(), m=r.BitCount(); + // see "Updated standards for validating elliptic curves", http://eprint.iacr.org/2007/343 + Integer t = 1; + unsigned int n = q.IsEven() ? 1 : q.BitCount(), m = r.BitCount(); for (unsigned int i=n; DiscreteLogWorkFactor(i)<m/2; i+=n) { - t = (t*q)%r; + if (q.IsEven()) + t = (t+t)%r; + else + t = (t*q)%r; if (t == 1) return false; } |