summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eccrypto.cpp10
-rw-r--r--validat2.cpp6
2 files changed, 10 insertions, 6 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;
}
diff --git a/validat2.cpp b/validat2.cpp
index aba5d6c..b9ed716 100644
--- a/validat2.cpp
+++ b/validat2.cpp
@@ -658,10 +658,10 @@ bool ValidateEC2N()
#if 0 // TODO: turn this back on when I make EC2N faster for pentanomial basis
cout << "Testing SEC 2 recommended curves..." << endl;
OID oid;
- while (!(oid = ECParameters<EC2N>::GetNextRecommendedParametersOID(oid)).m_values.empty())
+ while (!(oid = DL_GroupParameters_EC<EC2N>::GetNextRecommendedParametersOID(oid)).m_values.empty())
{
- ECParameters<EC2N> params(oid);
- bool fail = !params.ValidateParameters(GlobalRNG());
+ DL_GroupParameters_EC<EC2N> params(oid);
+ bool fail = !params.Validate(GlobalRNG(), 2);
cout << (fail ? "FAILED" : "passed") << " " << params.GetCurve().GetField().MaxElementBitLength() << " bits" << endl;
pass = pass && !fail;
}