PublicKeyMessage.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. namespace Renci.SshNet.Messages.Authentication
  2. {
  3. /// <summary>
  4. /// Represents SSH_MSG_USERAUTH_PK_OK message.
  5. /// </summary>
  6. [Message("SSH_MSG_USERAUTH_PK_OK", 60)]
  7. internal class PublicKeyMessage : Message
  8. {
  9. /// <summary>
  10. /// Gets the name of the public key algorithm.
  11. /// </summary>
  12. /// <value>
  13. /// The name of the public key algorithm.
  14. /// </value>
  15. public string PublicKeyAlgorithmName { get; private set; }
  16. /// <summary>
  17. /// Gets the public key data.
  18. /// </summary>
  19. public byte[] PublicKeyData { get; private set; }
  20. /// <summary>
  21. /// Called when type specific data need to be loaded.
  22. /// </summary>
  23. protected override void LoadData()
  24. {
  25. this.PublicKeyAlgorithmName = this.ReadAsciiString();
  26. this.PublicKeyData = this.ReadBinaryString();
  27. }
  28. /// <summary>
  29. /// Called when type specific data need to be saved.
  30. /// </summary>
  31. protected override void SaveData()
  32. {
  33. this.WriteAscii(this.PublicKeyAlgorithmName);
  34. this.WriteBinaryString(this.PublicKeyData);
  35. }
  36. }
  37. }