// The JCE crypto provider uses different alg names
String internalAlgName;
PSSParameterSpec pssSpec = null;
if (alg.equals(JWSAlgorithm.RS256)) {
internalAlgName = "SHA256withRSA";
} else if (alg.equals(JWSAlgorithm.RS384)) {
internalAlgName = "SHA384withRSA";
} else if (alg.equals(JWSAlgorithm.RS512)) {
internalAlgName = "SHA512withRSA";
} else if (alg.equals(JWSAlgorithm.PS256)) {
internalAlgName = "SHA256withRSAandMGF1";
// JWA mandates salt length must equal hash
pssSpec = new PSSParameterSpec("SHA256", "MGF1", MGF1ParameterSpec.SHA256, 32, 1);
} else if (alg.equals(JWSAlgorithm.PS384)) {
internalAlgName = "SHA384withRSAandMGF1";
// JWA mandates salt length must equal hash
pssSpec = new PSSParameterSpec("SHA384", "MGF1", MGF1ParameterSpec.SHA384, 48, 1);
} else if (alg.equals(JWSAlgorithm.PS512)) {
internalAlgName = "SHA512withRSAandMGF1";
// JWA mandates salt length must equal hash
pssSpec = new PSSParameterSpec("SHA512", "MGF1", MGF1ParameterSpec.SHA512, 64, 1);
} else {
throw new JOSEException("Unsupported RSASSA algorithm, must be RS256, RS384, RS512, PS256, PS384 or PS512");
}