namespace Renci.SshNet.Messages.Authentication { /// /// Represents "publickey" SSH_MSG_USERAUTH_REQUEST message. /// public class RequestMessagePublicKey : RequestMessage { /// /// Gets the name of the authentication method. /// /// /// The name of the method. /// public override string MethodName { get { return "publickey"; } } /// /// Gets the name of the public key algorithm. /// /// /// The name of the public key algorithm. /// public string PublicKeyAlgorithmName { get; private set; } /// /// Gets the public key data. /// public byte[] PublicKeyData { get; private set; } /// /// Gets or sets public key signature. /// /// /// The signature. /// public byte[] Signature { get; set; } /// /// Initializes a new instance of the class. /// /// Name of the service. /// Authentication username. /// Name of private key algorithm. /// Private key data. public RequestMessagePublicKey(ServiceName serviceName, string username, string keyAlgorithmName, byte[] keyData) : base(serviceName, username) { this.PublicKeyAlgorithmName = keyAlgorithmName; this.PublicKeyData = keyData; } /// /// Initializes a new instance of the class. /// /// Name of the service. /// Authentication username. /// Name of private key algorithm. /// Private key data. /// Private key signature. public RequestMessagePublicKey(ServiceName serviceName, string username, string keyAlgorithmName, byte[] keyData, byte[] signature) : this(serviceName, username, keyAlgorithmName, keyData) { this.Signature = signature; } /// /// Called when type specific data need to be saved. /// protected override void SaveData() { base.SaveData(); if (this.Signature == null) { this.Write(false); } else { this.Write(true); } this.WriteAscii(this.PublicKeyAlgorithmName); this.WriteBinaryString(this.PublicKeyData); if (this.Signature != null) this.WriteBinaryString(this.Signature); } } }