Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Snif.KAPA

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)

Classes, interfaces and records

classEsnifKAPA

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)

recordTsnifAkeParams

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;
lanes (p), >= 1
MemoryKiB: Integer;
memory in KiB (m), >= 8*p
Iterations: Integer;
passes (t), >= 1
class function Default: TsnifAkeParams; static; function Serialize: tBytes;
Delegates to AppendBytes, passing 1 argument(s), and returns its result.
class function Parse(const aBytes: tBytes): TsnifAkeParams; static;

recordTsnifPwFile

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;
serialised TsnifAkeParams
PubKey: tBytes;
composite-KEM encoded public key (the verifier)
HostKeyId: tBytes;
host key this file is bound to (G2); may be empty
function Serialize: tBytes;
Delegates to AppendBytes, passing 1 argument(s), and returns its result.
class function Parse(const aBytes: tBytes): TsnifPwFile; static;

recordTsnifAkeServerSession

function MakeChallenge(const aFile: TsnifPwFile; out aC, aCt: tBytes): Boolean;
Encapsulate to the stored verifier and build the CTR challenge; retains K and the random s1. Returns False if the stored PubKey cannot be parsed.
function VerifyResponseBound(const aResponse, aBinding: tBytes): Boolean;
Constant-time check of the client's CHANNEL-BOUND response tag: aResponse ?= MAC( KDF(K,'resp', aBinding), s1 ). Full description »
function Confirm(const aTranscript: tBytes): tBytes;
The DEFERRED server authenticator over the transcript (sent only AFTER the client has committed its response tag).
function SessionKey(const aTranscript: tBytes): tBytes;
Delegates to Kdf, forwarding fK, 'sk', cKeyLen and aTranscript, and returns its result.
property S1: tBytes read fS1;
The server's random challenge s1 (== the client's s2 on success). The driver needs it to build the confirmation transcript, since the wire now carries the bound tag instead of s2. Read-only; still a secret - do not transmit it.
procedure Burn;

recordTsnifAkeClientSession

function Respond(const aUser, aPassword, aSecret, aSalt, aParamsBytes, aC, aCt: tBytes; out aS2: tBytes): Boolean;
Re-derive the keypair from user+password+salt+params, decapsulate c, and decrypt the challenge to s2; retains K. The decapsulation is implicit- rejecting: a wrong password yields a pseudo-random K (and thus a wrong s2), never an error - we do NOT branch on it.
function ResponseTag(const aS2, aBinding: tBytes): tBytes;
The CHANNEL-BOUND response tag sent in AuthStep INSTEAD of raw s2: r2 = MAC( KDF(K,'resp', aBinding), s2 ). Full description »
function VerifyConfirm(const aTranscript, aConfirm: tBytes): Boolean;
Constant-time verification of the server's deferred authenticator.
function SessionKey(const aTranscript: tBytes): tBytes;
Delegates to Kdf, forwarding fK, 'sk', cKeyLen and aTranscript, and returns its result.
procedure Burn;

Routines