summaryrefslogtreecommitdiff
path: root/eccrypto.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-09-24 02:54:22 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-09-24 02:54:22 +0000
commitd07b0dfa3658653cb9cbdbe5c7847a447b265093 (patch)
tree77922ce054f5882ecdd4f998dc9c9e505aff611d /eccrypto.cpp
parentba34a9607981a05a88f962302682415d2422986e (diff)
downloadcryptopp-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.cpp10
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;
}