summary refs log tree commit diff
path: root/crypto/src/asn1/cms/OtherRecipientInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/cms/OtherRecipientInfo.cs')
-rw-r--r--crypto/src/asn1/cms/OtherRecipientInfo.cs37
1 files changed, 16 insertions, 21 deletions
diff --git a/crypto/src/asn1/cms/OtherRecipientInfo.cs b/crypto/src/asn1/cms/OtherRecipientInfo.cs
index 989b6183e..b47a256f9 100644
--- a/crypto/src/asn1/cms/OtherRecipientInfo.cs
+++ b/crypto/src/asn1/cms/OtherRecipientInfo.cs
@@ -1,3 +1,5 @@
+using System;
+
 namespace Org.BouncyCastle.Asn1.Cms
 {
     public class OtherRecipientInfo
@@ -17,32 +19,28 @@ namespace Org.BouncyCastle.Asn1.Cms
             return new OtherRecipientInfo(Asn1Sequence.GetInstance(obj, explicitly));
         }
 
-        private readonly DerObjectIdentifier oriType;
-        private readonly Asn1Encodable oriValue;
+        private readonly DerObjectIdentifier m_oriType;
+        private readonly Asn1Encodable m_oriValue;
 
-        public OtherRecipientInfo(
-            DerObjectIdentifier	oriType,
-            Asn1Encodable		oriValue)
+        public OtherRecipientInfo(DerObjectIdentifier oriType, Asn1Encodable oriValue)
         {
-            this.oriType = oriType;
-            this.oriValue = oriValue;
+            m_oriType = oriType ?? throw new ArgumentNullException(nameof(oriType));
+            m_oriValue = oriValue ?? throw new ArgumentNullException(nameof(oriValue));
         }
 
         private OtherRecipientInfo(Asn1Sequence seq)
         {
-            oriType = DerObjectIdentifier.GetInstance(seq[0]);
-            oriValue = seq[1];
-        }
+            int count = seq.Count;
+            if (count != 2)
+                throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
 
-        public virtual DerObjectIdentifier OriType
-        {
-            get { return oriType; }
+            m_oriType = DerObjectIdentifier.GetInstance(seq[0]);
+            m_oriValue = seq[1];
         }
 
-        public virtual Asn1Encodable OriValue
-        {
-            get { return oriValue; }
-        }
+        public virtual DerObjectIdentifier OriType => m_oriType;
+
+        public virtual Asn1Encodable OriValue => m_oriValue;
 
         /**
          * Produce an object suitable for an Asn1OutputStream.
@@ -52,9 +50,6 @@ namespace Org.BouncyCastle.Asn1.Cms
          *    oriValue ANY DEFINED BY oriType }
          * </pre>
          */
-        public override Asn1Object ToAsn1Object()
-        {
-            return new DerSequence(oriType, oriValue);
-        }
+        public override Asn1Object ToAsn1Object() => new DerSequence(m_oriType, m_oriValue);
     }
 }