diff options
Diffstat (limited to 'crypto/src/asn1/cms/Attribute.cs')
-rw-r--r-- | crypto/src/asn1/cms/Attribute.cs | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/crypto/src/asn1/cms/Attribute.cs b/crypto/src/asn1/cms/Attribute.cs index 9e2ced198..f44646bbc 100644 --- a/crypto/src/asn1/cms/Attribute.cs +++ b/crypto/src/asn1/cms/Attribute.cs @@ -23,34 +23,29 @@ namespace Org.BouncyCastle.Asn1.Cms #pragma warning restore CS0618 // Type or member is obsolete } - private DerObjectIdentifier attrType; - private Asn1Set attrValues; + private readonly DerObjectIdentifier m_attrType; + private readonly Asn1Set m_attrValues; [Obsolete("Use 'GetInstance' instead")] - public Attribute( - Asn1Sequence seq) + public Attribute(Asn1Sequence seq) { - attrType = (DerObjectIdentifier)seq[0]; - attrValues = (Asn1Set)seq[1]; + int count = seq.Count; + if (count != 2) + throw new ArgumentException("Bad sequence size: " + count, nameof(seq)); + + m_attrType = DerObjectIdentifier.GetInstance(seq[0]); + m_attrValues = Asn1Set.GetInstance(seq[1]); } - public Attribute( - DerObjectIdentifier attrType, - Asn1Set attrValues) + public Attribute(DerObjectIdentifier attrType, Asn1Set attrValues) { - this.attrType = attrType; - this.attrValues = attrValues; + m_attrType = attrType ?? throw new ArgumentNullException(nameof(attrType)); + m_attrValues = attrValues ?? throw new ArgumentNullException(nameof(attrValues)); } - public DerObjectIdentifier AttrType - { - get { return attrType; } - } + public DerObjectIdentifier AttrType => m_attrType; - public Asn1Set AttrValues - { - get { return attrValues; } - } + public Asn1Set AttrValues => m_attrValues; /** * Produce an object suitable for an Asn1OutputStream. @@ -61,9 +56,6 @@ namespace Org.BouncyCastle.Asn1.Cms * } * </pre> */ - public override Asn1Object ToAsn1Object() - { - return new DerSequence(attrType, attrValues); - } + public override Asn1Object ToAsn1Object() => new DerSequence(m_attrType, m_attrValues); } } |