< Summary

Information
Class: Renci.SshNet.Messages.Transport.KeyExchangeInitMessage
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Transport\KeyExchangeInitMessage.cs
Line coverage
100%
Covered lines: 53
Uncovered lines: 0
Coverable lines: 53
Total lines: 183
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Transport\KeyExchangeInitMessage.cs

#LineLine coverage
 1using Renci.SshNet.Abstractions;
 2
 3namespace Renci.SshNet.Messages.Transport
 4{
 5    /// <summary>
 6    /// Represents SSH_MSG_KEXINIT message.
 7    /// </summary>
 8    [Message("SSH_MSG_KEXINIT", 20)]
 9    public class KeyExchangeInitMessage : Message, IKeyExchangedAllowed
 10    {
 11        /// <summary>
 12        /// Initializes a new instance of the <see cref="KeyExchangeInitMessage"/> class.
 13        /// </summary>
 363414        public KeyExchangeInitMessage()
 363415        {
 363416            var cookie = new byte[16];
 363417            CryptoAbstraction.GenerateRandom(cookie);
 363418            Cookie = cookie;
 363419        }
 20
 21        #region Message Properties
 22
 23        /// <summary>
 24        /// Gets session cookie.
 25        /// </summary>
 966626        public byte[] Cookie { get; private set; }
 27
 28        /// <summary>
 29        /// Gets or sets supported key exchange algorithms.
 30        /// </summary>
 31        /// <value>
 32        /// Supported key exchange algorithms.
 33        /// </value>
 966634        public string[] KeyExchangeAlgorithms { get; set; }
 35
 36        /// <summary>
 37        /// Gets or sets supported server host key algorithms.
 38        /// </summary>
 39        /// <value>
 40        /// Supported server host key algorithms.
 41        /// </value>
 785242        public string[] ServerHostKeyAlgorithms { get; set; }
 43
 44        /// <summary>
 45        /// Gets or sets supported encryption algorithms client to server.
 46        /// </summary>
 47        /// <value>
 48        /// Supported encryption algorithms client to server.
 49        /// </value>
 911450        public string[] EncryptionAlgorithmsClientToServer { get; set; }
 51
 52        /// <summary>
 53        /// Gets or sets supported encryption algorithms server to client.
 54        /// </summary>
 55        /// <value>
 56        /// Supported encryption algorithms server to client.
 57        /// </value>
 911458        public string[] EncryptionAlgorithmsServerToClient { get; set; }
 59
 60        /// <summary>
 61        /// Gets or sets supported hash algorithms client to server.
 62        /// </summary>
 63        /// <value>
 64        /// Supported hash algorithms client to server.
 65        /// </value>
 1146166        public string[] MacAlgorithmsClientToServer { get; set; }
 67
 68        /// <summary>
 69        /// Gets or sets supported hash algorithms server to client.
 70        /// </summary>
 71        /// <value>
 72        /// Supported hash algorithms server to client.
 73        /// </value>
 1146174        public string[] MacAlgorithmsServerToClient { get; set; }
 75
 76        /// <summary>
 77        /// Gets or sets supported compression algorithms client to server.
 78        /// </summary>
 79        /// <value>
 80        /// Supported compression algorithms client to server.
 81        /// </value>
 905182        public string[] CompressionAlgorithmsClientToServer { get; set; }
 83
 84        /// <summary>
 85        /// Gets or sets supported compression algorithms server to client.
 86        /// </summary>
 87        /// <value>
 88        /// Supported compression algorithms server to client.
 89        /// </value>
 905190        public string[] CompressionAlgorithmsServerToClient { get; set; }
 91
 92        /// <summary>
 93        /// Gets or sets supported languages client to server.
 94        /// </summary>
 95        /// <value>
 96        /// Supported languages client to server.
 97        /// </value>
 785298        public string[] LanguagesClientToServer { get; set; }
 99
 100        /// <summary>
 101        /// Gets or sets supported languages server to client.
 102        /// </summary>
 103        /// <value>
 104        /// The languages server to client.
 105        /// </value>
 7852106        public string[] LanguagesServerToClient { get; set; }
 107
 108        /// <summary>
 109        /// Gets or sets a value indicating whether first key exchange packet follows.
 110        /// </summary>
 111        /// <value>
 112        /// <see langword="true"/> if first key exchange packet follows; otherwise, <see langword="false"/>.
 113        /// </value>
 7237114        public bool FirstKexPacketFollows { get; set; }
 115
 116        /// <summary>
 117        /// Gets or sets the reserved value.
 118        /// </summary>
 119        /// <value>
 120        /// The reserved value.
 121        /// </value>
 7237122        public uint Reserved { get; set; }
 123
 124        #endregion
 125
 126        /// <summary>
 127        /// Gets the size of the message in bytes.
 128        /// </summary>
 129        /// <value>
 130        /// <c>-1</c> to indicate that the size of the message cannot be determined,
 131        /// or is too costly to calculate.
 132        /// </value>
 133        protected override int BufferCapacity
 134        {
 12645135            get { return -1; }
 136        }
 137
 138        /// <summary>
 139        /// Called when type specific data need to be loaded.
 140        /// </summary>
 141        protected override void LoadData()
 1817142        {
 1817143            Cookie = ReadBytes(16);
 1817144            KeyExchangeAlgorithms = ReadNamesList();
 1817145            ServerHostKeyAlgorithms = ReadNamesList();
 1817146            EncryptionAlgorithmsClientToServer = ReadNamesList();
 1817147            EncryptionAlgorithmsServerToClient = ReadNamesList();
 1817148            MacAlgorithmsClientToServer = ReadNamesList();
 1817149            MacAlgorithmsServerToClient = ReadNamesList();
 1817150            CompressionAlgorithmsClientToServer = ReadNamesList();
 1817151            CompressionAlgorithmsServerToClient = ReadNamesList();
 1817152            LanguagesClientToServer = ReadNamesList();
 1817153            LanguagesServerToClient = ReadNamesList();
 1817154            FirstKexPacketFollows = ReadBoolean();
 1817155            Reserved = ReadUInt32();
 1817156        }
 157
 158        /// <summary>
 159        /// Called when type specific data need to be saved.
 160        /// </summary>
 161        protected override void SaveData()
 4215162        {
 4215163            Write(Cookie);
 4215164            Write(KeyExchangeAlgorithms);
 4215165            Write(ServerHostKeyAlgorithms);
 4215166            Write(EncryptionAlgorithmsClientToServer);
 4215167            Write(EncryptionAlgorithmsServerToClient);
 4215168            Write(MacAlgorithmsClientToServer);
 4215169            Write(MacAlgorithmsServerToClient);
 4215170            Write(CompressionAlgorithmsClientToServer);
 4215171            Write(CompressionAlgorithmsServerToClient);
 4215172            Write(LanguagesClientToServer);
 4215173            Write(LanguagesServerToClient);
 4215174            Write(FirstKexPacketFollows);
 4215175            Write(Reserved);
 4215176        }
 177
 178        internal override void Process(Session session)
 1814179        {
 1814180            session.OnKeyExchangeInitReceived(this);
 1814181        }
 182    }
 183}