How can I encrypt my string data with SHA-256 padding instead of the default SHA-1 padding in Crypto++? I have not been able to find any way to change what padding algorithm my encryption/decryption functions use. I have heard of some libraries having hard-coded padding schemes, but I hope that there is a way to modify the one used by Crypto++.
Here is my encryption method:
string GUIMain::encryptData(const string data) {
CryptoPP::RSAES_OAEP_SHA_Encryptor e(*serverPublic);
string cipher;
CryptoPP::StringSource ss1(data, true, new CryptoPP::PK_EncryptorFilter(*rng, e, new CryptoPP::StringSink(cipher)));
return cipher;
}
Here is my decryption method:
string GUIMain::decryptData(const string cipher) {
CryptoPP::RSAES_OAEP_SHA_Decryptor d(*privateKey);
string recovered;
CryptoPP::StringSource ss2(cipher, true, new CryptoPP::PK_DecryptorFilter(*rng, d, new CryptoPP::StringSink(recovered)));
return recovered;
}
The keys (*serverPublic
and *privateKey
) are object types RSA::PublicKey
and RSA::PrivateKey
respectively. *rng
is an AutoSeededRandomPool
object.
Is there any way I could add to/change these methods to work correctly? I am new to C++, so please explain solutions if possible.