Expand description
SCRAM SHA-256 authentication primitives for the Haystack auth protocol.
This module implements the cryptographic operations needed for SCRAM (Salted Challenge Response Authentication Mechanism) with SHA-256 as specified by the Project Haystack auth spec.
It provides functions shared by both server and client implementations for the three-phase handshake: HELLO, SCRAM challenge/response, and BEARER token issuance.
Structs§
- Scram
Credentials - Pre-computed SCRAM credentials for a user (stored server-side).
- Scram
Handshake - In-flight SCRAM handshake state held by the server between the server-first-message and client-final-message exchanges.
Enums§
- Auth
Error - Errors that can occur during SCRAM authentication.
- Auth
Header - Parsed Haystack
Authorizationheader.
Constants§
- DEFAULT_
ITERATIONS - Default PBKDF2 iteration count for SCRAM SHA-256.
Functions§
- client_
final_ message - Client-side: Process server-first-message, produce client-final-message.
- client_
first_ message - Client-side: Create the client-first-message data (base64-encoded).
- derive_
credentials - Derive SCRAM credentials from a password (for user creation/storage).
- extract_
client_ nonce - Extract the client nonce from a base64-encoded client-first-message.
- format_
auth_ info - Format a Haystack
Authentication-Infoheader with the auth token. - format_
www_ authenticate - Format a Haystack
WWW-Authenticateheader for a SCRAM challenge. - generate_
nonce - Generate a random nonce string (base64-encoded 18 random bytes).
- parse_
auth_ header - Parse a Haystack
Authorizationheader value. - server_
first_ message - Server-side: Create the server-first-message data and handshake state.
- server_
verify_ final - Server-side: Verify client-final-message and produce server signature.