3

I am working on a c# signing application. At one point, a System.Security.Cryptography.SignatureDescription needs to be obtained. Does anyone know why description1 below contains a valid structure, while description2 is null? Changing from .Net3.5 to .Net4.5.1 did not help.

SignatureDescription description1 = CryptoConfig.CreateFromName("http://www.w3.org/2000/09/xmldsig#rsa-sha1") as SignatureDescription; SignatureDescription description2 = CryptoConfig.CreateFromName("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256") as SignatureDescription; 

It didn't work for SHA512 either. URIs obtained from here.

4
  • Create from name doesn't mean you need to enter a URL. Why should changing to .NET 4.5.1 yield another result (if that was true, .NET was very badly backwards compatible). Commented Jul 15, 2014 at 11:08
  • re .Net, I figured, however sometimes it doesn't harm to try. Regarding CreateFromName(), I tried using the URI because that works for SHA1. If there are any similar methods to create a SignatureDescription given a particular hashing algorithm, that would be fine. Commented Jul 15, 2014 at 11:43
  • Btw, one could pass "SHA1" or "SHA256" to CreateFromName(), however the SignatureDescription is not available then for either algorithms. So it seems the full URI is required to get the SignatureDescription. Commented Jul 15, 2014 at 12:35
  • I am now specifying the signature description strings myself. Once again, this is working for SHA1 but not for SHA256. Any thoughts? SignatureDescription desc = new SignatureDescription(); desc.DeformatterAlgorithm = "System.Security.Cryptography.RSAPKCS1SignatureDeformatter"; desc.DigestAlgorithm = "System.Security.Cryptography.SHA256CryptoServiceProvider"; desc.FormatterAlgorithm = "System.Security.Cryptography.RSAPKCS1SignatureFormatter"; desc.KeyAlgorithm = "System.Security.Cryptography.RSACryptoServiceProvider"; HashAlgorithm hash = desc.CreateDigest(); Commented Jul 23, 2014 at 13:53

1 Answer 1

1

Apparently RSA-SHA256 is not supported in .Net 3.5. However there's a workaround which can be found here: http://social.msdn.microsoft.com/Forums/vstudio/en-US/6438011b-92fb-4123-a22f-ad071efddf85/xml-digital-signature-with-sha256-algorithm

Sign up to request clarification or add additional context in comments.

1 Comment

The workaround it says there is kinda odd. It calls CryptoConfig.AddAlgorithm which is not implemented in 3.5 but in 4.0... If you stick to 3.5 and follow that workaround you should consider Codeplex CryptoConfig2 otherwise it is unlikely you would get it working.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.