namespace Renci.SshNet.Messages.Authentication { /// /// Represents "hostbased" SSH_MSG_USERAUTH_REQUEST message. /// internal class RequestMessageHost : RequestMessage { /// /// Gets the public key algorithm for host key as ASCII encoded byte array. /// public byte[] PublicKeyAlgorithm { get; private set; } /// /// Gets or sets the public host key and certificates for client host. /// /// /// The public host key. /// public byte[] PublicHostKey { get; private set; } /// /// Gets or sets the name of the client host as ASCII encoded byte array. /// /// /// The name of the client host. /// public byte[] ClientHostName { get; private set; } /// /// Gets or sets the client username on the client host as UTF-8 encoded byte array. /// /// /// The client username. /// public byte[] ClientUsername { get; private set; } /// /// Gets or sets the signature. /// /// /// The signature. /// public byte[] Signature { get; private set; } /// /// Gets the size of the message in bytes. /// /// /// The size of the messages in bytes. /// protected override int BufferCapacity { get { var capacity = base.BufferCapacity; capacity += 4; // PublicKeyAlgorithm length capacity += PublicKeyAlgorithm.Length; // PublicKeyAlgorithm capacity += 4; // PublicHostKey length capacity += PublicHostKey.Length; // PublicHostKey capacity += 4; // ClientHostName length capacity += ClientHostName.Length; // ClientHostName capacity += 4; // ClientUsername length capacity += ClientUsername.Length; // ClientUsername capacity += 4; // Signature length capacity += Signature.Length; // Signature return capacity; } } /// /// Initializes a new instance of the class. /// /// Name of the service. /// Authentication username. /// The public key algorithm. /// The public host key. /// Name of the client host. /// The client username. /// The signature. public RequestMessageHost(ServiceName serviceName, string username, string publicKeyAlgorithm, byte[] publicHostKey, string clientHostName, string clientUsername, byte[] signature) : base(serviceName, username, "hostbased") { PublicKeyAlgorithm = Ascii.GetBytes(publicKeyAlgorithm); PublicHostKey = publicHostKey; ClientHostName = Ascii.GetBytes(clientHostName); ClientUsername = Utf8.GetBytes(clientUsername); Signature = signature; } /// /// Called when type specific data need to be saved. /// protected override void SaveData() { base.SaveData(); WriteBinaryString(PublicKeyAlgorithm); WriteBinaryString(PublicHostKey); WriteBinaryString(ClientHostName); WriteBinaryString(ClientUsername); WriteBinaryString(Signature); } } }