ddn.net.ssh.keys

SSH public key and signature codecs (RFC 4253 section 6.6, RFC 8332).

Parses and encodes the key blob formats used by the initial profile (ssh-ed25519, ssh-rsa), parses signature blobs, separates the RSA key-format name from the SHA-2 signature algorithm names, and bridges parsed keys to the ddn-crypto verifiers. OpenSSH public-key lines and SHA-256 fingerprints round out the trust-facing surface.

The SHA-1 based ssh-rsa signature algorithm is never accepted: parsing succeeds (peers may offer it), but verification rejects it with a typed error, keeping the no-SHA-1-signature policy of the initial profile in one place.

Types 5

classSshKeyException : Exception

Raised for malformed, unsupported, or policy-rejected key or signature material.

Constructors
this(string msg, string file = __FILE__, size_t line = __LINE__)Constructs a key-codec exception.

Key-codec limits from the support matrix.

blobMax = 65536Maximum public key blob size in bytes
rsaMinBits = 2048Minimum accepted RSA modulus size in bits

A parsed SSH public key.

Field data are slices into the parsed blob; keep the blob alive as long as the struct is used. rawBlob preserves the exact received bytes for fingerprinting and transcript hashing.

Fields
string keyAlgorithmKey-format name, for example ssh-ed25519 or ssh-rsa
const(ubyte)[] ed25519KeyEd25519 public key bytes (valid for ssh-ed25519)
const(ubyte)[] rsaERSA public exponent magnitude (valid for ssh-rsa)
const(ubyte)[] rsaNRSA modulus magnitude (valid for ssh-rsa)
string ecdsaCurveECDSA curve identifier (valid for ecdsa-sha2-nistp256)
const(ubyte)[] ecdsaPointSEC 1 uncompressed point (valid for ecdsa-sha2-nistp256)
string commentComment from a public-key line, empty when absent
const(ubyte)[] rawBlobThe complete blob the key was parsed from

A parsed SSH signature blob.

Fields
string signatureAlgorithmSignature algorithm name, for example rsa-sha2-256
const(ubyte)[] signatureAlgorithm-specific signature body

Verifies SSH signatures against a parsed public key using the ddn-crypto primitives.

Methods
SshPublicKeyVerifier create(SshParsedPublicKey key) static @safeCreates a verifier for a parsed key.
bool verify(const(ubyte)[] signedData, scope const SshParsedSignature signature)Verifies a signature over the given data.
Constructors

Functions 13

fnSshParsedPublicKey parseSshPublicKeyBlob(const(ubyte)[] blob) @safeParses a public key blob (the string payload of a key exchange or the base64 body of a public-key line).
fnbool isParsedSshPublicKeyAlgorithm(string algorithm) @safe pure nothrowWhether a public key blob advertising this algorithm name can be structurally parsed by parseSshPublicKeyBlob.
fnubyte[] buildSshEd25519PublicKeyBlob(const(ubyte)[] keyBytes) @safeBuilds a wire-encoded ssh-ed25519 public key blob.
fnubyte[] buildSshRsaPublicKeyBlob(const(ubyte)[] e, const(ubyte)[] n) @safeBuilds a wire-encoded ssh-rsa public key blob from magnitude bytes.
fnubyte[] buildSshEcdsaP256PublicKeyBlob( const(ubyte)[] uncompressedPoint) @safeBuilds a wire-encoded ecdsa-sha2-nistp256 public key blob.
fnubyte[] sshEcdsaP256SignatureBodyFromRaw( const(ubyte)[] rawSignature) @safeConverts a fixed-width P-256 signature to the SSH ECDSA body.
fnubyte[] sshEcdsaP256SignatureBodyToRaw( const(ubyte)[] signatureBody) @safeConverts an SSH ECDSA body to fixed-width primitive form.
fnSshParsedSignature parseSshSignatureBlob(const(ubyte)[] blob) @safeParses a signature blob into its algorithm name and raw signature.
fnubyte[] buildSshSignatureBlob(string algorithm, const(ubyte)[] signature) @safeBuilds a wire-encoded signature blob.
fnbool isSupportedSignatureAlgorithm(string algorithm) @safe pure nothrowChecks whether a signature algorithm is accepted by the initial profile policy.
fnstring sshKeyFingerprintSha256(const(ubyte)[] blob)Computes the unpadded base64 SHA-256 fingerprint of a key blob.
fnstring formatSshFingerprint(const(ubyte)[] blob)Formats a fingerprint the way OpenSSH tools display it.
fnSshParsedPublicKey parseOpenSSHPublicKeyLine(string line, size_t maxLine = 16384) @safeParses an OpenSSH public-key line: algorithm, base64 blob, optional comment.