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,kandx. - 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), whereM1is the client hash we just sent.Auses the same leading-zero-stripped encoding as the client hash. - compute_
k π - The multiplier
k = H(N, g), always 3509477ea9fca66eadb7cf7b1bd0eb508f54d3989a9c988006a7d0b338374dd2 for this group. - compute_
key π - Computes the SRP session key
K. - compute_
shared_ πa A = g^a mod N.- compute_
u π - The scrambling parameter
u = H(A, B), which ties the key to both ephemerals. - compute_
x π - Derives SRP
x, which proves we know the password without sending it. - exchange_
a_ πfor_ b - Sends
userAand returns the serverβsuserB. - from_
server_ πhex - Parses a value the server sent in the encoding above.
- generate_
secret_ πa - Generates the ephemeral secret
aas a random 256-bit value. - mod_
n_ πbytes value mod Nas big-endian bytes, always the full width ofN.- mod_pow π
base ^ exponent mod N, constant time inexponent.- perform π
- The exchange itself, with
secret_ataken as an argument so tests can pin it. - perform_
and_ πverify_ with_ x - Runs the SRP exchange from a precomputed x and labels the key with the session id. The salt only feeds the verification hash.
- scalar π
- A SHA-256 output as an SRP scalar.
- scalar_
bytes π - The bytes of x without leading zeros, which a big integer serializer may add. x is a SHA-256 scalar, so a value that still does not fit comes from a malformed credential bundle.
- 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) andu(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
Bthat is 0 or 1 moduloN, 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.