summaryrefslogtreecommitdiff
path: root/xtrcrypt.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-01-29 04:58:56 -0500
committerJeffrey Walton <noloader@gmail.com>2017-01-29 04:58:56 -0500
commitb8adc91ce888b94505f383101ed3a2b06e4a70a2 (patch)
treeb544c3450f2216194ba7b5722c3fd07c7c44cbce /xtrcrypt.cpp
parent7c7e8aa8046ac6689f4a5468842e4333badebc6c (diff)
downloadcryptopp-git-b8adc91ce888b94505f383101ed3a2b06e4a70a2.tar.gz
Add asserts to validation routines
Diffstat (limited to 'xtrcrypt.cpp')
-rw-r--r--xtrcrypt.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/xtrcrypt.cpp b/xtrcrypt.cpp
index 7ffc5b41..aa106aa4 100644
--- a/xtrcrypt.cpp
+++ b/xtrcrypt.cpp
@@ -45,16 +45,26 @@ bool XTR_DH::Validate(RandomNumberGenerator &rng, unsigned int level) const
{
bool pass = true;
pass = pass && m_p > Integer::One() && m_p.IsOdd();
+ CRYPTOPP_ASSERT(pass);
pass = pass && m_q > Integer::One() && m_q.IsOdd();
+ CRYPTOPP_ASSERT(pass);
GFP2Element three = GFP2_ONB<ModularArithmetic>(m_p).ConvertIn(3);
+ CRYPTOPP_ASSERT(pass);
pass = pass && !(m_g.c1.IsNegative() || m_g.c2.IsNegative() || m_g.c1 >= m_p || m_g.c2 >= m_p || m_g == three);
+ CRYPTOPP_ASSERT(pass);
if (level >= 1)
+ {
pass = pass && ((m_p.Squared()-m_p+1)%m_q).IsZero();
+ CRYPTOPP_ASSERT(pass);
+ }
if (level >= 2)
{
pass = pass && VerifyPrime(rng, m_p, level-2) && VerifyPrime(rng, m_q, level-2);
+ CRYPTOPP_ASSERT(pass);
pass = pass && XTR_Exponentiate(m_g, (m_p.Squared()-m_p+1)/m_q, m_p) != three;
+ CRYPTOPP_ASSERT(pass);
pass = pass && XTR_Exponentiate(m_g, m_q, m_p) == three;
+ CRYPTOPP_ASSERT(pass);
}
return pass;
}