PBKDF2
A standard way to turn a password into an encryption key, or a stored password hash, by hashing it many thousands of times so guessing is slow.
In more detail
crypto.pbkdf2() runs on the libuv thread pool, while pbkdf2Sync() blocks the main thread until it finishes. Its deliberate slowness makes it a good example of CPU-bound work in the lessons.
Examples
hashlib.pbkdf2_hmac('sha256', password, salt, 600_000)OWASP suggests 600,000 iterations when using PBKDF2 with HMAC-SHA-256Related terms
- KDF — A key derivation function: an algorithm that turns a password or other secret into one or more cryptographic keys of the right length.
- HMAC — A way of combining a secret key with a hash function to produce a tag that shows a message came from someone holding the key and was not changed.
- password hashing — Storing a password as the output of a deliberately slow, salted hash function, so a stolen database does not reveal the passwords.
- Argon2 — A modern password hashing function that is deliberately slow and needs a lot of memory for every guess, which makes stolen password hashes very expensive to crack.
- hash — A short fixed-length fingerprint calculated from data, which changes completely if even one byte of the data changes.
- thread pool — A fixed or bounded set of reusable worker threads that take tasks from a queue, instead of creating a new thread for each task.
- node:crypto — The built-in Node.js module for hashing, HMACs, encryption, random numbers and key derivation, backed by OpenSSL.
Taught in
- Cryptographic Hashing: SHA-256, SHA-3 & Passwords — Cybersecurity Fundamentals, GRC & Cryptography
- Encryption In Practice With OpenSSL — ISC2 Certified in Cybersecurity (CC) Exam Prep
- libuv Architecture: Event Demultiplexer & Thread Pool — Node.js Internals & Backend Services
- Choosing The Right Cryptography — CompTIA Security+ (SY0-801) Exam Prep
References
- RFC 8018: PKCS #5 password-based cryptography, version 2.1
- OWASP Password Storage Cheat Sheet
- Node.js: Crypto (crypto.pbkdf2)