Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Digital Signature Verification using Certificate data in C#.
 

Digital Signature Verification using Certificate data in C#.

Hi All,

I have a problem in verifying a Digital signature of a small piece of data in C#.NET. Actually i have an XML file that contains the data, Certificate details which can yield Public key and the Signed data. This xml file was created using the Bouncycastle cryptographic implementations in Java. Now Using the Public key in the certificate I have to verify the signature of data in the xml file. The algorithm used by me to sign in Java is SHA1withRSA. But I get an error when I try to assign the public key value to the RSA Key. I dont have much idea on how to use the certificate to verify the sign. Could anyone please give me some links or suggestion how could I proceed on it? I have been breaking my head for 3 days now, It would be of great help to me.

Thanks & Regards,
Maveric
maveric_sam  Tuesday, April 15, 2008 4:03 PM

Here is what I am using to do this in a SAML Single Sign On processing application. It may give you some ideas:

nodeSignature = objXMLDoc.SelectSingleNode("//saml:Assertion//dsTongue Tiedignature", mgr);

if (strCertificate.Length > 0 && File.Exists(strCertificate))
{
X509Certificate objCert = X509Certificate.CreateFromCertFile(strCertificate);
SignedXml objVerifier = new SignedXml(objXMLDoc);

objVerifier.LoadXml((XmlElement)nodeSignature);
KeyInfo key = new KeyInfo();
key.AddClause(new KeyInfoX509Data(objCert));
objVerifier.KeyInfo = key;
if (!objVerifier.CheckSignature())
{

//Do whatever
}

}

Lastbuilders

Lastbuilders  Tuesday, April 22, 2008 1:03 PM

I am facing issues on signature verification by using string. The following code always returns false. Kindly help me outor suggest some implementation..... Sad thanks in advance

string idpSigningCert = "Certificate string copied from OIF metadata";

byte[] certData = Encoding.Default.GetBytes(idpSigningCert);

X509Certificate2 cert = new X509Certificate2(certData);

RSACryptoServiceProvider csp = (RSACryptoServiceProvider)cert.PublicKey.Key;

SHA1Managed sha1 = new SHA1Managed();

UnicodeEncoding encoding = new UnicodeEncoding();

string text = "SamlResponse from Querystring";

string base64signature ="Response signature from querystring";

byte[] hash = sha1.ComputeHash(text);

// Verify the signature with the hash

isSignatureVerified = csp.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA1"), Convert.FromBase64String(base64signature));

Damodaran R  Tuesday, September 02, 2008 9:53 AM

You can use google to search for other answers

Custom Search

More Threads

• Visual studio designer host fails to serialize component when custom component designer inserts code into code view
• How do I reference a control's properties?
• Abstract Base Class
• Textbox and margin
• VB.NET 2005 *ERROR* DESIGNER LOADER DID NOT PROVIDE ROOT COMPONENT
• Is there a "Fix tab order" mechanism in Visual Studio?
• Forms Designer and GetDC() vs. GetWindowDC()
• Form Size
• ExtenderProvider
• Problem in checkBox........