Table of Contents

Class AuditRecordCanonicalizer

Namespace
Excalibur.AuditLogging
Assembly
Excalibur.AuditLogging.Abstractions.dll

Produces the deterministic, unambiguous canonical byte representation of an audit record's integrity-covered fields, for use as the input to IAuditIntegrityStrategy.

public static class AuditRecordCanonicalizer
Inheritance
AuditRecordCanonicalizer
Inherited Members

Remarks

The keyed MAC protects the bytes it is computed over, not the field structure — so the canonical form must be both deterministic (the same fields always produce byte-identical output) and injective on field boundaries (distinct field sequences can never collide to the same bytes). This helper guarantees both:

  • A leading version byte (CanonicalVersion) so the canonical form can evolve while older records stay verifiable under their original version.
  • Length-prefixed fields (a present/absent marker plus a big-endian length), never naive concatenation — so ["a","bc"] and ["ab","c"] produce different bytes, and a null field is distinct from an empty one.
  • Fixed UTF-8 encoding (culture-invariant) — callers must supply culture-invariant field strings in a stable order.

Verification must re-canonicalize the live reloaded fields through this same helper (never persist and re-MAC a stored canonical blob), so the integrity check covers the queryable record.

Fields

CanonicalVersion

The current canonical-format version, written as the first byte of every canonical buffer.

public const byte CanonicalVersion = 1

Field Value

byte

Methods

Canonicalize(params string?[])

Canonicalizes an ordered set of integrity-covered fields into deterministic, unambiguous bytes.

public static byte[] Canonicalize(params string?[] fields)

Parameters

fields string[]

The record's integrity-covered fields, in a stable order, each already rendered as a culture-invariant string (or null for an absent field).

Returns

byte[]

The canonical byte representation, prefixed with CanonicalVersion.

Exceptions

ArgumentNullException

Thrown when fields is null.