[botan-devel] java rsa decrypt botan

Timothy Prepscius timprepscius at gmail.com
Wed Jul 25 16:01:55 EDT 2012


For the search engines: (decrypt rsa cipher java botan)

If you are decrypting java RSA, you probably are going to do this:

(unless you declared a different padding within the getCipher method…. I think...)


Block CryptorRSA::decryptRSABlock (const Block &bytes) throw (CryptoException)
{
//	std::string paddingFunction = "EME1(SHA-1)"; // nope
//	std::string paddingFunction = "EME1(SHA-256)"; // nope
	std::string paddingFunction = "EME-PKCS1-v1_5"; // yes

	AutoSeeded_RNG rng;
	Botan::RSA_PrivateKey *rsaPrivateKey = (Botan::RSA_PrivateKey *)privateKeyImpl;
	std::auto_ptr<Botan::PK_Decryptor> dec(Botan::get_pk_decryptor(*rsaPrivateKey, paddingFunction));
	Botan::SecureVector<Botan::byte> decrypted = dec->decrypt((const unsigned char *)bytes.data(), bytes.size());	

	Block out;
	out.assign(decrypted.begin(), decrypted.end());
	return out;
}


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20120725/81654181/attachment.html>


More information about the botan-devel mailing list