Password hashing

bcrypt

The Blowfish-based adaptive password hash, a long-standing default in web frameworks

legacy Root API only
Legacy tier.

Old but not broken. Kept for interoperability; root API only. Reach it with NextSSL(root=True) in Python or the nextssl_root_* functions in C.

About bcrypt

bcrypt is a password hashing function. It uses a 23-byte (184-bit) output and a 16-byte salt. It takes the parameter cost (default 12). Its registry entry cites bcrypt (Provos, Mazieres 1999). NextSSL lists it in the legacy tier and exposes it through the root API only (NextSSL(root=True) in Python, nextssl_root_* in C).

Overview

bcrypt is a password hashing function designed by Niels Provos and David Mazières in 1999 for OpenBSD. It introduced a tunable cost factor so hashing could be made slower as hardware improved, and it remains widely used in web frameworks.

bcrypt is built on Eksblowfish, an 'expensive key schedule' variant of Blowfish. The salt and password are mixed into Blowfish's S-boxes and subkeys, and the key schedule is then repeated 2^cost times, alternately keyed by the password and salt. Finally the string "OrpheanBeholderScryDoubt" is encrypted 64 times with the resulting cipher to produce the hash, which is stored with its cost and salt in a $2b$ modular-crypt string.

bcrypt uses about 4 KiB of memory, which is enough to hinder GPUs moderately but far less than modern memory-hard functions require. Hashes begin with '$2a$', '$2b$' or '$2y$', reflecting fixes to historical implementation bugs, followed by a two-digit cost and a 22-character salt. The cost is logarithmic, so each increment doubles the work.

History

1999–1999
  1. bcrypt presented by Niels Provos and David Mazières at USENIX

Security notes

bcrypt is not broken, but it truncates passwords at 72 bytes and its small memory footprint makes it more vulnerable to FPGA and ASIC attack than Argon2id or scrypt. Some implementations mishandle non-ASCII or null bytes. Use a cost of at least 10–12, and prefer Argon2id for new systems.

Typical uses

Password storage in existing web applicationsInteroperability with $2a$/$2b$/$2y$ hashes

Sizes

FieldBytesMeaning
out23Output
salt16Salt

Parameters

NameTypeRangeDefaultRequired
cost u32 4 – 16 12 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

root = NextSSL(root=True)   # tier 'legacy' is reachable from the root API only
phc = root.call("pwhash", "bcrypt", None, b"correct horse")[0]   # PHC string, fresh salt
ok  = root.check("pwhash_verify", "bcrypt", 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 bcrypt?

bcrypt is a password hash in the bcrypt family. bcrypt is a password hashing function designed by Niels Provos and David Mazières in 1999 for OpenBSD.

What are the bcrypt sizes?

In NextSSL, bcrypt uses: output 23 bytes.

Who designed bcrypt and when?

bcrypt belongs to the bcrypt family, first published in 1999 by Niels Provos, David Mazières. Its origin: OpenBSD; USENIX 1999.

Which standards define bcrypt?

bcrypt is referenced by bcrypt (Provos, Mazieres 1999).

Is bcrypt safe to use?

bcrypt is in the legacy tier. Old but not broken. Kept for interoperability; root API only. It is only reachable through the root API (NextSSL(root=True) in Python, nextssl_root_* in C).