ObjectIdentifier
Describes object identifier for DER encoding.
using System;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
namespace Renci.SshNet.Common
{
public struct ObjectIdentifier
{
public ulong[] Identifiers {
[IsReadOnly]
get;
private set;
}
public ObjectIdentifier(params ulong[] identifiers)
{
if (identifiers == null)
throw new ArgumentNullException("identifiers");
if (identifiers.Length < 2)
throw new ArgumentException("Must contain at least two elements.", "identifiers");
Identifiers = identifiers;
}
internal static ObjectIdentifier FromHashAlgorithmName(HashAlgorithmName hashAlgorithmName)
{
string text = CryptoConfig.MapNameToOID(hashAlgorithmName.Name);
if (text == null)
throw new ArgumentException($"""{hashAlgorithmName}""", "hashAlgorithmName");
return new ObjectIdentifier(text.Split('.', StringSplitOptions.None).Select(ulong.Parse).ToArray());
}
}
}