ddn.net.ssh.known_hosts
known_hosts parsing and host trust matching.
Parses the OpenSSH known_hosts format - plain and hashed host patterns, wildcard and negated patterns, markers, comments - and answers whether a presented host key is trusted, unknown, changed, or revoked for a target (host, port) plus optional caller aliases.
Policy notes:
- Parsing is strict: a malformed file throws instead of being
silently skipped, so trust decisions fail closed.
- Entries whose key type has no enabled public-data parser -
ecdsa-sha2-nistp384/nistp521, certificate, and security-key types - are skipped the way OpenSSH ignores key types it does not use; the enabled profile never negotiates them, so they cannot match a presented key.
- A matched
@revokedentry marks the host revoked andoverrides everything else.
@cert-authorityentries never act as plain trustedkeys; they surface as a distinct unsupported outcome while certificate validation is out of scope.
- The file is never modified; there is no accept-new
behaviour here.
Types 5
Outcome of a known_hosts lookup for a presented key.
known_hosts limits from the support matrix.
One parsed known_hosts entry.
bool revokedTrue when marked @revokedbool certAuthorityTrue when marked @cert-authoritystring[] patternsHost pattern field items, negation flags includedstring keyTypeKey-format name from the lineconst(ubyte)[] keyBlobDecoded key blobA parsed known_hosts database.
private SshKnownHostsEntry[] entries_SshKnownHostsResult check(string host, ushort port,
const(ubyte)[] keyBlob, string[] aliases = null) const @safeLooks up a presented key for a target host.bool entryMatches(
scope const SshKnownHostsEntry entry,
scope const string[] candidates) static @safebool hashedHostMatches(string field,
string candidate) static @trustedChecks a hashed host field of the form |1|salt|hash against one candidate using HMAC-SHA1 with the stored salt.bool patternMatches(string pattern,
string candidate) static @safe pure nothrowMatches one non-hashed pattern against one candidate.this(SshKnownHostsEntry[] entries)A pinned set of host keys: exact blobs, nothing else matches.
private const(ubyte)[][] blobs_bool isPinned(const(ubyte)[] keyBlob) const @safeChecks whether the presented blob is one of the pinned keys.this(scope const(ubyte)[][] blobs)Constructs a pinned-key set from exact key blobs.Functions 3
Variables 2
string edBlobBase64 = "AAAAC3NzaC1lZDI1NTE5AAAAIH2rdejW247PBfeVS8elmtXzRTcaAeqAff968XHgkai+"string otherBlobBase64 = "AAAAC3NzaC1lZDI1NTE5AAAAINhZZIMbIoqJYucBZG8cectL3avqcfVbMs9/vOjCQCHq"