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;
}
コード例 #2
0
ファイル: gfpcrypt.cpp プロジェクト: axxapp/winxgui
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;
}
コード例 #3
0
ファイル: LRSPublicKey.cpp プロジェクト: ranzhao1/Dissent-1
  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();
  }
コード例 #4
0
ファイル: LFSR.CPP プロジェクト: flomar/CrypTool-VS2015
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;
	}
}
コード例 #5
0
ファイル: LRSPublicKey.cpp プロジェクト: ranzhao1/Dissent-1
  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());
  }
コード例 #6
0
ファイル: luc.cpp プロジェクト: someone9388/cryptopp
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());
}
コード例 #7
0
 int CppRsaPublicKeyImpl::GetKeySize() const
 {
   return GetModulus().GetBitCount();
 }