throw new JOSEException("Unsupported critical header parameter");
}
// Derive the content encryption key
JWEAlgorithm alg = header.getAlgorithm();
SecretKey cek;
if (alg.equals(JWEAlgorithm.RSA1_5)) {
int keyLength = header.getEncryptionMethod().cekBitLength();
SecureRandom randomGen = getSecureRandom();
SecretKey randomCEK = AES.generateKey(keyLength, randomGen);
try {
cek = RSA1_5.decryptCEK(privateKey, encryptedKey.decode(), keyLength, keyEncryptionProvider);
} catch (Exception e) {
// Protect against MMA attack by generating random CEK on failure,
// see http://www.ietf.org/mail-archive/web/jose/current/msg01832.html
cek = randomCEK;
}
} else if (alg.equals(JWEAlgorithm.RSA_OAEP)) {
cek = RSA_OAEP.decryptCEK(privateKey, encryptedKey.decode(), keyEncryptionProvider);
} else if (alg.equals(JWEAlgorithm.RSA_OAEP_256)) {
cek = RSA_OAEP_256.decryptCEK(privateKey, encryptedKey.decode(), keyEncryptionProvider);
} else {