Table of Contents

Class AuditChainVerifier

Namespace
Excalibur.AuditLogging
Assembly
Excalibur.AuditLogging.dll

Verifies audit hash-chains on behalf of an audit store, establishing both halves of tamper-evidence — that no record's contents were altered, and that no record was inserted, deleted, or reordered — in a single pass shared by every provider.

public static class AuditChainVerifier
Inheritance
AuditChainVerifier
Inherited Members

Remarks

Both detections come from one walk. Each record's keyed MAC is verified against the prior tag taken from the record that actually precedes it, rather than from the record's own stored claim about its predecessor. Altering a covered field breaks the MAC; removing a record breaks the next survivor's, because the tag it was written with names a predecessor that is no longer there. A store that instead verifies each record against its own stored claim checks only the first of those, and will report a trail with records removed from it as intact.

The stored claim is separately compared against the predecessor actually present, so that altering it alone — which moves no MAC input — is reported rather than passing unnoticed.

This type exists so that a provider does not have to rediscover those distinctions. A store should read its records, group them into partitions matching how it chains on write, resolve each partition's anchor and successor, and call VerifyAsync(IAuditIntegrityStrategy, IReadOnlyList<AuditChainPartition>, DateTimeOffset, DateTimeOffset, bool, CancellationToken) — leaving no per-provider verification logic to diverge.

Methods

VerifyAsync(IAuditIntegrityStrategy, IReadOnlyList<AuditChainPartition>, DateTimeOffset, DateTimeOffset, bool, CancellationToken)

Verifies every supplied chain partition and renders the outcome as an AuditIntegrityResult.

public static Task<AuditIntegrityResult> VerifyAsync(IAuditIntegrityStrategy integrity, IReadOnlyList<AuditChainPartition> partitions, DateTimeOffset startDate, DateTimeOffset endDate, bool isHashChained, CancellationToken cancellationToken)

Parameters

integrity IAuditIntegrityStrategy

The keyed integrity strategy that holds the signing key.

partitions IReadOnlyList<AuditChainPartition>

The chain partitions in range. Supply one entry per partition the store chains over; supplying a single entry holding records from several partitions reports violations on an intact trail.

startDate DateTimeOffset

The inclusive start of the window examined, recorded on the result.

endDate DateTimeOffset

The inclusive end of the window examined, recorded on the result.

isHashChained bool

Whether the store's write path chained these records. Pass false from a store whose chaining is switched off: each partition is then a single record, so the reported quantity counts records rather than chains, and the result says so.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<AuditIntegrityResult>

NoEventsInScope when the partitions hold no records at all; ViolationsDetected naming the earliest failing record when any partition's chain does not hold; otherwise Verified.

Remarks

Each partition is walked until its first failure, so CompromisedChainCount counts compromised partitions, not failing records. Once a chain breaks, every record after the break is unverifiable rather than independently sound, so counting further failures within one partition would report the consequences of a single break as though they were separate findings.

A partition is the store's write-time chaining unit, so the unit this quantity is in depends on the store's configuration: with chaining on, a partition is a chain and two altered records in one chain count once; with chaining off, the store supplies one partition per record and the same quantity counts records. That is why isHashChained is required rather than inferred — it travels onto the result so a reader is never handed a number whose unit they cannot see.

Exceptions

ArgumentNullException

Thrown when integrity or partitions is null.