scrypt
Colin Percival's memory-hard key derivation function, standardised in RFC 7914
About scrypt
scrypt is a password hashing function. It uses a 16–1,024-byte output and a 0–64-byte salt. It takes the parameters ln (default 17), out_len (default 32), p (default 1) and r (default 8). Its registry entry cites RFC 7914. NextSSL lists it in the standard tier and exposes it through the safe API.
Overview
scrypt is a password-based key derivation function designed by Colin Percival in 2009 to make large-scale hardware attacks costly by requiring substantial memory. It is specified in RFC 7914 and is widely used in password storage, disk encryption and cryptocurrencies.
scrypt first stretches the password and salt with PBKDF2-HMAC-SHA256 into p blocks. Each block is processed by ROMix: a sequence of N pseudo-random blocks is generated with the BlockMix function built on Salsa20/8 and stored in memory, then N data-dependent lookups into that sequence are mixed back into the state. The outputs are recombined with PBKDF2 to produce the key. The parameters N (cost), r (block size) and p (parallelism) set memory and time.
Memory use is roughly 128·N·r bytes. Litecoin and several other cryptocurrencies use scrypt with very small parameters as a proof-of-work function, which should not be confused with password-hashing settings. Typical interactive settings start around N = 2^15 to 2^17 with r = 8 and p = 1, adjusted to the time and memory budget of the server. The memory cost is what makes custom cracking hardware expensive.
History
2009–2016scrypt published by Colin Percival
Specified in RFC 7914
Security notes
scrypt is secure when tuned with sufficiently large N. Its data-dependent memory access can leak timing information through cache side channels, which Argon2id avoids. Parameters that were adequate in 2009 are too low today.
Typical uses
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| out | 16 – 1,024 | Output |
| salt | 0 – 64 | Salt |
Parameters
| Name | Type | Range | Default | Required |
|---|---|---|---|---|
| ln | u32 | 1 – 20 | 17 | no |
| out_len | u32 | 16 – 1024 | 32 | no |
| p | u32 | 1 – 16 | 1 | no |
| r | u32 | 1 – 32 | 8 | no |
Parameters are passed as a string, for example nextssl_mac("hmac", "hash=sha512", …). Omitted parameters take their declared default.
Use it
from nextssl_demo import NextSSL
ns = NextSSL() # safe API: safe and standard tiers
phc = ns.call("pwhash", "scrypt", None, b"correct horse")[0] # PHC string, fresh salt
ok = ns.check("pwhash_verify", "scrypt", None, b"correct horse", phc)
nextssl_pwhash("scrypt", NULL, password, out);
nextssl_pwhash_verify("scrypt", NULL, password, phc);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_pwhash_in(reg::all(), Policy::Safe, "scrypt", &Params::new())?;
let phc = alg.hash(b"correct horse")?; // PHC string
let ok = alg.verify(b"correct horse", &phc)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Similar names
Looking for something else?More password hashing
All 30Frequently asked questions
What is scrypt?
scrypt is a password hash in the scrypt family. scrypt is a password-based key derivation function designed by Colin Percival in 2009 to make large-scale hardware attacks costly by requiring substantial memory.
What are the scrypt sizes?
In NextSSL, scrypt uses: output 16 to 1,024 bytes.
Who designed scrypt and when?
scrypt belongs to the scrypt family, first published in 2009 by Colin Percival. Its origin: RFC 7914.
Which standards define scrypt?
scrypt is referenced by RFC 7914.
Is scrypt safe to use?
scrypt is in the standard tier. Standardised and sound. Reachable from the safe API. It can be called from the safe API.
Related families
The Password Hashing Competition winner: memory-hard hashing standardised in RFC 9106
PBKDF2The iterated-HMAC password-based key derivation function from PKCS #5 and NIST SP 800-132
yescryptAn scrypt-derived memory-hard password hash, now the default in many Linux distributions
Salsa20Bernstein's eSTREAM-portfolio ARX stream cipher and the core of scrypt and NaCl