ddn.net.ssh.agent

ssh-agent wire codec (RFC 9322 / OpenSSH PROTOCOL.agent).

Every message is a uint32 length followed by a payload. The client subset used here covers identity listing (11/12) and signing (13/14), plus the failure status. All readers are bounded before any allocation, and every parsed field is validated structurally so a hostile agent cannot smuggle oversized blobs, empty names, or trailing bytes past this codec.

Types 8

Agent protocol limits from the support matrix.

messageMax = 256 * 1024Maximum encoded message size in bytes
identitiesMax = 256Maximum identities in one listing answer
signatureMax = 64 * 1024Maximum signature blob in a sign response
commentMax = 1024Maximum comment length
enumSshAgentMessage : ubyte

Agent message numbers.

failure = 5Generic failure
requestIdentities = 11Client: list identities
identitiesAnswer = 12Server: identities answer
signRequest = 13Client: sign request
signResponse = 14Server: sign response
enumSshAgentFlags : uint

Signature request flags (OpenSSH agent).

rsaSha2_256 = 2Request rsa-sha2-256 signatures for RSA keys
rsaSha2_512 = 4Request rsa-sha2-512 signatures for RSA keys
classSshAgentException : Exception

Raised for agent wire violations: bad framing, unexpected message numbers, limit breaches, or structural errors.

Constructors
this(string msg, string file = __FILE__, size_t line = __LINE__)Constructs an agent exception.

One identity from a listing answer.

Fields
const(ubyte)[] blobRaw public key blob
string commentComment (may be empty)

A decoded listing answer.

Fields
SshAgentIdentity[] identitiesIdentities in answer order

A decoded sign response.

Fields
const(ubyte)[] signatureRaw signature blob

Result of framing: the payload and total occupied size.

Fields
const(ubyte)[] payloadPayload bytes (slice into the source buffer)
size_t totalTotal bytes occupied including the length prefix

Functions 7

fnubyte[] buildRequestIdentities() @safeEncodes a REQUEST_IDENTITIES message.
fnubyte[] buildSignRequest(const(ubyte)[] keyBlob, const(ubyte)[] data, uint flags) @safeEncodes a SIGN_REQUEST message.
fnSshAgentFraming frameAgentMessage(const(ubyte)[] buffer) @safeDecodes one complete agent message from a buffer.
fnSshAgentIdentitiesAnswer parseIdentitiesAnswer(const(ubyte)[] payload) @safeParses an IDENTITIES_ANSWER payload (without the length prefix).
fnSshAgentSignAnswer parseSignResponse(const(ubyte)[] payload) @safeParses a SIGN_RESPONSE payload (without the length prefix).
fnbool isAgentFailure(const(ubyte)[] payload) @safe pure nothrowChecks whether a payload is the generic agent failure status.
private fnSshWireWriter frameUint32(scope const(ubyte)[] payload) @safeHelper: prefixes a payload with its agent length.