From c2d847a1bf7570dffdbc3980515c2e0c559e9989 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 21 Jul 2021 23:51:00 +0700 Subject: Hold boolean instead of the parser --- crypto/src/asn1/cms/AuthEnvelopedDataParser.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'crypto/src') diff --git a/crypto/src/asn1/cms/AuthEnvelopedDataParser.cs b/crypto/src/asn1/cms/AuthEnvelopedDataParser.cs index 950040b26..1e1e72c02 100644 --- a/crypto/src/asn1/cms/AuthEnvelopedDataParser.cs +++ b/crypto/src/asn1/cms/AuthEnvelopedDataParser.cs @@ -22,7 +22,7 @@ namespace Org.BouncyCastle.Asn1.Cms private DerInteger version; private IAsn1Convertible nextObject; private bool originatorInfoCalled; - private EncryptedContentInfoParser authEncryptedContentInfoParser; + private bool isData; public AuthEnvelopedDataParser( Asn1SequenceParser seq) @@ -87,8 +87,9 @@ namespace Org.BouncyCastle.Asn1.Cms { Asn1SequenceParser o = (Asn1SequenceParser) nextObject; nextObject = null; - authEncryptedContentInfoParser = new EncryptedContentInfoParser(o); - return authEncryptedContentInfoParser; + EncryptedContentInfoParser encryptedContentInfoParser = new EncryptedContentInfoParser(o); + isData = CmsObjectIdentifiers.Data.Equals(encryptedContentInfoParser.ContentType); + return encryptedContentInfoParser; } return null; @@ -110,7 +111,7 @@ namespace Org.BouncyCastle.Asn1.Cms // "The authAttrs MUST be present if the content type carried in // EncryptedContentInfo is not id-data." - if (!authEncryptedContentInfoParser.ContentType.Equals(CmsObjectIdentifiers.Data)) + if (!isData) throw new Asn1ParsingException("authAttrs must be present with non-data content"); return null; -- cgit 1.5.1