diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-17 20:32:13 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-17 20:32:13 +0700 |
commit | 2e1dc7df1b47554ed229b65b9574973b43541a10 (patch) | |
tree | fd8b51ede5fe64ef823d8eb60c5db17e40f31544 /crypto/src/asn1/cms/EnvelopedDataParser.cs | |
parent | FIx fetching of DateOfCertGen extension (diff) | |
download | BouncyCastle.NET-ed25519-2e1dc7df1b47554ed229b65b9574973b43541a10.tar.xz |
Refactoring in Asn1
Diffstat (limited to 'crypto/src/asn1/cms/EnvelopedDataParser.cs')
-rw-r--r-- | crypto/src/asn1/cms/EnvelopedDataParser.cs | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/crypto/src/asn1/cms/EnvelopedDataParser.cs b/crypto/src/asn1/cms/EnvelopedDataParser.cs index a86608bb4..06e10c104 100644 --- a/crypto/src/asn1/cms/EnvelopedDataParser.cs +++ b/crypto/src/asn1/cms/EnvelopedDataParser.cs @@ -2,7 +2,7 @@ using System; namespace Org.BouncyCastle.Asn1.Cms { - /** + /** * Produce an object suitable for an Asn1OutputStream. * <pre> * EnvelopedData ::= SEQUENCE { @@ -14,96 +14,96 @@ namespace Org.BouncyCastle.Asn1.Cms * } * </pre> */ - public class EnvelopedDataParser - { - private Asn1SequenceParser _seq; - private DerInteger _version; - private IAsn1Convertible _nextObject; - private bool _originatorInfoCalled; - - public EnvelopedDataParser( - Asn1SequenceParser seq) - { - this._seq = seq; - this._version = (DerInteger)seq.ReadObject(); - } - - public DerInteger Version - { - get { return _version; } - } - - public OriginatorInfo GetOriginatorInfo() - { - _originatorInfoCalled = true; - - if (_nextObject == null) - { - _nextObject = _seq.ReadObject(); - } - - if (_nextObject is Asn1TaggedObjectParser o) - { - if (o.HasContextTag(0)) - { - Asn1SequenceParser originatorInfo = (Asn1SequenceParser)o.ParseBaseUniversal(false, Asn1Tags.Sequence); - _nextObject = null; - return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object()); - } - } - - return null; - } - - public Asn1SetParser GetRecipientInfos() - { - if (!_originatorInfoCalled) - { - GetOriginatorInfo(); - } - - if (_nextObject == null) - { - _nextObject = _seq.ReadObject(); - } - - Asn1SetParser recipientInfos = (Asn1SetParser)_nextObject; - _nextObject = null; - return recipientInfos; - } - - public EncryptedContentInfoParser GetEncryptedContentInfo() - { - if (_nextObject == null) - { - _nextObject = _seq.ReadObject(); - } - - if (_nextObject != null) - { - Asn1SequenceParser o = (Asn1SequenceParser) _nextObject; - _nextObject = null; - return new EncryptedContentInfoParser(o); - } - - return null; - } - - public Asn1SetParser GetUnprotectedAttrs() - { - if (_nextObject == null) - { - _nextObject = _seq.ReadObject(); - } - - if (_nextObject != null) - { - Asn1TaggedObjectParser o = (Asn1TaggedObjectParser)_nextObject; - _nextObject = null; - return (Asn1SetParser)Asn1Utilities.ParseContextBaseUniversal(o, 1, false, Asn1Tags.SetOf); - } - - return null; - } - } + public class EnvelopedDataParser + { + private Asn1SequenceParser _seq; + private DerInteger _version; + private IAsn1Convertible _nextObject; + private bool _originatorInfoCalled; + + public EnvelopedDataParser( + Asn1SequenceParser seq) + { + this._seq = seq; + this._version = (DerInteger)seq.ReadObject(); + } + + public DerInteger Version + { + get { return _version; } + } + + public OriginatorInfo GetOriginatorInfo() + { + _originatorInfoCalled = true; + + if (_nextObject == null) + { + _nextObject = _seq.ReadObject(); + } + + if (_nextObject is Asn1TaggedObjectParser o) + { + if (o.HasContextTag(0)) + { + Asn1SequenceParser originatorInfo = (Asn1SequenceParser)o.ParseBaseUniversal(false, Asn1Tags.Sequence); + _nextObject = null; + return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object()); + } + } + + return null; + } + + public Asn1SetParser GetRecipientInfos() + { + if (!_originatorInfoCalled) + { + GetOriginatorInfo(); + } + + if (_nextObject == null) + { + _nextObject = _seq.ReadObject(); + } + + Asn1SetParser recipientInfos = (Asn1SetParser)_nextObject; + _nextObject = null; + return recipientInfos; + } + + public EncryptedContentInfoParser GetEncryptedContentInfo() + { + if (_nextObject == null) + { + _nextObject = _seq.ReadObject(); + } + + if (_nextObject != null) + { + Asn1SequenceParser o = (Asn1SequenceParser)_nextObject; + _nextObject = null; + return new EncryptedContentInfoParser(o); + } + + return null; + } + + public Asn1SetParser GetUnprotectedAttrs() + { + if (_nextObject == null) + { + _nextObject = _seq.ReadObject(); + } + + if (_nextObject != null) + { + Asn1TaggedObjectParser o = (Asn1TaggedObjectParser)_nextObject; + _nextObject = null; + return (Asn1SetParser)Asn1Utilities.ParseContextBaseUniversal(o, 1, false, Asn1Tags.SetOf); + } + + return null; + } + } } |