PublicKeyRequestMessage.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. namespace FxSsh.Messages.Userauth
  5. {
  6. public class PublicKeyRequestMessage : RequestMessage
  7. {
  8. public bool HasSignature { get; private set; }
  9. public string KeyAlgorithmName { get; private set; }
  10. public byte[] PublicKey { get; private set; }
  11. public byte[] Signature { get; private set; }
  12. public byte[] PayloadWithoutSignature { get; private set; }
  13. protected override void OnLoad(SshDataWorker reader)
  14. {
  15. base.OnLoad(reader);
  16. if (MethodName != "publickey")
  17. throw new ArgumentException(string.Format("Method name {0} is not valid.", MethodName));
  18. HasSignature = reader.ReadBoolean();
  19. KeyAlgorithmName = reader.ReadString(Encoding.ASCII);
  20. PublicKey = reader.ReadBinary();
  21. if (HasSignature)
  22. {
  23. Signature = reader.ReadBinary();
  24. PayloadWithoutSignature = RawBytes.Take(RawBytes.Length - Signature.Length - 5).ToArray();
  25. }
  26. }
  27. }
  28. }