Auth

Stable

Argon2id hashing, SCRAM login and JWTs for Go

Used by ViF, LogWisp and Chess

Small, independent authentication pieces for Go: Argon2id password hashing, a SCRAM login on Argon2id that can be bound to the TLS channel, HS256 and RS256 JWTs, and opaque tokens.

  • Argon2id password hashes in PHC format, with bounds on untrusted input
  • A challenge-response login on Argon2id and HMAC-SHA256, optionally bound to the TLS channel
  • HS256 and RS256 JWTs
  • An allowlist of opaque tokens, and Bearer header parsing

What sets it apart

Four parts that share nothing but their care with untrusted input: password hashes, a login, signed tokens and opaque ones. LogWisp’s listeners and its browser viewer log in with the SCRAM below, and ViF’s hosts check a game’s passphrase with it, bound to the certificate on a wss:// door; Chess issues its sessions as JWTs.

Argon2-SCRAM
A four-message challenge and response over Argon2id and HMAC-SHA256. The server keeps keys it cannot log in with, and the client accepts a login only when the server's final signature proves it holds the user's key. Its own JSON protocol, not SASL's SCRAM-SHA-256.
A cost floor
The client refuses a challenge under 64 MiB and 3 passes, so a hostile server cannot ask for a cheap proof to guess the password from. Only the client's own policy lowers it, never the challenge.
Channel binding
Both sides can commit the proof to the TLS channel, a hash of the server's certificate or a TLS exporter. A relay terminating TLS with any other certificate, even a trusted one, fails the proof; bound and unbound peers never agree, so nothing downgrades quietly.
Unknown users
get stable decoy challenges, derived from a key the replicas share, and fail at the proof exactly as a wrong password does.
Bounds
Every key derivation checks memory, passes, lanes and their product before allocating anything. Passwords stop at 1024 bytes and tokens at 16 KiB; a server holds at most 4096 pending handshakes, each for 30 seconds.
JWTs
One manager per key and service: issuer and audience enforced, the algorithm pinned, expiry and subject required, application claims nested under extra where they cannot overwrite registered ones. RS256 keeps signing apart from verifying.
Opaque tokens
A strict Bearer header parser, and an allowlist keyed by each token's SHA-256.