On 22 Sep, 14:19, Robert Bielik <[email protected]>
wrote:
> I'm trying to extract the information needed in order to create a
> RSAParameter object in C# to be able to decrypt a message encrypted with
> Crypto++.
>
> How do I extract the RSAParameters via the NameValuePair object (of
> RSA::PrivateKey) ??
Actually I don't have to. Here's a short how to:
1. Save the Crypto++ (CryptoPP::RSA::PrivateKey) private key through:
std::string my_private_key;
privateKey.Save(Base64Encoder(new StringSink(my_private_key),
true));
Copy the value of my_private_key to C# code
2. Use the C# code from
http://www.codeproject.com/KB/security/CryptoInteropKeys.aspx
to create a RSAParameters struct:
First add following constructor to AsnKeyParser:
internal AsnKeyParser(byte[] keydata)
{
parser = new AsnParser(keydata);
}
Then you can:
const String my_private_key = "..."; // Copied from step 1
byte[] rawKeyData = Convert.FromBase64String(my_private_key);
AsnKeyParser keyParser = new AsnKeyParser(rawKeyData);
RSAParameters privParams = keyParser.ParseRSAPrivateKey();
Then use RSAParameters as shown in
http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.aspx
That's it :)
Regards,
/Rob
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.