我正在使用BouncyCastle来读取RSA私钥,我想从私钥中获取指纹或唯一密钥ID。
下面是代码
using (Stream stream = new MemoryStream(privateKey))
{
using (var reader = new StreamReader(stream))
{
RsaPrivateCrtKeyParameters rsaPrivatekey;
if (!string.IsNullOrEmpty(passPhrase))
{
var privateKeyObject = new PemReader(reader, new PasswordFinder(passPhrase)).ReadObject();
rsaPrivatekey = (RsaPrivateCrtKeyParameters) privateKeyObject;
}
else
{
var privateKeyObject = new PemReader(reader).ReadObject();
rsaPrivatekey = (RsaPrivateCrtKeyParameters) privateKeyObject;
}
/*here I want to get the Key Id or Fingerprint using
rsaPrivatekey object*/
}
}