Chapter 15
Encrypted password fields (PFE1)
Passwords are encrypted in the browser with the server's public key (ECDH P-256 → HKDF-SHA256 → AES-256-GCM) and bound to a single-use challenge plus the field name. This is on top of HTTPS: it keeps passwords unreadable to TLS-terminating proxies, CDNs, gateways and request logs, and makes captured requests unreplayable.
Browser:
const envelope = await sealSecret(passwordControl.getValue(), session.encryption, 'password');
// After every response: session.encryption.challenge = body.challenge;
sealSecret encodes the password from wipeable memory straight to UTF-8 bytes, encrypts, and zeroes the bytes.
No JavaScript string of the password is ever created.
Server (Node):
const bytes = openEnvelope(envelope, pfe.byKid, `${challenge}|password`); // throws PfeError on any failure
try { /* hash or verify */ } finally { bytes.fill(0); }
Other back ends: drop-in decryptors live in server/decrypt/ for Python, Go, C#, Ruby, PHP and Java, each with
the same open(envelope, keys, context) shape. npm run test:pfe checks them all against vectors produced by the
browser code. Key generation, rotation, the wire format and the threat model are in
docs/ENCRYPTION.md.
Web Crypto only works in a secure context (HTTPS or localhost). See §17.3.