Reputation: 4914
I have 35 byte hash that needs to be signed. But when i try to sing it with SHA1
var rsa = new RSACryptoServiceProvider();
rsa.SignHash(hash, "SHA1");
i get error "bad hash" (obviously), because SHA1 digest size is 20.
Now is there any other hash algorithm besides SHA1 supported. for instace
rsa.SignHash(hash, "SHA224");
Upvotes: 0
Views: 2834
Reputation: 49647
I do not know any hash functions that has 35 bytes as output. SHA-224 is 28 bytes.
When using the SignHash()-method, the hash is signed using PKCS#1 v.1.5. Part of this signature is information specifying exactly which hash was used, so if your hash is not a SHA-1 hash, you should not attempt to sign it specifying SHA-1 (likewise with SHA-225)
If you want to sign your 35 byte hash, you might consider rehashing it with a supported hash-function:
rsa.SignData(hash, HashAlgorithm.Create("SHA256"));
And to answer your actual question: here is the list of supported hash algorithms in .NET 4.
Upvotes: 1