java.lang.Object
io.getlime.security.powerauth.crypto.lib.encryptor.ecies.EciesEncryptor

public class EciesEncryptor extends Object
Class implementing an ECIES encryptor.
Author:
Petr Dvorak, petr@wultra.com, Roman Strobl, roman.strobl@wultra.com
  • Constructor Details

    • EciesEncryptor

      public EciesEncryptor(ECPublicKey publicKey)
      Construct a new encryptor with null sharedInfo1 and sharedInfo2.
      Parameters:
      publicKey - Public key used for encryption.
    • EciesEncryptor

      public EciesEncryptor(ECPublicKey publicKey, byte[] sharedInfo1, byte[] sharedInfo2)
      Construct a new encryptor with provided sharedInfo1 and sharedInfo2.
      Parameters:
      publicKey - Public key used for encryption.
      sharedInfo1 - Additional shared information used during key derivation.
      sharedInfo2 - Additional shared information used during decryption.
    • EciesEncryptor

      public EciesEncryptor(EciesEnvelopeKey envelopeKey, byte[] sharedInfo2)
      Construct an encryptor from existing ECIES envelope key and sharedInfo2 parameter. The derivation of envelope key is skipped. The privateKey and sharedInfo1 values are unknown.
      Parameters:
      envelopeKey - ECIES envelope key.
      sharedInfo2 - Parameter sharedInfo2 for ECIES.
  • Method Details

    • initEnvelopeKey

      public void initEnvelopeKey(byte[] ephemeralPublicKeyBytes) throws EciesException
      Initialize envelope key for encryptor using provided ephemeral public key. This method is used when the encryptor parameters are transported over network and the encryptor is reconstructed on another server using envelope key and sharedInfo2 parameter.
      Parameters:
      ephemeralPublicKeyBytes - Ephemeral public key for ECIES.
      Throws:
      EciesException - In case envelope key initialization fails.
    • encrypt

      public EciesPayload encrypt(byte[] data, boolean useIv, boolean useTimestamp, byte[] associatedData) throws EciesException
      Encrypt data.
      Parameters:
      data - Request data.
      useIv - Controls whether encryption uses non-zero initialization vector for protocol V3.1+.
      useTimestamp - Controls whether encryption uses timestamp for protocol V3.2+.
      associatedData - Associated data for protocol V3.2+ or null for previous protocol versions.
      Returns:
      ECIES payload.
      Throws:
      EciesException - In case encryption fails.
    • encrypt

      public EciesPayload encrypt(byte[] data, EciesParameters eciesParameters) throws EciesException
      Encrypt data with provided ECIES parameters.
      Parameters:
      data - Request data.
      eciesParameters - ECIES parameters.
      Returns:
      ECIES payload.
      Throws:
      EciesException - In case encryption fails.
    • getSharedInfo2

      public byte[] getSharedInfo2()
      Get parameter sharedInfo2 for ECIES.
      Returns:
      Parameter sharedInfo2 for ECIES.
    • getEnvelopeKey

      public EciesEnvelopeKey getEnvelopeKey()
      Get ECIES envelope key.
      Returns:
      ECIES envelope key.