API is taking time ....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anujkgarg
    New Member
    • Jan 2009
    • 1

    #1

    API is taking time ....

    I am trying to fetch public key from DSA certificate using .NET
    cryptography API. It is taking 15 to 45 seconds.....
    Code:
           String crtFileName = "C:\mycert.crt";
    
            X509Certificate2 x509 = new X509Certificate2();
    
            byte[] rawData = System.IO.File.ReadAllBytes(crtFileName);
            x509.Import(rawData);
    
            // START
            DateTime tm = DateTime.Now;
            DSACryptoServiceProvider dsa1 = (DSACryptoServiceProvider)
    x509.PublicKey.Key; // TAKING 15 to 45 SECONDS
            TimeSpan ts = DateTime.Now - tm ;
            Console.WriteLine("Extract Public Key : " + ts.ToString
    ());
            // END
    
            HashAlgorithm hashAlgo = HashAlgorithm.Create("SHA1");
            byte[] hash = hashAlgo.ComputeHash(data_to_sign);
            bool bVar = dsa1.VerifySignature(hash, signature);
    Help me to find why API is taking time... ?
    Last edited by Frinavale; Feb 4 '09, 05:32 PM. Reason: added [code] tags
  • conseguenza
    New Member
    • Aug 2009
    • 5

    #2
    Hi, try to do this:

    X509Certificate 2 cert = new X509Certificate 2(crtFileName);
    DSASignatureDef ormatter deformatter = new DSASignatureDef ormatter(cert.P ublicKey.Key);
    ...
    bool ok = deformatter.Ver ifySignature(ha sh, 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

    Comment

    Working...