bool DL_GroupParameters_DSA::ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const { bool pass = DL_GroupParameters_GFP::ValidateGroup(rng, level); int pSize = GetModulus().BitCount(), qSize = GetSubgroupOrder().BitCount(); pass = pass && ((pSize==1024 && qSize==160) || (pSize==2048 && qSize==224) || (pSize==2048 && qSize==256) || (pSize==3072 && qSize==256)); return pass; }
bool DL_GroupParameters_DSA::ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const { bool pass = DL_GroupParameters_GFP::ValidateGroup(rng, level); pass = pass && DSA::IsValidPrimeLength(GetModulus().BitCount()); pass = pass && GetSubgroupOrder().BitCount() == 160; return pass; }
bool LRSPublicKey::Verify(const QByteArray &data, const LRSSignature &sig) const { if(!sig.IsValid()) { qDebug() << "Invalid signature"; return false; } if(sig.SignatureCount() != GetKeys().count()) { qDebug() << "Incorrect amount of keys used to generate signature."; return false; } CppHash hash; hash.Update(GetGroupGenerator().GetByteArray()); hash.Update(sig.GetTag().GetByteArray()); hash.Update(data); QByteArray precompute = hash.ComputeHash(); Integer tcommit = sig.GetCommit1(); QVector<Integer> keys = GetKeys(); for(int idx = 0; idx < keys.count(); idx++) { Integer z_p = (GetGenerator().Pow(sig.GetSignature(idx), GetModulus()) * _keys[idx].Pow(tcommit, GetModulus())) % GetModulus(); Integer z_pp = (GetGroupGenerator().Pow(sig.GetSignature(idx), GetModulus()) * sig.GetTag().Pow(tcommit, GetModulus())) % GetModulus(); hash.Update(precompute); hash.Update(z_p.GetByteArray()); hash.Update(z_pp.GetByteArray()); tcommit = Integer(hash.ComputeHash()) % GetSubgroup(); } return tcommit == sig.GetCommit1(); }
void LFSR::Show(OStream& out /*=DefaultOStream*/) const { out << "LFSR Modulus: " << GetModulus() << " - Grad: " << GetDegree() << endl; out << " Polynom: " << GetPolynomial() << endl; out << " Zustand: " << GetCurrentState() << endl; if (out[OStream::Details]) { out << "["; LFSR lfsr=*this; for (int i=0;i<20;i++) out << lfsr.next() << sep; out << "]" << endl; } }
bool LRSPublicKey::operator==(const AsymmetricKey &key) const { const LRSPublicKey *other = dynamic_cast<const LRSPublicKey *>(&key); if(!other) { return false; } if(this == other) { return true; } return (other->GetGenerator() == GetGenerator()) && (other->GetKeys() == GetKeys()) && (other->GetModulus() == GetModulus()) && (other->GetSubgroup() == GetSubgroup()) && (other->GetLinkageContext() == GetLinkageContext()) && (other->IsValid() == IsValid()); }
void DL_GroupParameters_LUC::SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const { for (unsigned int i=0; i<exponentsCount; i++) results[i] = Lucas(exponents[i], base, GetModulus()); }
int CppRsaPublicKeyImpl::GetKeySize() const { return GetModulus().GetBitCount(); }