Skip to main content
Category: Passwords & Hashing

scrypt

Simply put

scrypt is a password-based key derivation function that turns a password into a cryptographic key. It is deliberately designed to require significant computing power and memory, which makes large-scale guessing (brute-force) attacks harder and more expensive. It was created by Colin Percival, originally for the Tarsnap online backup system.

Formal definition

scrypt is a password-based key derivation function (PBKDF) created by Colin Percival in March 2009, originally for the Tarsnap online backup system. It is designed to be both computationally intensive and memory-hard, deliberately requiring large amounts of memory in addition to CPU work; this raises the cost of parallelized, hardware-accelerated brute-force attacks compared with functions that are only CPU-bound. In IAM contexts it is typically applied to derive keys from or to protect stored passwords, and a demonstration password-based encryption utility built on the scrypt KDF is distributed alongside it. Note that scrypt is a key derivation function, not an encryption algorithm itself; specific tunable parameters, work factors, and version details are out of scope of this evidence.

Why it matters

Password-based key derivation functions are a frontline defense for stored credentials and password-derived keys. Because users choose passwords with limited entropy, an attacker who obtains a credential database can attempt to recover plaintext passwords through large-scale guessing. scrypt raises the cost of these attacks by being deliberately computationally intensive and, critically, memory-hard: it requires significant memory in addition to CPU work. This memory requirement is what distinguishes scrypt from functions that are only CPU-bound, since it constrains an attacker's ability to cheaply parallelize guessing across specialized, hardware-accelerated platforms.

For IAM teams evaluating how passwords are protected at rest, the choice of derivation function directly affects the economics of an offline attack following a breach. A function designed to be far more secure against hardware brute-force attempts, as scrypt was intended by its creator, means that even if a hashed credential store is exfiltrated, recovering usable passwords becomes materially more expensive. This matters most in scenarios where the credential store is the last line of defense and detection or rotation may lag behind compromise.

It is important to keep scrypt's role bounded: it is a key derivation function, not an encryption algorithm. Its strength against guessing attacks depends on how it is deployed and tuned, and specific parameter and work-factor guidance is outside the scope of this evidence. Teams should treat scrypt as one component of credential protection rather than a complete solution, and should verify configuration against current, authoritative guidance for their platform.

Who it's relevant to

Security architects
Architects selecting how passwords and password-derived keys are protected at rest need to understand scrypt's memory-hard design and its intended resistance to hardware-accelerated brute-force attacks. They should weigh it alongside other password-based key derivation functions while recognizing that specific parameter tuning is deployment-dependent and out of scope here.
IAM engineers
Engineers implementing credential storage or key derivation from passwords will encounter scrypt as an option for turning a password into a cryptographic key. They should remember that scrypt is a KDF, not an encryption algorithm, and that its protective strength depends on configuration and work-factor choices not covered by this evidence.
Compliance and audit leads
Those reviewing how an organization protects stored credentials can treat the use of a memory-hard, computationally intensive function like scrypt as relevant context when assessing resistance to offline guessing attacks. Verification should focus on how it is deployed and configured against current authoritative guidance, since parameter details are not specified in this evidence.

Inside scrypt

Memory-hard key derivation function (KDF)
scrypt is a password-based key derivation function designed to be memory-hard, meaning it deliberately consumes significant amounts of memory during computation to raise the cost of large-scale parallel brute-force attacks using specialized hardware such as ASICs or GPUs.
Cost parameter (N)
The CPU/memory cost factor that controls the overall work and memory footprint of the derivation. Increasing N raises both the computational effort and the memory required, and it is typically chosen as a power of two.
Block size parameter (r)
Influences the size of the memory blocks processed internally, affecting the memory usage and the mix of memory versus CPU work in the algorithm.
Parallelization parameter (p)
Controls the degree of parallelism in the computation, allowing tuning of how much independent work can be performed concurrently.
Salt
A unique per-password value combined with the input to ensure that identical passwords produce different derived outputs, defending against precomputation and rainbow-table attacks.
Derived key output
The fixed-length output produced by the function, used either as a stored password verifier or as key material for other cryptographic purposes, with a configurable output length.

Common questions

Answers to the questions practitioners most commonly ask about scrypt.

