473,322 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how to verify signed data in .NET2.0?

2
Hi

My client has signed the xml in Java using private key & IAIK tool. I want to decrypt/verify the data in .NET 2.0. I have public certificate of my client. I have tried various methods but verification fails. Kindly suggest any code to verify/decrypt the data. The signed XML is as follows

Expand|Select|Wrap|Line Numbers
  1. <TrnResponse>
  2.  <Transaction>
  3.   <Type>TrnResponse</MessageType>
  4.   <ReferenceNo>123456</ReferenceNo>
  5.   <ClientName>ABCDI</ClientName>
  6.   <TReferenceNo>111111</CTReferenceNo>
  7.   <Mode>05</Mode>
  8.   <Status>SUCCESSFUL</Status>
  9.   <TRXDateTime>06-03-2012 13:16:21</TRXDateTime>
  10.   <TRXID>001111222</TRXID>
  11.   </Transaction>
  12.  <Signature>  <SignatureValue>MIAGCSqGSIb3DQEHAqCAMIIHlwIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcB</SignatureValue>
  13.   </Signature>
  14. </TrnResponse>
i am trying following code to verify

Expand|Select|Wrap|Line Numbers
  1. XmlDocument Doc = new XmlDocument();
  2.         Doc.PreserveWhitespace = false;
  3.         Doc.Load(@"d:\data.xml");
  4.         SignedXml signedXml = new SignedXml(Doc);
  5.         XmlNodeList nodeList = Doc.GetElementsByTagName("Signature");
  6.  
  7.         X509Certificate2 cert = GetRecipientCert(); // method returns public certificate
  8.         RSACryptoServiceProvider csp = (RSACryptoServiceProvider)cert.PublicKey.Key;
  9.  
  10.         string publickey = cert.PublicKey.Key.ToXmlString(false);
  11.  
  12.         XmlNodeList xn1 = Doc.GetElementsByTagName("Transaction");
  13.         string license_code = xn1.Item(0).OuterXml.ToString();
  14.         ASCIIEncoding ByteConverter = new ASCIIEncoding();
  15.         byte[] verify_this = ByteConverter.GetBytes(license_code);
  16.         string base64_encoded_signature = Doc.GetElementsByTagName("SignatureValue").Item(0).InnerText;
  17.         byte[] signature = Convert.FromBase64String(base64_encoded_signature);
  18.         bool ok = csp.VerifyData(verify_this, new SHA1CryptoServiceProvider(), signature);
Apr 4 '12 #1
0 1498

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

Similar topics

1
by: Marian Dvorsky | last post by:
There are two methods in RSACryptoServiceProvider to verify signed data: VerifyData(byte buffer, object halg, byte signature) VerifyHash(byte rgbHash, string str, byte rgbSignature) What is...
1
by: Chris Online | last post by:
Hi all, At the moment I'm using a Altera MAX and MAX+plus2 graphical design software. I'm using the following parts inside the altera: Octal flipflop 74HC273 AddressDecoder 74HC154 Octal Buffer...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
6
by: johnt | last post by:
i am looking for help on how to verify information in a form so that the following info has to be filled in before they click on submit. I am not an expert in java or html so any help would be...
2
by: Susan Bricker | last post by:
Greetings! Still the same application (as previous posts). I worked on the app while at work (don't tell my boss ... cause this is just for fun and not work related) and the form was working,...
5
by: rogsonl | last post by:
My computer was moved last week, and the company changed the network groups we work on. As a result, one of the main benefits from Whidbey (database connectivity) no longer works. Situation: 1....
0
by: jpr | last post by:
Hello, I need some help. I have a form named MASTER based on a table also called MASTER. A control of my form in names SSN which stores the client SSN. On the same form I have placed a subform...
4
by: Rahul | last post by:
What will be the result of ANDing an integer data item with a character data item? #include<stdio.h> int main() { int a = 0xFFFFFFFF; char c = 0xAA ; c &=a;
20
by: hippomedon | last post by:
Hello everyone, I'm looking for some advice on whether I should break the normalization rule. Normally, I would not consider it, but this seems to be a special case. I have created an...
1
by: sirfsaif | last post by:
I have three servers and each server has separate MySQL and DB. For instance I have common DB i.e. store on all the three servers i.e web1, web2 and web3. I m running a query in DB store on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.