PBKDF2 Key Derivation
Password-Based Key Derivation Function 2 (RFC 8018)
Overview
Derives a cryptographic secret key of configurable byte length from a password or passphrase using PBKDF2 (Password-Based Key Derivation Function 2, PKCS #5 v2.1 / RFC 8018 / NIST SP 800-132) with HMAC-SHA256 or HMAC-SHA512 as the pseudorandom function (PRF).
PBKDF2 applies the PRF iteratively (controlled by Iterations) to slow down brute-force and dictionary attacks against human-chosen passwords. If the optional Salt input port is left unconnected, the node defaults to 16 zero bytes (0x00 * 16) for deterministic testing.
When to Use
- Stretching a user password or passphrase into a 16-, 24-, or 32-byte symmetric encryption key for AES, ChaCha20-Poly1305, or HMAC.
- Reproducing PKCS #5 / RFC 6070 / keystore key-derivation test vectors.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Iterationsiterations |
numberDefault: 10000 |
Always visible | Number of HMAC iteration rounds (clamped to 1..1,000,000; default 10000). Higher counts increase resistance to brute-force attacks at the cost of execution time. |
Output Key Length (bytes)keyLength |
numberDefault: 32 |
Always visible | Desired output key length in bytes (clamped to 1..512; default 32 for a 256-bit key). |
PR Hash FunctionhashAlgorithm |
selectDefault: SHA-256 |
Always visible | Underlying HMAC pseudorandom function: SHA-256 or SHA-512.
|
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 (2 total).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Password |
password |
Bytes |
Required | Always visible | Password or secret byte array (Uint8Array; must be at least 1 byte). Connect String to Bytes if starting from text. |
Salt |
salt |
Bytes |
Optional | Always visible | Optional salt byte array (Uint8Array). Defaults to 16 zero bytes if unconnected; connect a Random Generator (16B) in real protocols. |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Derived Key |
derivedKey |
Bytes |
Always visible | Derived cryptographic key material (Uint8Array) of Output Key Length bytes. |
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.
| Error Code | Default Engine Message | Trigger Condition |
|---|---|---|
INVALID_KDF_PARAMS |
Invalid KDF parameters | Raised when the KDF input secret/password is empty or the requested output length/iterations are outside the valid range. |
Examples
Deriving a 256-bit AES Key from a Passphrase and Random Salt
Stretch a UTF-8 passphrase into a 32-byte key using 10,000 iterations of PBKDF2-HMAC-SHA256.
- Encode your passphrase with String to Bytes and connect it to
Password / Secret. - Connect a 16-byte Random Generator to
Salt, leave Output Key Length at32, and wireDerived Keyto AES Encrypt.