I want to create a new instance of RSACng class but with a specified key pair.
var rsa = new RSACng();
The above will initialize a new instance of the RSACng class with a random 2,048-bit key pair.
However we can pass an instance of CngKey
while declaring RSACng.
var key = CngKey.Import(Convert.FromBase64String(_privateKey), CngKeyBlobFormat.Pkcs8PrivateBlob);
var rsa = new RSACng(key);
The above will initialize a CngKey
object with the particular private key (the private key was obtained from a PEM file, pkcs8 format)
But this only initializes the RSACng object with private key.
How can I initialize it with the key pair (both in PEM files) ?