How to generate DSA 512 bit KeyPair in VC++ 2010
-
Hi to all, I am able to generate DSA 512 bit KeyPair using crypto++ using the following code
bool CreateDSAKeys() { CryptoPP::AutoSeededX917RNG<CryptoPP::AES> prng; try { CryptoPP::GDSA<CryptoPP::SHA1>::GroupParameters pqg; pqg.GenerateRandom (prng, CryptoPP::MakeParameters(CryptoPP::Name::ModulusSize (), 512)(CryptoPP::Name::SubgroupOrderSize (), 160)); OutputData(output, "P ", pqg.GetModulus (), pqg.GetModulus ().ByteCount ()); OutputData(output, "Q ", pqg.GetSubgroupOrder(), pqg.GetSubgroupOrder ().ByteCount ()); OutputData(output, "G ", pqg.GetSubgroupGenerator(), pqg.GetSubgroupGenerator ().ByteCount ()); CryptoPP::GDSA<CryptoPP::SHA1>::Signer priv; priv.AccessKey().GenerateRandom(prng, pqg);//CryptoPP::MakeParameters(CryptoPP::Name::ModulusSize (), 512) /*CryptoPP::MakeParameters(CryptoPP::Name::ModulusSize(), 512)*/); DSA::Verifier pub(priv); OutputData(output, "X ", priv.GetKey().GetPrivateExponent(), priv.GetKey().GetPrivateExponent().ByteCount ()); OutputData(output, "Y ", pub.GetKey().GetPublicElement(), pub.GetKey().GetPublicElement().ByteCount ()); } }
But, The length of the PrivateKey x Parameter and the length of the Q parameter are not equal and the values of group parameters are also not constant. can any one suggest me a way to solve this problem. Thanks in advance.