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

public class EciesEnvelopeKey extends Object
The ECIES Envelope Key represents a temporary key for ECIES encryption and decryption process. The key is derived from shared secret produced in ECDH key agreement. The derivation function is X9.63 with SHA256 digest. Additionally this class holds the ephemeral public key which is either generated or received from the client.
Author:
Roman Strobl, roman.strobl@wultra.com
  • Constructor Summary

    Constructors
    Constructor
    Description
    EciesEnvelopeKey(byte[] secretKey, byte[] ephemeralPublicKey)
    EciesEnvelopeKey constructor with secret key and ephemeral public key.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    deriveIvForNonce(byte[] nonce)
    Derive initialization vector from IV key and provided nonce.
    byte[]
    Get secret key for encryption or decryption.
    byte[]
    Get ephemeral public key.
    byte[]
    Get key for AES-CBC IV derivation.
    byte[]
    Get key for HMAC calculation.
    byte[]
    Get the complete secret key for ECIES.
    boolean
    Get whether derived secret key is valid.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EciesEnvelopeKey

      public EciesEnvelopeKey(byte[] secretKey, byte[] ephemeralPublicKey)
      EciesEnvelopeKey constructor with secret key and ephemeral public key.
      Parameters:
      secretKey - Derived secret key.
      ephemeralPublicKey - Ephemeral public key.
  • Method Details

    • getEncKey

      public byte[] getEncKey() throws EciesException
      Get secret key for encryption or decryption.
      Returns:
      Secret key for encryption or decryption.
      Throws:
      EciesException - In case encryption key is not valid.
    • getMacKey

      public byte[] getMacKey() throws EciesException
      Get key for HMAC calculation.
      Returns:
      Key for HMAC calculation.
      Throws:
      EciesException - In case MAC key is not valid.
    • getIvKey

      public byte[] getIvKey() throws EciesException
      Get key for AES-CBC IV derivation.
      Returns:
      Key for AES-CBC IV derivation.
      Throws:
      EciesException - In case IV key is not valid.
    • deriveIvForNonce

      public byte[] deriveIvForNonce(byte[] nonce) throws EciesException
      Derive initialization vector from IV key and provided nonce.
      Parameters:
      nonce - Nonce to be used in IV derivation.
      Returns:
      Derived initialization vector.
      Throws:
      EciesException - In case that nonce is not valid, or HMAC calculation failed.
    • getSecretKey

      public byte[] getSecretKey() throws EciesException
      Get the complete secret key for ECIES.
      Returns:
      Secret key for ECIES.
      Throws:
      EciesException - In case secret key is not valid.
    • getEphemeralKeyPublic

      public byte[] getEphemeralKeyPublic()
      Get ephemeral public key.
      Returns:
      Ephemeral public key.
    • isValid

      public boolean isValid()
      Get whether derived secret key is valid.
      Returns:
      Whether derived secret key is valid.