namespace XFESystem.Tls; /// Fill the complete buffer from a verified kernel CSPRNG, or throw. public delegate void TlsRandomFill(Span destination); /// /// Explicit bridge to kernel-owned security services. Neither delegate has a /// host OS, compile timestamp, deterministic seed, or jitter-only fallback. /// The platform must verify UTC provenance and RNG health before supplying it. /// public sealed class TlsPlatformSecurityContext : ITlsSecurityContext { private readonly Func readVerifiedUtc; private readonly TlsRandomFill fillVerifiedRandom; public TlsPlatformSecurityContext(Func readVerifiedUtc, TlsRandomFill fillVerifiedRandom) { this.readVerifiedUtc = readVerifiedUtc ?? throw new ArgumentNullException(nameof(readVerifiedUtc)); this.fillVerifiedRandom = fillVerifiedRandom ?? throw new ArgumentNullException(nameof(fillVerifiedRandom)); } public DateTime UtcNow { get { DateTime utc = readVerifiedUtc(); TlsSecurity.ValidateUtc(utc); return utc; } } public void FillRandom(Span destination) { try { fillVerifiedRandom(destination); } catch { // A source may fail after partially filling the destination. // Never return that partial result to the TLS implementation. destination.Clear(); throw; } } }