Wrapper encrypter = new AESWrapEngine();
encrypter.init(true, new KeyParameter(kek.getEncoded()));
// Produce cipher text
try {
return encrypter.wrap(cekBytes, 0, cekBytes.length);
} catch (Exception e) {
// java.lang.IllegalStateException
// org.bouncycastle.crypto.DataLengthException
throw new JOSEException("Couldn't encrypt Content Encryption Key (CEK): " + e.getMessage(), e);