<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0-beta.98" />

OtherHashAlgAndValue

Summary description for OtherHashAlgAndValue.
using Org.BouncyCastle.Asn1.X509; using System; namespace Org.BouncyCastle.Asn1.Esf { public class OtherHashAlgAndValue : Asn1Encodable { private readonly AlgorithmIdentifier m_hashAlgorithm; private readonly Asn1OctetString m_hashValue; public AlgorithmIdentifier HashAlgorithm => m_hashAlgorithm; public static OtherHashAlgAndValue GetInstance(object obj) { if (obj == null) return null; OtherHashAlgAndValue otherHashAlgAndValue = obj as OtherHashAlgAndValue; if (otherHashAlgAndValue != null) return otherHashAlgAndValue; return new OtherHashAlgAndValue(Asn1Sequence.GetInstance(obj)); } public static OtherHashAlgAndValue GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new OtherHashAlgAndValue(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } public static OtherHashAlgAndValue GetOptional(Asn1Encodable element) { if (element == null) throw new ArgumentNullException("element"); OtherHashAlgAndValue otherHashAlgAndValue = element as OtherHashAlgAndValue; if (otherHashAlgAndValue != null) return otherHashAlgAndValue; Asn1Sequence optional = Asn1Sequence.GetOptional(element); if (optional != null) return new OtherHashAlgAndValue(optional); return null; } public static OtherHashAlgAndValue GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new OtherHashAlgAndValue(Asn1Sequence.GetTagged(taggedObject, declaredExplicit)); } private OtherHashAlgAndValue(Asn1Sequence seq) { int count = seq.Count; if (count != 2) throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq"); m_hashAlgorithm = AlgorithmIdentifier.GetInstance(seq[0]); m_hashValue = Asn1OctetString.GetInstance(seq[1]); } public OtherHashAlgAndValue(AlgorithmIdentifier hashAlgorithm, byte[] hashValue) { if (hashAlgorithm == null) throw new ArgumentNullException("hashAlgorithm"); m_hashAlgorithm = hashAlgorithm; m_hashValue = DerOctetString.FromContents(hashValue); } public OtherHashAlgAndValue(AlgorithmIdentifier hashAlgorithm, Asn1OctetString hashValue) { if (hashAlgorithm == null) throw new ArgumentNullException("hashAlgorithm"); m_hashAlgorithm = hashAlgorithm; if (hashValue == null) throw new ArgumentNullException("hashValue"); m_hashValue = hashValue; } public byte[] GetHashValue() { return m_hashValue.GetOctets(); } public override Asn1Object ToAsn1Object() { return new DerSequence(m_hashAlgorithm, m_hashValue); } } }