I need to add an OAEPParameterSpec as a AlgorithmParameterSpec to a JWE (Json Web Encryption) object. How can I do that?
I'm using a client - server application. server is encrypting in RSA-OAEP-256 encryption algorithm, client is failing at decrypting it since it is using an HSM and there is a padding issue. A lot of researches shows that BouncyCastle provider has to be used in order to solve that but that isn't relevant for me because I can't change the HSM.
In order to have this there is a tweak should be done at server side before encrypting is to add the following line
AlgorithmParameterSpec oaepParameterSpec = new OAEPParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT);
This "oaepParameterSpec" has to be added to the JWE object I'm using, but I can't find any reference to guide me how to do that nor in the jose4j specs on how to change/set AlgorithmParameterSpec.
The RSA-OAEP-256 implementation in jose4j uses that OAEPParameterSpec https://bitbucket.org/b_c/jose4j/src/2e8f0c3fe7fdc9c8c48a572e02a677fb16c21448/src/main/java/org/jose4j/jwe/RsaKeyManagementAlgorithm.java#lines-84 so I don't know if that path is going to help.