mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 07:27:23 +01:00
fixed GH #622: Crypto: RSATest::testSign() should verify with public key only
This commit is contained in:
parent
ccf0e78b6a
commit
c7e9067fde
@ -146,7 +146,7 @@ void RSATest::testSign()
|
||||
std::string pubKey = strPub.str();
|
||||
std::istringstream iPub(pubKey);
|
||||
RSAKey keyPub(&iPub);
|
||||
RSADigestEngine eng2(key);
|
||||
RSADigestEngine eng2(keyPub);
|
||||
eng2.update(msg.c_str(), static_cast<unsigned>(msg.length()));
|
||||
assert (eng2.verify(sig));
|
||||
}
|
||||
@ -156,7 +156,7 @@ void RSATest::testSignSha256()
|
||||
{
|
||||
std::string msg("Test this sign message");
|
||||
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
|
||||
RSADigestEngine eng(key,"SHA256");
|
||||
RSADigestEngine eng(key, "SHA256");
|
||||
eng.update(msg.c_str(), static_cast<unsigned>(msg.length()));
|
||||
const Poco::DigestEngine::Digest& sig = eng.signature();
|
||||
std::string hexDig = Poco::DigestEngine::digestToHex(sig);
|
||||
@ -167,7 +167,7 @@ void RSATest::testSignSha256()
|
||||
std::string pubKey = strPub.str();
|
||||
std::istringstream iPub(pubKey);
|
||||
RSAKey keyPub(&iPub);
|
||||
RSADigestEngine eng2(key,"SHA256");
|
||||
RSADigestEngine eng2(keyPub, "SHA256");
|
||||
eng2.update(msg.c_str(), static_cast<unsigned>(msg.length()));
|
||||
assert (eng2.verify(sig));
|
||||
}
|
||||
@ -189,7 +189,7 @@ void RSATest::testSignManipulated()
|
||||
std::string pubKey = strPub.str();
|
||||
std::istringstream iPub(pubKey);
|
||||
RSAKey keyPub(&iPub);
|
||||
RSADigestEngine eng2(key);
|
||||
RSADigestEngine eng2(keyPub);
|
||||
eng2.update(msgManip.c_str(), static_cast<unsigned>(msgManip.length()));
|
||||
assert (!eng2.verify(sig));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user