IllegalBlockSizeException, BadPaddingException {
IESCipher cipher = new IESCipher(new IESEngine(
new ECDHBasicAgreement(), new KDF2BytesGenerator(
new SHA1Digest()), new HMac(new SHA256Digest()),
new PaddedBufferedBlockCipher(new CBCBlockCipher(
new AESEngine()))));
cipher.engineInit(forEncryption ? Cipher.ENCRYPT_MODE
: Cipher.DECRYPT_MODE, recipient, new SecureRandom());
return cipher.engineDoFinal(input, 0, input.length);
}