Skip to content
Advertisement

How can I add support for PBEWithMD5AndTripleDES algorithm in modern OpenJDK based JVM (Semeru)

I’m trying to run some legacy code using Semeru:

java -version
openjdk version "1.8.0_322"
IBM Semeru Runtime Open Edition (build 1.8.0_322-b06)
Eclipse OpenJ9 VM (build openj9-0.30.0, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20220128_306 (JIT enabled, AOT enabled)
OpenJ9   - 9dccbe076
OMR      - dac962a28
JCL      - c1d9a7af7c based on jdk8u322-b06)

But this code depends on a proprietary Oracle cipher not included in OpenJDK anymore so when running:

Cipher.getInstance("PBEWithMD5AndTripleDES");

I’m getting an exception:

Caused by: java.security.NoSuchAlgorithmException: Cannot find any provider supporting PBEWithMD5AndTripleDES
    at javax.crypto.Cipher.getInstance(Cipher.java:543)

I’ve tried including Bouncy Castle as an alternative provider, but without luck.

Any chance of getting some open source provider I can include that supports this?

I’ve tried specifying the provider as SunJCE, which should be included as per:

cat /opt/java/openjdk/lib/security/java.security | grep security.provider
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

But got to the same error…

Advertisement

Answer

Sharing my own solution just in case anyone else has the same issue.

That cipher is actually available in the /lib/ext/sunjce_provider.jar file on the openjdk compilation (IBM Semeru Runtime Open Edition (build 1.8.0_322-b06)).

As posted on the question, it’s actually on the provider list (index 6), but the jar was not being loaded. I have yet to investigate if there is any change on the extension classloader that I’m not aware of, but, so far, manually adding that jar to the application classpath has worked flawlessly and got the cipher working.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement