RSASSA-PSS in C#

后端 未结 1 1377
北荒
北荒 2021-01-18 19:36

Does anyone know which signature algorithm is used for RSACryptoServiceProvider.SignHash? I believe it is RSAPKCS1, is that still secure?

Does anyone have an idea of

1条回答
  •  暖寄归人
    2021-01-18 20:09

    RSACryptoServiceProvider can only do PKCS-1 signatures.

    In .NET 4.6 a new set of methods was added on the RSA base class which added an RSASignaturePadding parameter. The RSACng class can do RSASSA-PSS via the RSASignaturePadding.Pss value (PSS with MGF-1, MGF digest and PSS digest are both the message digest, and the salt size is the digest size).

    .NET 4.6 also added better type-safety to getting keys from certificates, and the new approaches will most likely return RSACng:

    using (RSA privateKey = cert.GetRSAPrivateKey())
    {
        return privateKey.SignHash(hash, HashAlgorithmName.SHA256, RSASignaturePadding.Pss);
    }
    

    0 讨论(0)
提交回复
热议问题