java.lang.Object
io.getlime.security.powerauth.crypto.lib.util.EciesUtils

public final class EciesUtils extends Object
A utility class for handling ECIES data.
Author:
Roman Strobl, roman.strobl@wultra.com
  • Method Details

    • generateMacData

      public static byte[] generateMacData(byte[] sharedInfo2, byte[] encryptedData)
      Generate MAC data for ECIES request or response MAC validation.
      Parameters:
      sharedInfo2 - Parameter sharedInfo2 for ECIES.
      encryptedData - Encrypted data
      Returns:
      Resolved MAC data.
    • generateTimestamp

      public static long generateTimestamp()
      Generate timestamp for ECIES request/response.
      Returns:
      Timestamp bytes to use for ECIES encryption.
    • deriveAssociatedData

      public static byte[] deriveAssociatedData(EncryptorScope scope, String protocolVersion, String applicationKey, String activationId, String temporaryKeyId) throws EciesException
      Derive associated data for ECIES.
      Parameters:
      scope - Encryptor's scope.
      protocolVersion - Protocol version.
      applicationKey - Application key.
      activationId - Activation ID.
      temporaryKeyId - Temporary key ID.
      Returns:
      Derived associated data.
      Throws:
      EciesException - In case that activation ID is required but is missing.
    • deriveSharedInfo2Base

      public static byte[] deriveSharedInfo2Base(EncryptorScope scope, String applicationSecret, byte[] transportKey) throws EciesException
      Derive base for SharedInfo2 calculation for ECIES encryption scheme.
      Parameters:
      scope - Scope of the encryptor.
      applicationSecret - Application's secret.
      transportKey - Transport key, required when scope is EncryptorScope.ACTIVATION_SCOPE.
      Returns:
      Bytes representing SharedInfo2 base.
      Throws:
      EciesException - In case of some required parameter is missing or if underlying cryptographic primitive fail.
    • deriveSharedInfo2

      public static byte[] deriveSharedInfo2(String protocolVersion, byte[] sharedInfo2Base, byte[] ephemeralPublicKey, byte[] nonce, Long timestamp, byte[] associatedData) throws EciesException
      Derive final SharedInfo2 constant for ECIES encryption scheme.
      Parameters:
      protocolVersion - Protocol's version.
      sharedInfo2Base - SharedInfo2 base, calculated by deriveSharedInfo2Base(EncryptorScope, String, byte[]) function.
      ephemeralPublicKey - Ephemeral public key. Value is null for response encryption / decryption.
      nonce - Nonce for request or response.
      timestamp - Timestamp for request or response.
      associatedData - Associated data.
      Returns:
      Bytes representing SharedInfo2 parameter for ECIES encryption.
      Throws:
      EciesException - In case that some required parameter is missing.