diff options
Diffstat (limited to 'crypto/src/asn1/cms/OriginatorPublicKey.cs')
-rw-r--r-- | crypto/src/asn1/cms/OriginatorPublicKey.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/src/asn1/cms/OriginatorPublicKey.cs b/crypto/src/asn1/cms/OriginatorPublicKey.cs index 6ed017877..eb302c00b 100644 --- a/crypto/src/asn1/cms/OriginatorPublicKey.cs +++ b/crypto/src/asn1/cms/OriginatorPublicKey.cs @@ -1,3 +1,5 @@ +using System; + using Org.BouncyCastle.Asn1.X509; namespace Org.BouncyCastle.Asn1.Cms @@ -29,12 +31,16 @@ namespace Org.BouncyCastle.Asn1.Cms public OriginatorPublicKey(AlgorithmIdentifier algorithm, DerBitString publicKey) { - m_algorithm = algorithm; - m_publicKey = publicKey; + m_algorithm = algorithm ?? throw new ArgumentNullException(nameof(algorithm)); + m_publicKey = publicKey ?? throw new ArgumentNullException(nameof(publicKey)); } private OriginatorPublicKey(Asn1Sequence seq) { + int count = seq.Count; + if (count != 2) + throw new ArgumentException("Bad sequence size: " + count, nameof(seq)); + m_algorithm = AlgorithmIdentifier.GetInstance(seq[0]); m_publicKey = DerBitString.GetInstance(seq[1]); } |