Browse DevX
Sign up for e-mail newsletters from DevX


Authenticate Your Data with PKI and Digital Signatures : Page 4

Utilize PKI and Digital Signatures to enables users to digitally sign documents, keeping others from modifying them and allowing you to validate user data. Marc D'Aoust demonstrates how with a sample application and all the code.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Validating a Signature
To validate the signature, reverse the procedure:
  1. Decrypt the secret key using the reviewer's Public Key data.
  2. Decrypt the stored digest using the secret key.
  3. Regenerate the digest value from the saved document.
  4. Validate the digest by comparing the two values.

If the digest strings are identical, then the data was not compromised and you can prove—with reasonable certainty—that the reviewer did indeed read and approve the data.

To make this work, retrieve the Pubic Key of the user who signed that data. (The user's identity is stored in the Document table in the DocReviewer field. The user's Public Key information is then retrieved from the KeyData field of the User table.) Here again the RSA provider has a function to help you:

'Validate the signature using 'the Reviewer's public key data objRSAProvider = New RSACryptoServiceProvider() objRSAProvider.FromXmlString(strPublicKeyData) arStoredSignature = StringToByteArray(strSignature) If objRSAProvider.VerifyData(arDocText, "MD5", _ arStoredSignature) Then MsgBox("Document is valid!", _ MsgBoxStyle.Exclamation, "Valid") Else MsgBox("Document is NOT valid!", _ MsgBoxStyle.Critical, "Not Valid") End If

The VerifyData() function accepts the data, algorithm name, and signature value and returns a Boolean indicating success or failure.

Use What You've Learned
Now that you have gained a better understanding of Public Key Infrastructures and Digital Signatures, you can use them in real-life applications. Of course, commercial applications use a more complicated and robust approach in their PKI implementations. If you're interested in learning more about cryptography and PKI, a good place to start is the RSA Labs Web site. It contains several documents explaining how the keys and signatures are generated.

Marc D'Aoust is vice president of research and development for OSTnet OpenSource Technologies Inc., a Montreal, Quebec (Canada)-based company that develops tools to enable software reuse. to reach him by e-mail.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date