Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Authenticate Your Data with PKI and Digital Signatures : Page 2

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.


advertisement
The First Step in PKI and Signatures: A Key Pair
To use an asymmetric algorithm you first have to generate a key pair. The first key is the public key, which is published to a key server so it can be shared. The other key is the private key. It is stored locally and kept confidential. To communicate securely with someone, you retrieve the recipient's public key from a key server and use it to encrypt the data you're sending. Only a person with knowledge of the private key can decrypt the data. With this scheme, as long as the private key is kept confidential, no one can read a message meant for someone else.

This scheme, however, is not optimal. Asymmetric algorithms are slow. To speed things up, you need to minimize the length of the data that the asymmetric algorithm processes. You can first encrypt the data using a symmetric algorithm and then encrypt the secret key you used using an asymmetric algorithm and the recipient's public key. This way, only the intended recipient can read the secret key and decrypt the data.

While they can be used for encryption, asymmetric algorithms are manly used in PKIs to generate signatures. Signatures are used to authenticate the origin of a message and to ensure that no one has tampered with the data in the message. Here's how it works.



When a person is ready to send data, the person:

  1. Generates a digest (a unique string) from the data using a hash algorithm. (Hash algorithms apply mathematical manipulations to the data to extrapolate the digest and are extremely difficult to reverse. Common hash algorithms include SHA-1 and MD5.)
  2. Encrypts the digest using a symmetric algorithm and a randomly generated secret key.
  3. Encrypts the secret key using an asymmetric algorithm and the sender's private key and appends it to the encrypted digest.
  4. Attaches the signature to the data and sends it off.

To validate the message, the recipient retrieves the sender's public key from a common key server and reverses the process:

  1. Decrypts the secret key.
  2. Uses it to decrypt the message digest.
  3. Regenerates the digest from the message data.
  4. Compares the regenerated digest and the decrypted one. If they don't match, the data was either tampered with or it was encrypted by someone other then the sender. Either way the information in the message can be discarded as invalid.


Comment and Contribute

 

 

 

 

 


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

 

 

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