NodeCrypto Help

PBKDF2 Key Derivation

Category: Key Derivation ยท Node Type ID: kdf-pbkdf2

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

Parameter Configuration

Parameter (ID)Type & DefaultVisibility ConditionDescription & Options
Iterations
iterations
number
Default: 10000
Supports Variable Reference ($var: int)
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
number
Default: 32
Supports Variable Reference ($var: int)
Always visible Desired output key length in bytes (clamped to 1..512; default 32 for a 256-bit key).
PR Hash Function
hashAlgorithm
select
Default: SHA-256
Always visible Underlying HMAC pseudorandom function: SHA-256 or SHA-512.
  • SHA-256: SHA-256
  • SHA-512: 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 NamePort IDData TypeRequiredVisibility ConditionDescription
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 NamePort IDData TypeVisibility ConditionDescription
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 CodeDefault Engine MessageTrigger 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.

  1. Encode your passphrase with String to Bytes and connect it to Password / Secret.
  2. Connect a 16-byte Random Generator to Salt, leave Output Key Length at 32, and wire Derived Key to AES Encrypt.