namespace Renci.SshNet.Messages.Authentication { /// /// Represents SSH_MSG_USERAUTH_PK_OK message. /// [Message("SSH_MSG_USERAUTH_PK_OK", 60)] internal class PublicKeyMessage : Message { /// /// Gets the name of the public key algorithm as ASCII encoded byte array. /// /// /// The name of the public key algorithm. /// public byte[] PublicKeyAlgorithmName { get; private set; } /// /// Gets the public key data. /// public byte[] PublicKeyData { 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; // PublicKeyAlgorithmName length capacity += PublicKeyAlgorithmName.Length; // PublicKeyAlgorithmName capacity += 4; // PublicKeyData length capacity += PublicKeyData.Length; // PublicKeyData return capacity; } } internal override void Process(Session session) { session.OnUserAuthenticationPublicKeyReceived(this); } /// /// Called when type specific data need to be loaded. /// protected override void LoadData() { PublicKeyAlgorithmName = ReadBinary(); PublicKeyData = ReadBinary(); } /// /// Called when type specific data need to be saved. /// protected override void SaveData() { WriteBinaryString(PublicKeyAlgorithmName); WriteBinaryString(PublicKeyData); } } }