Skip to main content

Module srp

Expand description

SRP-4096: the A/B exchange with the server and the crypto behind it.

StructsΒ§

SrpInfo πŸ”’
The account’s public SRP parameters, as returned by v3/auth/start.

ConstantsΒ§

AUTH_ENDPOINT πŸ”’
CONFIRM_KEY_ENDPOINT πŸ”’
N_BITS πŸ”’
The width of the SRP group, and so of every value reduced modulo it.
N_HEX πŸ”’
SCALAR_BITS πŸ”’
The width of the SHA-256 values SRP uses as scalars: u, k and x.
SRP_METHOD πŸ”’

StaticsΒ§

G πŸ”’
The SRP group generator.
N πŸ”’
The 4096-bit SRP group prime (RFC 3526).
N_PARAMS πŸ”’
The Montgomery form of N, built once.

FunctionsΒ§

calculate_client_hash πŸ”’
The client verification hash sent to v2/auth/confirm-key: H(H(N) xor H(g) || H(I) || s || A || B || K).
calculate_identity πŸ”’
SHA256(SHA256(uuid) || SHA256(lower(nfkd(username)))), url-safe base64.
calculate_server_hash πŸ”’
The server’s answer to calculate_client_hash: H(A || M1 || K), where M1 is the client hash we just sent. A uses the same leading-zero-stripped encoding as the client hash.
compute_key πŸ”’
Computes the SRP session key K.
compute_shared_a πŸ”’
A = g^a mod N.
compute_x πŸ”’
Derives SRP x, which proves we know the password without sending it.
exchange_a_for_b πŸ”’
Sends userA and returns the server’s userB.
from_server_hex πŸ”’
Parses a value the server sent in the encoding above.
generate_secret_a πŸ”’
Generates the ephemeral secret a as a random 256-bit value.
mod_n_bytes πŸ”’
value mod N as big-endian bytes, always the full width of N.
mod_pow πŸ”’
base ^ exponent mod N, constant time in exponent.
perform πŸ”’
The exchange itself, with secret_a taken as an argument so tests can pin it.
perform_and_verify πŸ”’
Runs the SRP exchange and labels the resulting key with the session id.
scalar πŸ”’
A SHA-256 output as an SRP scalar.
sha256 πŸ”’
to_compatible_byte_array πŸ”’
Big-endian bytes with leading zeros stripped, the encoding the server hashes over.
to_server_hex πŸ”’
Hex in the exact format 1Password’s server expects: lowercase, with all leading zero nibbles stripped. The output may be odd-length; that is intentional. Both userA (sent over the wire) and u (the SRP shared secret hashed into the session key) use this encoding, and changing it would break wire compatibility or session-key agreement with the server.
validate_b πŸ”’
Rejects a server B that is 0 or 1 modulo N, the two values the web client refuses.
verify_key πŸ”’
Sends the client verification hash to confirm the session key, then checks the server’s answer.