Connecting Tech Pros Worldwide Help | Site Map

API is taking time ....

Newbie
 
Join Date: Jan 2009
Posts: 1
#1: Jan 29 '09
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... ?
Newbie
 
Join Date: Aug 2009
Posts: 5
#2: Sep 26 '09

re: API is taking time ....


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
Reply