I found the hard way that in Oracle's Java standard crypto provider
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
uses MFG1 instanciated with SHA-1; SHA-256 is only used to hash the label (in practice empty). The only solution that I found to actually use SHA-256 in MFG1 (helped by that answer and comment) was using an alternate form of Cipher.init
:
cipher.init(Cipher.DECRYPT_MODE, privKey, new OAEPParameterSpec(
"SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT
));
Question: is there a transformation that Cipher.getInstance
will recognize, with effect similar to "RSA/ECB/OAEPWithSHA-256AndMGF1Padding"
, except with MGF1 using SHA-256?