本文整理汇总了C++中rsa::PrivateKey::GetPrivateExponent方法的典型用法代码示例。如果您正苦于以下问题:C++ PrivateKey::GetPrivateExponent方法的具体用法?C++ PrivateKey::GetPrivateExponent怎么用?C++ PrivateKey::GetPrivateExponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rsa::PrivateKey
的用法示例。
在下文中一共展示了PrivateKey::GetPrivateExponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintPrivateKey
void PrintPrivateKey(const RSA::PrivateKey& key)
{
cout << "n: " << key.GetModulus() << endl;
cout << "d: " << key.GetPrivateExponent() << endl;
cout << "e: " << key.GetPublicExponent() << endl;
cout << "p: " << key.GetPrime1() << endl;
cout << "q: " << key.GetPrime2() << endl;
}
示例2: printPrivateKey
static void printPrivateKey(RSA::PrivateKey key)
{
///////////////////////////////////////
// Generated Parameters
const Integer& n = key.GetModulus();
const Integer& p = key.GetPrime1();
const Integer& q = key.GetPrime2();
const Integer& d = key.GetPrivateExponent();
const Integer& e = key.GetPublicExponent();
cout << "RSA Parameters:" << endl;
cout << " n: " << n << endl;
cout << " p: " << p << endl;
cout << " q: " << q << endl;
cout << " d: " << d << endl;
cout << " e: " << e << endl;
cout << endl;
}
示例3: main
int main(int argc, char** argv)
{
std::ios_base::sync_with_stdio(false);
// http://www.cryptopp.com/docs/ref/class_auto_seeded_random_pool.html
AutoSeededRandomPool rnd;
try
{
// http://www.cryptopp.com/docs/ref/rsa_8h.html
RSA::PrivateKey rsaPrivate;
rsaPrivate.GenerateRandomWithKeySize(rnd, 1024);
RSA::PublicKey rsaPublic(rsaPrivate);
if(!rsaPrivate.Validate(rnd, 3)) {
throw runtime_error("Validation failed");
}
SavePrivateKey("rsa-private.key", rsaPrivate);
SavePublicKey("rsa-public.key", rsaPublic);
cout << "Successfully generated and saved RSA keys:" << endl;
cout << "Values:" << endl;
cout << "N: " << rsaPrivate.GetModulus() << endl;
cout << "E: " << rsaPrivate.GetPublicExponent() << endl;
cout << "D: " << rsaPrivate.GetPrivateExponent() << endl;
}
catch(CryptoPP::Exception& e)
{
cerr << e.what() << endl;
return -2;
}
catch(std::exception& e)
{
cerr << e.what() << endl;
return -1;
}
return 0;
}
示例4: pubkey
int
main(int argc, char ** argv)
{
if (argc != 2) {
cout << "Usage: keygen <outputname>" << endl;
return -1;
}
AutoSeededRandomPool rng;
InvertibleRSAFunction params;
params.GenerateRandomWithKeySize(rng, 3072);
RSA::PublicKey pubkey(params);
RSA::PrivateKey privkey(params);
Integer m = params.GetModulus();
Integer p = params.GetModulus();
Integer q = params.GetModulus();
Integer priv = params.GetPrivateExponent();
Integer pub = params.GetPublicExponent();
string privname = string(argv[1]).append(".priv");
string pubname = string(argv[1]).append(".pub");
CryptoEngine::pubkeyToFile(pubkey, pubname);
CryptoEngine::privkeyToFile(privkey, privname);
cout << "Loading and verifying..." << endl;
RSA::PrivateKey newpriv = CryptoEngine::privkeyFromFile(privname);
RSA::PublicKey newpub = CryptoEngine::pubkeyFromFile(pubname);
cout << (m == newpriv.GetModulus() ? "TRUE" : "FALSE") << endl;
cout << (priv == newpriv.GetPrivateExponent() ? "TRUE" : "FALSE") << endl;
cout << (pub == newpriv.GetPublicExponent() ? "TRUE" : "FALSE") << endl;
cout << (m == newpub.GetModulus() ? "TRUE" : "FALSE") << endl;
cout << (pub == newpub.GetPublicExponent() ? "TRUE" : "FALSE") << endl;
return 0;
}