Enabling KAE Encryption and Decryption
The following describes how to enable KAE encryption and decryption without modifying the existing service code.
- Modify the Java security configuration file.
- Open the $JAVA_HOME/jre/lib/security/java.security file.
1vi $JAVA_HOME/jre/lib/security/java.security
- Press i to enter the insert mode and comment out the following content:
1 2 3 4 5 6 7 8 9
security.provider.1=sun.security.provider.Sun security.provider.2=sun.security.rsa.SunRsaSign security.provider.3=sun.security.ec.SunEC security.provider.4=com.sun.net.ssl.internal.ssl.Provider security.provider.5=com.sun.crypto.provider.SunJCE security.provider.6=sun.security.jgss.SunProvider security.provider.7=com.sun.security.sasl.Provider security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI security.provider.9=sun.security.smartcardio.SunPCSC
Add the following content to add KAE Provider and set the highest priority for it:1 2 3 4 5 6 7 8 9 10 11
security.provider.1=org.openeuler.security.openssl.KAEProvider security.provider.2=sun.security.provider.Sun security.provider.3=sun.security.rsa.SunRsaSign security.provider.4=sun.security.ec.SunEC security.provider.5=com.sun.net.ssl.internal.ssl.Provider security.provider.6=com.sun.crypto.provider.SunJCE security.provider.7=sun.security.jgss.SunProvider security.provider.8=com.sun.security.sasl.Provider security.provider.9=org.jcp.xml.dsig.internal.dom.XMLDSigRI security.provider.10=sun.security.smartcardio.SunPCSC security.provider.11=sun.security.mscapi.SunMSCAPI
See the result:

- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Open the $JAVA_HOME/jre/lib/security/java.security file.
- Enable KAE encryption and decryption based on the KAE Provider feature of the BiSheng JDK.
- Configure the KAE environment variables.
- Open the /etc/profile file.
1vi /etc/profile - Press i to enter the insert mode and add the following content to the file:
1export OPENSSL_ENGINES=/usr/local/lib/engines-1.1
- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Make the configuration take effect.
1source /etc/profile
- Open the /etc/profile file.
- Configure KAE Provider.
- Open the $JAVA_HOME/jre/lib/kaeprovider.conf file.
1vi $JAVA_HOME/jre/lib/kaeprovider.conf
- Press i to enter the insert mode and add the following content to enable RSA hardware-based acceleration:
1 2 3 4
kae.rsa=true kae.log=true kae.rsa.useKaeEngine=true kae.libcrypto.useGlobalMode=true
- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Open the $JAVA_HOME/jre/lib/kaeprovider.conf file.
- Configure the KAE environment variables.
- Build and start the Spring Boot web service.
- Open the /home/tomcat-test-01/src/main/resources/application.properties file.
1vi /home/tomcat-test-01/src/main/resources/application.properties - Press i to enter the insert mode and add the following SSL settings:
1 2 3 4 5 6 7 8
server.port=8443 # Specifies the port number to 8443. server.ssl.enabled=true # Enables the HTTPS protocol. server.ssl.key-store=classpath:server.p12 # Specifies the certificate path. server.ssl.key-store-type=PKCS12 # Specifies the certificate type. server.ssl.key-store-password=123456 # Specifies the certificate password. server.ssl.ciphers=ECDHE-RSA-AES256-GCM-SHA384 server.ssl.protocol=TLS server.ssl.enabled-protocols=TLSv1.2
- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Build an executable JAR file.
1 2
cd /home/tomcat-test-01 mvn clean package -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
- Start the Spring Boot web service.
1java -jar target/tomcat-test-01-0.0.1-SNAPSHOT.jar
- Open the /home/tomcat-test-01/src/main/resources/application.properties file.
- Verify that the KAE hardware-based acceleration is in use.
- Check KAE logs.
1 2
cd /home/tomcat-test-01 cat kae.log
If the log shows that KAE has been used, the KAE hardware-based acceleration is used by Tomcat successfully.

- Check KAE hardware queues.
1watch -d cat /sys/class/uacce/hisi_*/available_instances
Use a browser to access the IP address and port (HTTPS, port 8443) of the Tomcat server and check whether there are changes in the command output. If there are changes, Tomcat has used the KAE hardware-based acceleration.
After the IP address is accessed, the number of available instances in a hardware queue decreases from 256 to 255.

- Check KAE logs.
Parent topic: Using KAE Encryption and Decryption