org.bouncycastle.crypto.engines

## Class IESEngine

- java.lang.Object
- - org.bouncycastle.crypto.engines.IESEngine

- Direct Known Subclasses:
    OldIESEngine

      public class IESEngine
      extends java.lang.Object

  Support class for constructing integrated encryption ciphers for doing basic message exchanges on top of key agreement ciphers. Follows the description given in IEEE Std 1363a.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `IESEngine(BasicAgreement agree, DerivationFunction kdf, Mac mac)` Set up for use with stream mode, where the key derivation function is used to provide a stream of bytes to xor with the message.
    `IESEngine(BasicAgreement agree, DerivationFunction kdf, Mac mac, BufferedBlockCipher cipher)` Set up for use in conjunction with a block cipher to handle the message.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BufferedBlockCipher` | `getCipher()`
    `protected byte[]` | `getLengthTag(byte[] p2)`
    `Mac` | `getMac()`
    `void` | `init(AsymmetricKeyParameter publicKey, CipherParameters params, EphemeralKeyPairGenerator ephemeralKeyPairGenerator)` Initialise the decryptor.
    `void` | `init(AsymmetricKeyParameter privateKey, CipherParameters params, KeyParser publicKeyParser)` Initialise the encryptor.
    `void` | `init(boolean forEncryption, CipherParameters privParam, CipherParameters pubParam, CipherParameters params)` Initialise the encryptor.
    `byte[]` | `processBlock(byte[] in, int inOff, int inLen)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IESEngine

          public IESEngine(BasicAgreement agree,
                           DerivationFunction kdf,
                           Mac mac)

      Set up for use with stream mode, where the key derivation function is used to provide a stream of bytes to xor with the message.

      Security note: when this engine is initialised with static keys on both sides (the `init(boolean, CipherParameters, CipherParameters, CipherParameters)` entry point, which supplies no ephemeral component) the key-derivation input is the same for every message, so the stream-mode keystream is identical from message to message - encrypting more than one message under a given key pair is a many-time pad and leaks plaintext relationships. Use the ephemeral sender-key initialisation (the standard ECIES mode) for messages that must remain confidential; the static-static mode is effectively deterministic encryption.

      Parameters:
        `agree` - the key agreement used as the basis for the encryption
        `kdf` - the key derivation function used for byte generation
        `mac` - the message authentication code generator for the message

    - #### IESEngine

          public IESEngine(BasicAgreement agree,
                           DerivationFunction kdf,
                           Mac mac,
                           BufferedBlockCipher cipher)

      Set up for use in conjunction with a block cipher to handle the message. It is strongly recommended that the cipher is not in ECB mode.
      Parameters:
        `agree` - the key agreement used as the basis for the encryption
        `kdf` - the key derivation function used for byte generation
        `mac` - the message authentication code generator for the message
        `cipher` - the cipher to used for encrypting the message

  - ### Method Detail

    - #### init

          public void init(boolean forEncryption,
                           CipherParameters privParam,
                           CipherParameters pubParam,
                           CipherParameters params)

      Initialise the encryptor.
      Parameters:
        `forEncryption` - whether or not this is encryption/decryption.
        `privParam` - our private key parameters
        `pubParam` - the recipient's/sender's public key parameters
        `params` - encoding and derivation parameters, may be wrapped to include an IV for an underlying block cipher.

    - #### init

          public void init(AsymmetricKeyParameter publicKey,
                           CipherParameters params,
                           EphemeralKeyPairGenerator ephemeralKeyPairGenerator)

      Initialise the decryptor.
      Parameters:
        `publicKey` - the recipient's/sender's public key parameters
        `params` - encoding and derivation parameters, may be wrapped to include an IV for an underlying block cipher.
        `ephemeralKeyPairGenerator` - the ephemeral key pair generator to use.

    - #### init

          public void init(AsymmetricKeyParameter privateKey,
                           CipherParameters params,
                           KeyParser publicKeyParser)

      Initialise the encryptor.
      Parameters:
        `privateKey` - the recipient's private key.
        `params` - encoding and derivation parameters, may be wrapped to include an IV for an underlying block cipher.
        `publicKeyParser` - the parser for reading the ephemeral public key.

    - #### getCipher

          public BufferedBlockCipher getCipher()

    - #### getMac

          public Mac getMac()

    - #### processBlock

          public byte[] processBlock(byte[] in,
                                     int inOff,
                                     int inLen)
                              throws InvalidCipherTextException

      Throws:
        `InvalidCipherTextException`

    - #### getLengthTag

          protected byte[] getLengthTag(byte[] p2)