< Summary

Information
Class: Renci.SshNet.Common.ObjectIdentifier
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Common\ObjectIdentifier.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 54
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_Identifiers()100%1100%
.ctor(...)100%4100%
FromHashAlgorithmName(...)100%4100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Common\ObjectIdentifier.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3using System.Security.Cryptography;
 4
 5namespace Renci.SshNet.Common
 6{
 7    /// <summary>
 8    /// Describes object identifier for DER encoding.
 9    /// </summary>
 10#pragma warning disable CA1815 // Override equals and operator equals on value types
 11    public struct ObjectIdentifier
 12#pragma warning restore CA1815 // Override equals and operator equals on value types
 13    {
 14        /// <summary>
 15        /// Gets the object identifier.
 16        /// </summary>
 1229817        public ulong[] Identifiers { get; private set; }
 18
 19        /// <summary>
 20        /// Initializes a new instance of the <see cref="ObjectIdentifier"/> struct.
 21        /// </summary>
 22        /// <param name="identifiers">The identifiers.</param>
 23        /// <exception cref="ArgumentNullException"><paramref name="identifiers"/> is <see langword="null"/>.</exception
 24        /// <exception cref="ArgumentException"><paramref name="identifiers"/> has less than two elements.</exception>
 25        public ObjectIdentifier(params ulong[] identifiers)
 277426        {
 277427            if (identifiers is null)
 328            {
 329                throw new ArgumentNullException(nameof(identifiers));
 30            }
 31
 277132            if (identifiers.Length < 2)
 333            {
 334                throw new ArgumentException("Must contain at least two elements.", nameof(identifiers));
 35            }
 36
 276837            Identifiers = identifiers;
 276838        }
 39
 40        internal static ObjectIdentifier FromHashAlgorithmName(HashAlgorithmName hashAlgorithmName)
 277141        {
 277142            var oid = CryptoConfig.MapNameToOID(hashAlgorithmName.Name);
 43
 277144            if (oid is null)
 345            {
 346                throw new ArgumentException($"Could not map `{hashAlgorithmName}` to OID.", nameof(hashAlgorithmName));
 47            }
 48
 276849            var identifiers = oid.Split('.').Select(ulong.Parse).ToArray();
 50
 276851            return new ObjectIdentifier(identifiers);
 276852        }
 53    }
 54}