< Summary

Information
Class: Renci.SshNet.Security.KeyExchangeEC
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\KeyExchangeEC.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 94
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

MethodBranch coverage Cyclomatic complexity Line coverage
CalculateHash()100%1100%
ValidateExchangeHash()100%1100%
Start(...)100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\KeyExchangeEC.cs

#LineLine coverage
 1using Renci.SshNet.Messages.Transport;
 2
 3namespace Renci.SshNet.Security
 4{
 5    internal abstract class KeyExchangeEC : KeyExchange
 6    {
 7#pragma warning disable SA1401 // Fields should be private
 8        /// <summary>
 9        /// Specifies client payload.
 10        /// </summary>
 11        protected byte[] _clientPayload;
 12
 13        /// <summary>
 14        /// Specifies server payload.
 15        /// </summary>
 16        protected byte[] _serverPayload;
 17
 18        /// <summary>
 19        /// Specifies client exchange.
 20        /// </summary>
 21        protected byte[] _clientExchangeValue;
 22
 23        /// <summary>
 24        /// Specifies server exchange.
 25        /// </summary>
 26        protected byte[] _serverExchangeValue;
 27
 28        /// <summary>
 29        /// Specifies host key data.
 30        /// </summary>
 31        protected byte[] _hostKey;
 32
 33        /// <summary>
 34        /// Specifies signature data.
 35        /// </summary>
 36        protected byte[] _signature;
 37#pragma warning restore SA1401 // Fields should be private
 38
 39        /// <summary>
 40        /// Gets the size, in bits, of the computed hash code.
 41        /// </summary>
 42        /// <value>
 43        /// The size, in bits, of the computed hash code.
 44        /// </value>
 45        protected abstract int HashSize { get; }
 46
 47        /// <summary>
 48        /// Calculates key exchange hash value.
 49        /// </summary>
 50        /// <returns>
 51        /// Key exchange hash.
 52        /// </returns>
 53        protected override byte[] CalculateHash()
 236154        {
 236155            var hashData = new KeyExchangeHashData
 236156                {
 236157                    ClientVersion = Session.ClientVersion,
 236158                    ServerVersion = Session.ServerVersion,
 236159                    ClientPayload = _clientPayload,
 236160                    ServerPayload = _serverPayload,
 236161                    HostKey = _hostKey,
 236162                    ClientExchangeValue = _clientExchangeValue,
 236163                    ServerExchangeValue = _serverExchangeValue,
 236164                    SharedKey = SharedKey,
 236165                };
 66
 236167            return Hash(hashData.GetBytes());
 236168        }
 69
 70        /// <summary>
 71        /// Validates the exchange hash.
 72        /// </summary>
 73        /// <returns>
 74        /// true if exchange hash is valid; otherwise false.
 75        /// </returns>
 76        protected override bool ValidateExchangeHash()
 118177        {
 118178            return ValidateExchangeHash(_hostKey, _signature);
 118179        }
 80
 81        /// <summary>
 82        /// Starts key exchange algorithm.
 83        /// </summary>
 84        /// <param name="session">The session.</param>
 85        /// <param name="message">Key exchange init message.</param>
 86        public override void Start(Session session, KeyExchangeInitMessage message)
 118187        {
 118188            base.Start(session, message);
 89
 118190            _serverPayload = message.GetBytes();
 118191            _clientPayload = Session.ClientInitMessage.GetBytes();
 118192        }
 93   }
 94}