diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2007-09-24 02:54:22 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2007-09-24 02:54:22 +0000 |
commit | d07b0dfa3658653cb9cbdbe5c7847a447b265093 (patch) | |
tree | 77922ce054f5882ecdd4f998dc9c9e505aff611d /eccrypto.cpp | |
parent | ba34a9607981a05a88f962302682415d2422986e (diff) | |
download | cryptopp-d07b0dfa3658653cb9cbdbe5c7847a447b265093.tar.gz |
update CheckMOVCondition() according to http://eprint.iacr.org/2007/343
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@402 57ff6487-cd31-0410-9ec3-f628ee90f5f0
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 91ec54f..f0ff9ee 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; } |