< Summary

Information
Class: Renci.SshNet.Security.Cryptography.HMACMD5
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\Cryptography\HMACMD5.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\HMACMD5.cs

#LineLine coverage
 1using System.Security.Cryptography;
 2using Renci.SshNet.Common;
 3
 4namespace Renci.SshNet.Security.Cryptography
 5{
 6    /// <summary>
 7    /// Computes a Hash-based Message Authentication Code (HMAC) by using the <see cref="MD5"/> hash function.
 8    /// </summary>
 9    public class HMACMD5 : System.Security.Cryptography.HMACMD5
 10    {
 11        private readonly int _hashSize;
 12
 13        /// <summary>
 14        /// Initializes a new instance of the <see cref="HMACMD5"/> class with the specified key.
 15        /// </summary>
 16        /// <param name="key">The key.</param>
 17        public HMACMD5(byte[] key)
 18#pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms
 019            : base(key)
 20#pragma warning restore CA5351 // Do Not Use Broken Cryptographic Algorithms
 021        {
 22#pragma warning disable MA0056 // Do not call overridable members in constructor
 023            _hashSize = base.HashSize;
 24#pragma warning restore MA0056 // Do not call overridable members in constructor
 025        }
 26
 27        /// <summary>
 28        /// Initializes a new instance of the <see cref="HMACMD5"/> class with the specified key
 29        /// and size of the computed hash code.
 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 HMACMD5(byte[] key, int hashSize)
 34#pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms
 635            : base(key)
 36#pragma warning restore CA5351 // Do Not Use Broken 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 CA5351 // Do Not Use Broken Cryptographic Algorithms
 5861            var hash = base.HashFinal();
 62#pragma warning restore CA5351 // Do Not Use Broken Cryptographic Algorithms
 5863            return hash.Take(HashSize / 8);
 5864        }
 65    }
 66}