Cryptographic core of Tunnel Bound KAPA (KEM-based Augmented Password
Authentication) that replaces the SRP-style
TsnifAuthentication. This unit is the PURE-CRYPTO layer: no remoting, no Snif
classes, no persistence - so it can be round-trip tested in-process. The
Login/ChangeAuth remoting classes (StreamSec.Snif.AkeAuthentication) drive it and
add the channel-binding (IsnifChannelBinding) and the wire marshalling.
See the DESIGN SPEC block at the top of StreamSec.Snif.AkeAuthentication for the
full rationale (goals G1/G2/G3, the CTR-challenge + DEFERRED-HMAC ordering that
kills the offline-dictionary-from-a-challenge oracle, the CHANNEL-BOUND response
tag that stops a host-key MITM from relaying the client's answer to the real
server, the rogue-server-oracle residual, and the FAIL-CLOSED client policy).
PRIMITIVE CHOICES (NOTE for review): the spec names "HMAC" and "KDF/HKDF". This
implementation realises both with SHA-3-family constructions (SHAKE256 as a
length-prefixed keyed XOF), which are sound (no length-extension), simpler to
drive here, and consistent with CompositeKEM's SHA3-256 combiner. This protocol
is internal (no cross-implementation interop), so a named HMAC/HKDF is not
required; a reviewer may swap in HMAC-SHA256 / HKDF-SHA256 if desired. The
challenge cipher is AES-256-CTR exactly as specified (no auth tag).
Flow (records hold the per-login secret state K and s1):
server: MakeChallenge(file) -> (c, ct) [retains K, s1]
client: Respond(user,pw, salt,params, c,ct) -> s2 [retains K]
client: ResponseTag(s2, binding) -> r2 [CHANNEL-BOUND response tag]
server: VerifyResponseBound(r2, binding) (constant time) then
server: Confirm(transcript) -> confirm [DEFERRED authenticator]
client: VerifyConfirm(transcript, confirm) (constant time)
both : SessionKey(transcript) (must match)Feature notes: Snif remoting framework (concepts) · Tunnel Bound KAPA (Snif authentication)
inherits from EsnifError
Raised by the KAPA augmented-PAKE helpers for a truncated or malformed wire buffer, or a key generation that failed. Part of the snif exception hierarchy - see EsnifError in StreamSec.Snif.Conversion.
(no public members)
Argon2id cost parameters; serialised into the server file so they travel with the salt and can be raised over time without breaking existing files.
Parallelism: Integer;
MemoryKiB: Integer;
Iterations: Integer;
class function Default: TsnifAkeParams; static;
function Serialize: tBytes;
class function Parse(const aBytes: tBytes): TsnifAkeParams; static;
The per-user server file. The app persists it (Snif has no built-in persistence). PubKey is the one-way verifier: the password-derived composite ML-KEM-768 + X25519 public key. The server can encapsulate to it but, holding no private key, can never impersonate the client.
Salt: tBytes;
Params: tBytes;
PubKey: tBytes;
HostKeyId: tBytes;
function Serialize: tBytes;
class function Parse(const aBytes: tBytes): TsnifPwFile; static;
function MakeChallenge(const aFile: TsnifPwFile; out aC, aCt: tBytes): Boolean;
function VerifyResponseBound(const aResponse, aBinding: tBytes): Boolean;
function Confirm(const aTranscript: tBytes): tBytes;
function SessionKey(const aTranscript: tBytes): tBytes;
property S1: tBytes read fS1;
procedure Burn;
function Respond(const aUser, aPassword, aSecret, aSalt, aParamsBytes, aC, aCt: tBytes; out aS2: tBytes): Boolean;
function ResponseTag(const aS2, aBinding: tBytes): tBytes;
function VerifyConfirm(const aTranscript, aConfirm: tBytes): Boolean;
function SessionKey(const aTranscript: tBytes): tBytes;
procedure Burn;