Why are digital signature algorithms in .NET restricted to using only platform implemented hash algorithms?

74 views Asked by At

The following C# code generates an ECDsa signature:

using ECDsa algorithm = ECDsa.Create();
byte[] data = Encoding.Default.GetBytes("Hello, World!");
byte[] signature = algorithm.SignData(data, HashAlgorithmName.SHA256);

The following C# code generates an RSA signature:

using RSA algorithm = RSA.Create();
byte[] data = Encoding.Default.GetBytes("Hello, World!");
byte[] signature = algorithm.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pss);

In both cases, I'm forced to pass in HashAlgorithmName (rather than just HashAlgorithm) to generate a signature:

There are no method overloads that allow me to pass in HashAlgorithm, therefore this seems like a limiting factor as I'm only able to use hash algorithms provided by .NET and unable to use other hash algorithms when signing data.

What is the reason for this?

0

There are 0 answers