I want to sign a text file (may be a .exe file or something else in the future)
using PKCS#7 and verify the signature using Java.
- What do I need to know?
- Where will I find an API (
.jarand documentation)? - What are the steps I need to follow in order to sign data and verify the data?
Please provide me code snippet if possible.
I reckon you need the following 2 Bouncy Castle jars to generate the PKCS7 digital signature:
bcprov-jdk15on-147.jar (for JDK 1.5 – JDK 1.7)
bcmail-jdk15on-147.jar (for JDK 1.5 – JDK 1.7)
You can download the Bouncy Castle jars from here.
You need to setup your keystore with the public & private key pair.
You need only the private key to generate the digital signature & the public key to verify it.
Here’s how you’d pkcs7 sign content (Exception handling omitted for brevity) :