By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,484 Members | 1,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,484 IT Pros & Developers. It's quick & easy.

API is taking time ....

P: 1
I am trying to fetch public key from DSA certificate using .NET
cryptography API. It is taking 15 to 45 seconds.....
Expand|Select|Wrap|Line Numbers
  1.        String crtFileName = "C:\mycert.crt";
  2.  
  3.         X509Certificate2 x509 = new X509Certificate2();
  4.  
  5.         byte[] rawData = System.IO.File.ReadAllBytes(crtFileName);
  6.         x509.Import(rawData);
  7.  
  8.         // START
  9.         DateTime tm = DateTime.Now;
  10.         DSACryptoServiceProvider dsa1 = (DSACryptoServiceProvider)
  11. x509.PublicKey.Key; // TAKING 15 to 45 SECONDS
  12.         TimeSpan ts = DateTime.Now - tm ;
  13.         Console.WriteLine("Extract Public Key : " + ts.ToString
  14. ());
  15.         // END
  16.  
  17.         HashAlgorithm hashAlgo = HashAlgorithm.Create("SHA1");
  18.         byte[] hash = hashAlgo.ComputeHash(data_to_sign);
  19.         bool bVar = dsa1.VerifySignature(hash, signature);
  20.  
Help me to find why API is taking time... ?
Jan 29 '09 #1
Share this Question
Share on Google+
1 Reply


P: 5
Hi, try to do this:

X509Certificate2 cert = new X509Certificate2(crtFileName);
DSASignatureDeformatter deformatter = new DSASignatureDeformatter(cert.PublicKey.Key);
...
bool ok = deformatter.VerifySignature(hash, signature);

I tried with the RSA algorithm and it works well. I doesn't have DSA certificate and so I cannot try it. Are you sure your certificate is well done ... ?

If you need some RSA certificate to test you can create them at http://www.we-coffee.com/x509builder.aspx
Sep 26 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.