< Summary

Information
Class: Renci.SshNet.Security.Cryptography.HMACSHA1
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\Cryptography\HMACSHA1.cs
Line coverage
69%
Covered lines: 9
Uncovered lines: 4
Coverable lines: 13
Total lines: 66
Line coverage: 69.2%
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
.ctor(...)100%10%
.ctor(...)100%1100%
get_HashSize()100%1100%
HashFinal()100%1100%

File(s)

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

#LineLine coverage
 1using System.Security.Cryptography;
 2
 3using Renci.SshNet.Common;
 4
 5namespace Renci.SshNet.Security.Cryptography
 6{
 7    /// <summary>
 8    /// Computes a Hash-based Message Authentication Code (HMAC) by using the <see cref="SHA1"/> hash function.
 9    /// </summary>
 10    public class HMACSHA1 : System.Security.Cryptography.HMACSHA1
 11    {
 12        private readonly int _hashSize;
 13
 14        /// <summary>
 15        /// Initializes a new instance of the <see cref="HMACSHA1"/> class with the specified key.
 16        /// </summary>
 17        /// <param name="key">The key.</param>
 18        public HMACSHA1(byte[] key)
 19#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms
 020            : base(key)
 21#pragma warning restore CA5350 // Do Not Use Weak Cryptographic Algorithms
 022        {
 23#pragma warning disable MA0056 // Do not call overridable members in constructor
 024            _hashSize = base.HashSize;
 25#pragma warning restore MA0056 // Do not call overridable members in constructor
 026        }
 27
 28        /// <summary>
 29        /// Initializes a new instance of the <see cref="HMACSHA1"/> class with the specified key and size of the comput
 30        /// </summary>
 31        /// <param name="key">The key.</param>
 32        /// <param name="hashSize">The size, in bits, of the computed hash code.</param>
 33        public HMACSHA1(byte[] key, int hashSize)
 34#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms
 635            : base(key)
 36#pragma warning restore CA5350 // Do Not Use Weak Cryptographic Algorithms
 637        {
 638            _hashSize = hashSize;
 639        }
 40
 41        /// <summary>
 42        /// Gets the size, in bits, of the computed hash code.
 43        /// </summary>
 44        /// <value>
 45        /// The size, in bits, of the computed hash code.
 46        /// </value>
 47        public override int HashSize
 48        {
 27049            get { return _hashSize; }
 50        }
 51
 52        /// <summary>
 53        /// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
 54        /// </summary>
 55        /// <returns>
 56        /// The computed hash code.
 57        /// </returns>
 58        protected override byte[] HashFinal()
 5859        {
 60#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms
 5861            var hash = base.HashFinal();
 62#pragma warning restore CA5350 // Do Not Use Weak Cryptographic Algorithms
 5863            return hash.Take(HashSize / 8);
 5864        }
 65    }
 66}