| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | using Renci.SshNet.Common; |
| | | 4 | | |
| | | 5 | | namespace Renci.SshNet.Security |
| | | 6 | | { |
| | | 7 | | internal sealed class KeyExchangeHashData : SshData |
| | | 8 | | { |
| | | 9 | | private byte[] _serverVersion; |
| | | 10 | | private byte[] _clientVersion; |
| | | 11 | | |
| | | 12 | | public string ServerVersion |
| | | 13 | | { |
| | 0 | 14 | | private get { return Utf8.GetString(_serverVersion, 0, _serverVersion.Length); } |
| | 7155 | 15 | | set { _serverVersion = Utf8.GetBytes(value); } |
| | | 16 | | } |
| | | 17 | | |
| | | 18 | | public string ClientVersion |
| | | 19 | | { |
| | 0 | 20 | | private get { return Utf8.GetString(_clientVersion, 0, _clientVersion.Length); } |
| | 7155 | 21 | | set { _clientVersion = Utf8.GetBytes(value); } |
| | | 22 | | } |
| | | 23 | | |
| | 7155 | 24 | | public byte[] ClientPayload { get; set; } |
| | | 25 | | |
| | 7155 | 26 | | public byte[] ServerPayload { get; set; } |
| | | 27 | | |
| | 7155 | 28 | | public byte[] HostKey { get; set; } |
| | | 29 | | |
| | 7155 | 30 | | public byte[] ClientExchangeValue { get; set; } |
| | | 31 | | |
| | 7155 | 32 | | public byte[] ServerExchangeValue { get; set; } |
| | | 33 | | |
| | 7155 | 34 | | public byte[] SharedKey { get; set; } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets the size of the message in bytes. |
| | | 38 | | /// </summary> |
| | | 39 | | /// <value> |
| | | 40 | | /// The size of the messages in bytes. |
| | | 41 | | /// </value> |
| | | 42 | | protected override int BufferCapacity |
| | | 43 | | { |
| | | 44 | | get |
| | 2385 | 45 | | { |
| | 2385 | 46 | | var capacity = base.BufferCapacity; |
| | 2385 | 47 | | capacity += 4; // ClientVersion length |
| | 2385 | 48 | | capacity += _clientVersion.Length; // ClientVersion |
| | 2385 | 49 | | capacity += 4; // ServerVersion length |
| | 2385 | 50 | | capacity += _serverVersion.Length; // ServerVersion |
| | 2385 | 51 | | capacity += 4; // ClientPayload length |
| | 2385 | 52 | | capacity += ClientPayload.Length; // ClientPayload |
| | 2385 | 53 | | capacity += 4; // ServerPayload length |
| | 2385 | 54 | | capacity += ServerPayload.Length; // ServerPayload |
| | 2385 | 55 | | capacity += 4; // HostKey length |
| | 2385 | 56 | | capacity += HostKey.Length; // HostKey |
| | 2385 | 57 | | capacity += 4; // ClientExchangeValue length |
| | 2385 | 58 | | capacity += ClientExchangeValue.Length; // ClientExchangeValue |
| | 2385 | 59 | | capacity += 4; // ServerExchangeValue length |
| | 2385 | 60 | | capacity += ServerExchangeValue.Length; // ServerExchangeValue |
| | 2385 | 61 | | capacity += 4; // SharedKey length |
| | 2385 | 62 | | capacity += SharedKey.Length; // SharedKey |
| | 2385 | 63 | | return capacity; |
| | 2385 | 64 | | } |
| | | 65 | | } |
| | | 66 | | |
| | | 67 | | protected override void LoadData() |
| | 0 | 68 | | { |
| | 0 | 69 | | throw new NotImplementedException(); |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | protected override void SaveData() |
| | 2385 | 73 | | { |
| | 2385 | 74 | | WriteBinaryString(_clientVersion); |
| | 2385 | 75 | | WriteBinaryString(_serverVersion); |
| | 2385 | 76 | | WriteBinaryString(ClientPayload); |
| | 2385 | 77 | | WriteBinaryString(ServerPayload); |
| | 2385 | 78 | | WriteBinaryString(HostKey); |
| | 2385 | 79 | | WriteBinaryString(ClientExchangeValue); |
| | 2385 | 80 | | WriteBinaryString(ServerExchangeValue); |
| | 2385 | 81 | | WriteBinaryString(SharedKey); |
| | 2385 | 82 | | } |
| | | 83 | | } |
| | | 84 | | } |