hl3*_*kel 6 c# rsa digital-signature
有谁知道RSACryptoServiceProvider.SignHash使用哪种签名算法?我相信它是 RSAPKCS1,它仍然安全吗?
有没有人有将 RSASSA-PSS 配置为 RSACryptoServiceProvider 的签名算法而不使用像 BouncyCastle 这样的第三方库的想法?
提前致谢。
RSACryptoServiceProvider只能做PKCS-1签名。
在 .NET 4.6 中,RSA 基类添加了一组新方法,其中添加了RSASignaturePadding参数。该类RSACng可以通过值进行 RSASSA-PSS RSASignaturePadding.Pss(PSS 与 MGF-1、MGF 摘要和 PSS 摘要都是消息摘要,盐大小是摘要大小)。
.NET 4.6 还为从证书获取密钥添加了更好的类型安全性,新方法很可能会返回 RSACng:
using (RSA privateKey = cert.GetRSAPrivateKey())
{
return privateKey.SignHash(hash, HashAlgorithmName.SHA256, RSASignaturePadding.Pss);
}
Run Code Online (Sandbox Code Playgroud)