mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2025-02-11 15:55:19 +00:00
Add asserts to pubkey.h
This commit is contained in:
parent
8fa8ec9913
commit
66a6994e99
11
pubkey.h
11
pubkey.h
@ -770,7 +770,9 @@ public:
|
||||
if (m_validationLevel > level)
|
||||
return true;
|
||||
|
||||
CRYPTOPP_ASSERT(ValidateGroup(rng, level));
|
||||
bool pass = ValidateGroup(rng, level);
|
||||
CRYPTOPP_ASSERT(ValidateElement(level, GetSubgroupGenerator(), &GetBasePrecomputation()));
|
||||
pass = pass && ValidateElement(level, GetSubgroupGenerator(), &GetBasePrecomputation());
|
||||
|
||||
m_validationLevel = pass ? level+1 : 0;
|
||||
@ -1215,14 +1217,21 @@ public:
|
||||
// GeneratableCryptoMaterial
|
||||
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
|
||||
{
|
||||
CRYPTOPP_ASSERT(GetAbstractGroupParameters().Validate(rng, level));
|
||||
bool pass = GetAbstractGroupParameters().Validate(rng, level);
|
||||
|
||||
const Integer &q = GetAbstractGroupParameters().GetSubgroupOrder();
|
||||
const Integer &x = GetPrivateExponent();
|
||||
|
||||
CRYPTOPP_ASSERT(x.IsPositive());
|
||||
CRYPTOPP_ASSERT(x < q);
|
||||
pass = pass && x.IsPositive() && x < q;
|
||||
|
||||
if (level >= 1)
|
||||
{
|
||||
CRYPTOPP_ASSERT(Integer::Gcd(x, q) == Integer::One());
|
||||
pass = pass && Integer::Gcd(x, q) == Integer::One();
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
|
||||
@ -1305,7 +1314,9 @@ public:
|
||||
// CryptoMaterial
|
||||
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
|
||||
{
|
||||
CRYPTOPP_ASSERT(GetAbstractGroupParameters().Validate(rng, level));
|
||||
bool pass = GetAbstractGroupParameters().Validate(rng, level);
|
||||
CRYPTOPP_ASSERT(GetAbstractGroupParameters().ValidateElement(level, this->GetPublicElement(), &GetPublicPrecomputation()));
|
||||
pass = pass && GetAbstractGroupParameters().ValidateElement(level, this->GetPublicElement(), &GetPublicPrecomputation());
|
||||
return pass;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user