< Summary

Information
Class: Renci.SshNet.Messages.Authentication.RequestMessagePublicKey
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Authentication\RequestMessagePublicKey.cs
Line coverage
89%
Covered lines: 35
Uncovered lines: 4
Coverable lines: 39
Total lines: 106
Line coverage: 89.7%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_PublicKeyAlgorithmName()100%1100%
get_PublicKeyData()100%1100%
get_Signature()100%1100%
get_BufferCapacity()100%2100%
.ctor(...)100%1100%
.ctor(...)100%10%
SaveData()100%2100%
ToString()100%2100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Authentication\RequestMessagePublicKey.cs

#LineLine coverage
 1namespace Renci.SshNet.Messages.Authentication
 2{
 3    /// <summary>
 4    /// Represents "publickey" SSH_MSG_USERAUTH_REQUEST message.
 5    /// </summary>
 6    public class RequestMessagePublicKey : RequestMessage
 7    {
 8        /// <summary>
 9        /// Gets the name of the public key algorithm as ASCII encoded byte array.
 10        /// </summary>
 11        /// <value>
 12        /// The name of the public key algorithm.
 13        /// </value>
 681614        public byte[] PublicKeyAlgorithmName { get; private set; }
 15
 16        /// <summary>
 17        /// Gets the public key data.
 18        /// </summary>
 545219        public byte[] PublicKeyData { get; private set; }
 20
 21        /// <summary>
 22        /// Gets or sets public key signature.
 23        /// </summary>
 24        /// <value>
 25        /// The signature.
 26        /// </value>
 749627        public byte[] Signature { get; set; }
 28
 29        /// <summary>
 30        /// Gets the size of the message in bytes.
 31        /// </summary>
 32        /// <value>
 33        /// The size of the messages in bytes.
 34        /// </value>
 35        protected override int BufferCapacity
 36        {
 37            get
 136438            {
 136439                var capacity = base.BufferCapacity;
 136440                capacity += 1; // Signature flag
 136441                capacity += 4; // PublicKeyAlgorithmName length
 136442                capacity += PublicKeyAlgorithmName.Length; // PublicKeyAlgorithmName
 136443                capacity += 4; // PublicKeyData length
 136444                capacity += PublicKeyData.Length; // PublicKeyData
 45
 136446                if (Signature != null)
 68047                {
 68048                    capacity += 4; // Signature length
 68049                    capacity += Signature.Length; // Signature
 68050                }
 51
 136452                return capacity;
 136453            }
 54        }
 55
 56        /// <summary>
 57        /// Initializes a new instance of the <see cref="RequestMessagePublicKey"/> class.
 58        /// </summary>
 59        /// <param name="serviceName">Name of the service.</param>
 60        /// <param name="username">Authentication username.</param>
 61        /// <param name="keyAlgorithmName">Name of private key algorithm.</param>
 62        /// <param name="keyData">Private key data.</param>
 63        public RequestMessagePublicKey(ServiceName serviceName, string username, string keyAlgorithmName, byte[] keyData
 136464            : base(serviceName, username, "publickey")
 136465        {
 136466            PublicKeyAlgorithmName = Ascii.GetBytes(keyAlgorithmName);
 136467            PublicKeyData = keyData;
 136468        }
 69
 70        /// <summary>
 71        /// Initializes a new instance of the <see cref="RequestMessagePublicKey"/> class.
 72        /// </summary>
 73        /// <param name="serviceName">Name of the service.</param>
 74        /// <param name="username">Authentication username.</param>
 75        /// <param name="keyAlgorithmName">Name of private key algorithm.</param>
 76        /// <param name="keyData">Private key data.</param>
 77        /// <param name="signature">Private key signature.</param>
 78        public RequestMessagePublicKey(ServiceName serviceName, string username, string keyAlgorithmName, byte[] keyData
 079            : this(serviceName, username, keyAlgorithmName, keyData)
 080        {
 081            Signature = signature;
 082        }
 83
 84        /// <summary>
 85        /// Called when type specific data need to be saved.
 86        /// </summary>
 87        protected override void SaveData()
 136488        {
 136489            base.SaveData();
 90
 136491            Write(Signature != null);
 136492            WriteBinaryString(PublicKeyAlgorithmName);
 136493            WriteBinaryString(PublicKeyData);
 136494            if (Signature != null)
 68095            {
 68096                WriteBinaryString(Signature);
 68097            }
 136498        }
 99
 100        /// <inheritdoc/>
 101        public override string ToString()
 1364102        {
 1364103            return $"{base.ToString()} {Ascii.GetString(PublicKeyAlgorithmName)} {(Signature != null ? "with" : "without
 1364104        }
 105    }
 106}