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

OtherKeyAttribute

using System; namespace Org.BouncyCastle.Asn1.Cms { public class OtherKeyAttribute : Asn1Encodable { private readonly DerObjectIdentifier m_keyAttrId; private readonly Asn1Encodable m_keyAttr; public DerObjectIdentifier KeyAttrId => m_keyAttrId; public Asn1Encodable KeyAttr => m_keyAttr; public static OtherKeyAttribute GetInstance(object obj) { if (obj == null) return null; OtherKeyAttribute otherKeyAttribute = obj as OtherKeyAttribute; if (otherKeyAttribute != null) return otherKeyAttribute; return new OtherKeyAttribute(Asn1Sequence.GetInstance(obj)); } public static OtherKeyAttribute GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new OtherKeyAttribute(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } public static OtherKeyAttribute GetOptional(Asn1Encodable element) { if (element == null) throw new ArgumentNullException("element"); OtherKeyAttribute otherKeyAttribute = element as OtherKeyAttribute; if (otherKeyAttribute != null) return otherKeyAttribute; Asn1Sequence optional = Asn1Sequence.GetOptional(element); if (optional != null) return new OtherKeyAttribute(optional); return null; } public static OtherKeyAttribute GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) { return new OtherKeyAttribute(Asn1Sequence.GetTagged(taggedObject, declaredExplicit)); } [Obsolete("Use 'GetInstance' instead")] public OtherKeyAttribute(Asn1Sequence seq) { int count = seq.Count; if (count < 1 || count > 2) throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq"); m_keyAttrId = DerObjectIdentifier.GetInstance(seq[0]); m_keyAttr = ((count == 1) ? null : seq[1]); } public OtherKeyAttribute(DerObjectIdentifier keyAttrId, Asn1Encodable keyAttr) { if (keyAttrId == null) throw new ArgumentNullException("keyAttrId"); m_keyAttrId = keyAttrId; m_keyAttr = keyAttr; } public override Asn1Object ToAsn1Object() { if (m_keyAttr != null) return new DerSequence(m_keyAttrId, m_keyAttr); return new DerSequence(m_keyAttrId); } } }