namespace Renci.SshNet.Messages.Authentication { /// /// Represents "password" SSH_MSG_USERAUTH_REQUEST message. /// internal class RequestMessagePassword : RequestMessage { /// /// Gets authentication password. /// public byte[] Password { get; private set; } /// /// Gets new authentication password. /// public byte[] NewPassword { 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 += 1; // NewPassword flag capacity += 4; // Password length capacity += Password.Length; // Password if (NewPassword != null) { capacity += 4; // NewPassword length capacity += NewPassword.Length; // NewPassword } return capacity; } } /// /// Initializes a new instance of the class. /// /// Name of the service. /// Authentication username. /// Authentication password. public RequestMessagePassword(ServiceName serviceName, string username, byte[] password) : base(serviceName, username, "password") { Password = password; } /// /// Initializes a new instance of the class. /// /// Name of the service. /// Authentication username. /// Authentication password. /// New authentication password. public RequestMessagePassword(ServiceName serviceName, string username, byte[] password, byte[] newPassword) : this(serviceName, username, password) { NewPassword = newPassword; } /// /// Called when type specific data need to be saved. /// protected override void SaveData() { base.SaveData(); Write(NewPassword != null); WriteBinaryString(Password); if (NewPassword != null) { WriteBinaryString(NewPassword); } } } }