TDES Encrypt
Triple-DES (112 or 168-bit Key) Encryption (NIST SP 800-67)
Overview
Encrypts data using the Triple Data Encryption Algorithm (TDES / 3DES) as standardized in NIST SP 800-67 and ISO/IEC 18033-3. TDES applies the 64-bit (8-byte) DES block cipher three times per block in Encrypt-Decrypt-Encrypt (EDE) order ($E_{K_3}(D_{K_2}(E_{K_1}(P)))$).
Accepts either a 16-byte key (2-Key TDES / 112-bit effective security, where $K_3 = K_1$) or a 24-byte key (3-Key TDES / 168-bit effective security) and supports CBC, ECB, CTR, CFB, and OFB modes over 8-byte blocks.
When to Use
- Interoperating with financial (EMV payment cards, ISO 8583 PIN blocks), smartcard (GlobalPlatform SCP02), or legacy hardware security module (HSM) protocols.
- Testing 8-byte block padding and EDE key schedules.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Cipher Modemode |
selectDefault: ECB |
Always visible | Selects the 64-bit block cipher operating mode: CBC, ECB, CTR, CFB, or OFB. Hides the IV port when set to ECB. See Block Cipher Modes for full details.
|
Paddingpadding |
selectDefault: None |
Always visible | 8-byte block padding scheme applied in ECB and CBC modes. Hidden in stream modes (CTR, CFB, OFB). See Padding Schemes for full details.
|
Unify ErrorserrorUnify |
booleanDefault: false |
Always visible | Replaces built-in errors with a single custom error code/message when enabled. |
Unified Error CodeerrorUnifyCode |
textDefault: "" (empty) |
When errorUnify is true |
Custom error code when Unify Errors is enabled. |
Unified Error MessageerrorUnifyMessage |
textDefault: "" (empty) |
When errorUnify is true |
Custom error message when Unify Errors is enabled. |
Port I/O Specification
See Ports & Connections for general wiring rules, data type colors, and dynamic port creation.
Input Ports
Port Nature: Fixed Input Ports (3 total; conditionally visible ports depend on parameter settings as shown below).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Key |
key |
Bytes |
Required | Always visible | TDES key: 16 bytes (2-key EDE2, 112-bit) or 24 bytes (3-key EDE3, 168-bit). |
Plaintext |
plaintext |
Bytes |
Required | Always visible | Plaintext bytes (Uint8Array) to encrypt. Must be a multiple of 8 bytes when Mode is ECB/CBC and Padding = None. |
IV |
iv |
Bytes |
Optional | When mode is CBC |
8-byte initialization vector or initial counter block. Only visible in CBC, CTR, CFB, and OFB modes. Defaults to 8 zero bytes if unconnected. |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Ciphertext |
ciphertext |
Bytes |
Always visible | Encrypted output bytes (Uint8Array). |
Error Cases
When any of the following conditions occurs at runtime, this node transitions to an ERROR state and downstream nodes connected to its outputs do not execute. Enabling Unify Errors (errorUnify) replaces all error codes below with your configured unified error code and message.
| Error Code | Default Engine Message | Trigger Condition |
|---|---|---|
INVALID_KEY_LENGTH |
Invalid key length | Raised when Key is neither 16 bytes nor 24 bytes. |
PLAINTEXT_NOT_BLOCK_ALIGNED |
In NoPad mode the plaintext length must be a multiple of the block size | Raised in ECB or CBC mode when Padding = None and Plaintext length is not a multiple of 8 bytes. |
Examples
Encrypting an 8-Byte EMV Cryptogram Block with 2-Key 3DES
Encrypt a 16-byte payload in CBC mode with a 16-byte 3DES key and zero IV.
- Set Cipher Mode to
CBCand Padding toNone(orISO7816). - Connect a 16-byte key to
Keyand your 16-byte payload toPlaintext.