Is scrypt an authentication protocol or a way to verify user identity?
No. Scrypt is a password-based key derivation function used to hash passwords (or derive keys) for storage, not an authentication protocol. It plays a role only in the credential-verification step of authentication: when a user submits a password, the system runs scrypt over it and compares the result against a stored value. Identification, the broader authentication flow, and any authorization decision that follows are separate concerns that scrypt does not address.
Does scrypt encrypt passwords?
No. Scrypt is a one-way key derivation and password hashing function, not an encryption algorithm. Encryption is reversible with a key, whereas scrypt is designed to be computationally infeasible to reverse. Storing a password with scrypt produces a derived value that is verified by recomputation, not decrypted. Conflating hashing with encryption is a common error; they serve different purposes.
What do scrypt's cost parameters control, and how should they be chosen?
Scrypt is typically tuned with an N (CPU/memory cost), r (block size), and p (parallelization) parameter. N drives the iteration and memory work, r influences the memory footprint per unit of work, and p affects parallelism. Higher values increase resistance to brute-force and hardware-accelerated attacks at the cost of latency and resource use. Appropriate values depend on your hardware, acceptable verification latency, and threat model, so they should be benchmarked in your own environment and revisited over time rather than fixed permanently.
How does scrypt's memory-hardness affect deployment on constrained or high-throughput systems?
Scrypt's defining property is that it is memory-hard, meaning it deliberately consumes significant memory to resist attackers using specialized hardware. In practice this means each verification can require substantial RAM, which matters when many authentication requests occur concurrently. On memory-constrained systems or high-throughput authentication services, you typically need to size parameters so that concurrent verifications do not exhaust memory, balancing security against capacity and latency. This is a configuration and capacity-planning concern specific to your deployment.
Should salts be used with scrypt, and how are they typically handled?
Yes. A unique, sufficiently random per-password salt is typically used with scrypt to prevent precomputation and rainbow-table attacks and to ensure identical passwords produce different stored values. The salt is generally stored alongside the derived output, often together with the cost parameters, so verification can recompute the same derivation. The salt is not secret; its purpose is uniqueness, not confidentiality.
How can you migrate stored scrypt hashes when you need to strengthen parameters or change algorithms?
Because scrypt is one-way, you cannot recompute stronger hashes from stored values without the original password. A common approach is to rehash at next successful login: when a user authenticates and their submitted password validates against the existing stored value, you recompute with the updated parameters (or a different function) and replace the stored value. Storing the parameters with each hash lets you detect which records use outdated settings. This migration strategy is a deployment practice and depends on your system's login flow and rollout policy.

Common misconceptions

scrypt is an encryption algorithm that protects stored passwords by encrypting them.
scrypt is a one-way key derivation function, not an encryption algorithm. It produces a derived value that is not reversible to recover the original password, and it does not provide confidentiality in the sense of decryptable ciphertext.
Because scrypt is memory-hard, it is always the strongest choice and makes other KDFs obsolete.
scrypt's suitability depends on deployment context and correct parameter tuning. Other password hashing and key derivation functions exist and may be preferred depending on requirements, threat model, and available guidance; no single KDF is universally superior, and poorly chosen parameters can undermine scrypt's intended protection.
Using scrypt handles user authentication on its own.
scrypt is a mechanism for deriving keys or verifying password-based credentials; it is one component of a credential-verification step. Authentication as a whole (verifying who a principal is) and authorization (what they may do) are separate concerns, and scrypt does not by itself constitute an authentication protocol or flow.

Best practices

Tune the cost (N), block size (r), and parallelization (p) parameters to your hardware and latency budget, and revisit them over time as available compute and memory capacity increase.
Always use a unique, sufficiently random salt per password to prevent precomputation and rainbow-table attacks.
Store the algorithm identifier and the chosen parameters alongside the derived output so that verification remains possible and parameters can be upgraded without breaking existing records.
Treat scrypt output as a one-way verifier for password storage; do not rely on it for confidentiality or assume the original password can be recovered.
Benchmark scrypt in your actual production environment to confirm that memory and CPU consumption are acceptable under expected load before committing to specific parameters.
Evaluate scrypt against your specific threat model and applicable guidance rather than assuming it is the correct choice for every deployment, and document the rationale for the parameters selected.
Promotional banner graphic asking if you are ready for PCI DSS 4.0 with a call-to-action to get the guide