How to Install Java Bouncy Castle Security Provider
Bouncy Castle provides a lot of different security algorithms, but the usage is not well documented, so I will explain the basic steps to use it. First download library and then move it to your $JAVA_HOME
path:
wget https://www.bouncycastle.org/download/bcprov-jdk15on-154.jar
sudo mv ~/Downloads/bcprov-jdk15on-154.jar $JAVA_HOME/jre/lib/ext
There are two option to use it:
Option 1: static Installation
Now add the following line to your $JAVA_HOME/jre/lib/security/java.security
:
security.provider.N=org.bouncycastle.jce.provider.BouncyCastleProvider
Option 2: dynamic usage
You have to import the bouncy castle package and the security class and load the provider right before the usage (e.g. at the start of your main):
import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
//...
public static void main(String[] args){
Security.addProvider(new BouncyCastleProvider());
// your code...
}