https://docs.oracle.com/en/java/javase/11/security/index.html describes a Java interface but does not specify the default algorithms for things like RSA encryption. I need to interface with code using the Java 11 java.security model for PK encryption using RSA on a linux server.
From what I can tell, Java uses PKCS v2.2 and probably uses sha256 (though they don't say). All of the examples on Oracle's site describe interfacing to java.security from Java only; most of what I can find on the net (or here) is quite old or doesn't actually describe the non-Java interface.
Q: Does anyone know of any working examples for using another language (preferably Perl or C) to interface with the Java-11 java.security library for PK encryption using RSA from linux?
If I can find any reference to a working library that will interface properly with Java-11's java.security I'll at least have working specs to start from -- or just interface directly to it with Inline.
Perl's Crypt::PK::RSA uses TomCrypt (https://github.com/libtom/libtomcrypt). This is a nice C implementation but it uses a v1.5 key padding, which isn't going to work with Java using v2.2. If I can find a working C v2.2 implementation I can try and graft it into TomCrypt; that or just a working stand-along RSA encryption algorithm in C that uses v2.2.
At this point I've tried using Crypt::PK::RSA with all of the available options for v1.5 & oeap using sha1 & sha256 to reproduce encrypting a given string to known ciphertext using both high- and low-endian transform to hex (via unpack H* and h*) without being able to reproduce the ciphertext hex output from Java.
At this point I've also tried using key pairs generated by OpenSSL & TomCrypt (via Crypt::PK::RSA) and can't even get Java to read them so I can't even generate a throwaway key to use here as an example.