I have two AssymetricAlgorithm
RSA keys that I have pulled out of a certificate that was in my keystore. One is the Public Key and the other the Private. Is there a way of getting this keypair into a BouncyCastle AsymmetricCipherKeyPair? BouncyCastle's AsymmetricCipherKeyPair
expects a public and private AsymmetricKeyParameter
however I have no way of getting my Private key without it being an instance of AssymetricAlgorithm
.
Asked
Active
Viewed 1.3k times
0

Petey B
- 11,439
- 25
- 81
- 101
-
see http://stackoverflow.com/questions/3240222/get-private-key-from-bouncycastle-x509-certificate-c for answer. – Petey B Jul 14 '10 at 13:50
2 Answers
1
The answer to this lies here:
-
I suspect a better answer lies in the Org.BouncyCastle.Security.DotNetUtilities class – President James K. Polk Jul 15 '10 at 03:23
1
I think this will help if key is marked as exportable
RSACryptoServiceProvider key = (RSACryptoServiceProvider)X509Certificate2object.PrivateKey;
RSAParameters rsaparam = key.ExportParameters(true);
AsymmetricCipherKeyPair keypair = DotNetUtilities.GetRsaKeyPair(rsaparam);

Prashanth
- 507
- 5
- 25