encryptDecrypt

Encrypts or decrypts data using the Triple DES (TDES) algorithm with either a DUKPT key or a session key derived from a master key (MK/SK). The operation mode, cipher mode, key type, and other parameters determine the exact cryptographic context.

  • For CryptoKeyType.MK_SK, baSessionKey must be provided; the operation uses this session key.

  • For CryptoKeyType.DUKPT_TDES, baSessionKey is ignored;

  • baInitializationVector is required for CBC mode, ignored for ECB.

  • The caller must provide a sufficiently-sized baOutput array for the result (same size as baData).

Parameters

tEncryptionMode

Specifies encryption or decryption (CryptoEncryptionMode).

tCipherMethod

Specifies the cipher block mode (CryptoCipherMethod).

eKeyType

Selects the key type to use (CryptoKeyType).

tKeyPurpose

The intended use of the key (CryptoKeyPurpose).

iKeyIndex

Index of the DUKPT key or MK/SK group (0–99).

baSessionKey

Optional session key (used only for MK/SK).

baInitializationVector

Initialization vector for CBC mode, or null for ECB.

baData

Input data to encrypt/decrypt.

baOutput

Output array to store the operation result; must be large enough to hold the result.

Throws

If the cryptographic operation fails (e.g., invalid parameters, missing key, secure element error).