Password hashing

scrypt

Colin Percival's memory-hard key derivation function, standardised in RFC 7914

standard Safe API

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–2016
  1. scrypt published by Colin Percival

  2. 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

Password storagePassphrase-based encryption keysDisk and wallet encryption

Sizes

FieldBytesMeaning
out16 – 1,024Output
salt0 – 64Salt

Parameters

NameTypeRangeDefaultRequired
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)

Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.

Frequently 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.