Sunday, August 3, 2014
In an earlier post here , we have shown you how to sign data and generate a digital signature in Java. Generating the signature alone does not provide security, you will also have to verify the digital signature. So according to that today I am going to show you how to verify a Digital Signature in Java. Here in our example we will show how you can do it once you are provided with the original dta, the public key (whose corresponding private key was used to sign the data) and finally the signature bytes that were generated earlier.
     In our previous article we have stored the public key in encided form in a file with an extension .pubkey and the signature bytes in a file with extension .dsa . So in order to verify first we will try to read the key bytes and pass them to X509EncodedKeySpec object. Then use the KeyFactory to reconstruct the public key. Next we have to create the Signature object with the same algorithm as earlier and initialize with the public key.

Total Pageviews

Followers


Labels

Popular Posts

free counters