Example usage for org.bouncycastle.jcajce.provider.asymmetric.ec IESCipher engineInit

List of usage examples for org.bouncycastle.jcajce.provider.asymmetric.ec IESCipher engineInit

Introduction

In this page you can find the example usage for org.bouncycastle.jcajce.provider.asymmetric.ec IESCipher engineInit.

Prototype

public void engineInit(int opmode, Key key, SecureRandom random) throws InvalidKeyException 

Source Link

Usage

From source file:com.completetrsst.crypto.Crypto.java

License:Apache License

private static byte[] _cryptIES(byte[] input, Key recipient, boolean forEncryption)
        throws InvalidKeyException, 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);
}