GetInstance() public static méthode

public static GetInstance ( Asn1TaggedObject obj, bool explicitly ) : OriginatorInfo
obj Org.BouncyCastle.Asn1.Asn1TaggedObject
explicitly bool
Résultat OriginatorInfo
        private AuthEnvelopedData(Asn1Sequence seq)
        {
            int        num        = 0;
            Asn1Object asn1Object = seq[num++].ToAsn1Object();

            this.version = (DerInteger)asn1Object;
            asn1Object   = seq[num++].ToAsn1Object();
            if (asn1Object is Asn1TaggedObject)
            {
                this.originatorInfo = OriginatorInfo.GetInstance((Asn1TaggedObject)asn1Object, false);
                asn1Object          = seq[num++].ToAsn1Object();
            }
            this.recipientInfos           = Asn1Set.GetInstance(asn1Object);
            asn1Object                    = seq[num++].ToAsn1Object();
            this.authEncryptedContentInfo = EncryptedContentInfo.GetInstance(asn1Object);
            asn1Object                    = seq[num++].ToAsn1Object();
            if (asn1Object is Asn1TaggedObject)
            {
                this.authAttrs = Asn1Set.GetInstance((Asn1TaggedObject)asn1Object, false);
                asn1Object     = seq[num++].ToAsn1Object();
            }
            this.mac = Asn1OctetString.GetInstance(asn1Object);
            if (seq.Count > num)
            {
                asn1Object       = seq[num++].ToAsn1Object();
                this.unauthAttrs = Asn1Set.GetInstance((Asn1TaggedObject)asn1Object, false);
            }
        }
Exemple #2
0
        private AuthenticatedData(Asn1Sequence seq)
        {
            int num = 0;

            this.version = (DerInteger)seq[num++];
            Asn1Encodable asn1Encodable = seq[num++];

            if (asn1Encodable is Asn1TaggedObject)
            {
                this.originatorInfo = OriginatorInfo.GetInstance((Asn1TaggedObject)asn1Encodable, false);
                asn1Encodable       = seq[num++];
            }
            this.recipientInfos = Asn1Set.GetInstance(asn1Encodable);
            this.macAlgorithm   = AlgorithmIdentifier.GetInstance(seq[num++]);
            asn1Encodable       = seq[num++];
            if (asn1Encodable is Asn1TaggedObject)
            {
                this.digestAlgorithm = AlgorithmIdentifier.GetInstance((Asn1TaggedObject)asn1Encodable, false);
                asn1Encodable        = seq[num++];
            }
            this.encapsulatedContentInfo = ContentInfo.GetInstance(asn1Encodable);
            asn1Encodable = seq[num++];
            if (asn1Encodable is Asn1TaggedObject)
            {
                this.authAttrs = Asn1Set.GetInstance((Asn1TaggedObject)asn1Encodable, false);
                asn1Encodable  = seq[num++];
            }
            this.mac = Asn1OctetString.GetInstance(asn1Encodable);
            if (seq.Count > num)
            {
                this.unauthAttrs = Asn1Set.GetInstance((Asn1TaggedObject)seq[num], false);
            }
        }
Exemple #3
0
        private AuthEnvelopedData(
            Asn1Sequence seq)
        {
            int index = 0;

            // "It MUST be set to 0."
            Asn1Object tmp = seq[index++].ToAsn1Object();

            version = DerInteger.GetInstance(tmp);
            if (!version.HasValue(0))
            {
                throw new ArgumentException("AuthEnvelopedData version number must be 0");
            }

            tmp = seq[index++].ToAsn1Object();
            if (tmp is Asn1TaggedObject)
            {
                originatorInfo = OriginatorInfo.GetInstance((Asn1TaggedObject)tmp, false);
                tmp            = seq[index++].ToAsn1Object();
            }

            // "There MUST be at least one element in the collection."
            recipientInfos = Asn1Set.GetInstance(tmp);
            if (recipientInfos.Count < 1)
            {
                throw new ArgumentException("AuthEnvelopedData requires at least 1 RecipientInfo");
            }

            tmp = seq[index++].ToAsn1Object();
            authEncryptedContentInfo = EncryptedContentInfo.GetInstance(tmp);

            tmp = seq[index++].ToAsn1Object();
            if (tmp is Asn1TaggedObject)
            {
                authAttrs = Asn1Set.GetInstance((Asn1TaggedObject)tmp, false);
                tmp       = seq[index++].ToAsn1Object();
            }
            else
            {
                // "The authAttrs MUST be present if the content type carried in
                // EncryptedContentInfo is not id-data."
                if (!authEncryptedContentInfo.ContentType.Equals(CmsObjectIdentifiers.Data))
                {
                    if (authAttrs == null || authAttrs.Count < 1)
                    {
                        throw new ArgumentException("authAttrs must be present with non-data content");
                    }
                }
            }

            mac = Asn1OctetString.GetInstance(tmp);

            if (seq.Count > index)
            {
                tmp         = seq[index++].ToAsn1Object();
                unauthAttrs = Asn1Set.GetInstance((Asn1TaggedObject)tmp, false);
            }
        }
Exemple #4
0
 public OriginatorInfo GetOriginatorInfo()
 {
     this.originatorInfoCalled = true;
     if (this.nextObject == null)
     {
         this.nextObject = this.seq.ReadObject();
     }
     if (this.nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)this.nextObject).TagNo == 0)
     {
         Asn1SequenceParser asn1SequenceParser = (Asn1SequenceParser)((Asn1TaggedObjectParser)this.nextObject).GetObjectParser(16, false);
         this.nextObject = null;
         return(OriginatorInfo.GetInstance(asn1SequenceParser.ToAsn1Object()));
     }
     return(null);
 }
 public OriginatorInfo GetOriginatorInfo()
 {
     originatorInfoCalled = true;
     if (nextObject == null)
     {
         nextObject = seq.ReadObject();
     }
     if (nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)nextObject).TagNo == 0)
     {
         Asn1SequenceParser asn1SequenceParser = (Asn1SequenceParser)((Asn1TaggedObjectParser)nextObject).GetObjectParser(16, isExplicit: false);
         nextObject = null;
         return(OriginatorInfo.GetInstance(asn1SequenceParser.ToAsn1Object()));
     }
     return(null);
 }
        private AuthEnvelopedData(
            Asn1Sequence seq)
        {
            int index = 0;

            // TODO
            // "It MUST be set to 0."
            Asn1Object tmp = seq[index++].ToAsn1Object();

            version = (DerInteger)tmp;

            tmp = seq[index++].ToAsn1Object();
            if (tmp is Asn1TaggedObject)
            {
                originatorInfo = OriginatorInfo.GetInstance((Asn1TaggedObject)tmp, false);
                tmp            = seq[index++].ToAsn1Object();
            }

            // TODO
            // "There MUST be at least one element in the collection."
            recipientInfos = Asn1Set.GetInstance(tmp);

            tmp = seq[index++].ToAsn1Object();
            authEncryptedContentInfo = EncryptedContentInfo.GetInstance(tmp);

            tmp = seq[index++].ToAsn1Object();
            if (tmp is Asn1TaggedObject)
            {
                authAttrs = Asn1Set.GetInstance((Asn1TaggedObject)tmp, false);
                tmp       = seq[index++].ToAsn1Object();
            }
            else
            {
                // TODO
                // "The authAttrs MUST be present if the content type carried in
                // EncryptedContentInfo is not id-data."
            }

            mac = Asn1OctetString.GetInstance(tmp);

            if (seq.Count > index)
            {
                tmp         = seq[index++].ToAsn1Object();
                unauthAttrs = Asn1Set.GetInstance((Asn1TaggedObject)tmp, false);
            }
        }
        public OriginatorInfo GetOriginatorInfo()
        {
            _originatorInfoCalled = true;

            if (_nextObject == null)
            {
                _nextObject = _seq.ReadObject();
            }

            if (_nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)_nextObject).TagNo == 0)
            {
                Asn1SequenceParser originatorInfo = (Asn1SequenceParser)
                                                    ((Asn1TaggedObjectParser)_nextObject).GetObjectParser(Asn1Tags.Sequence, false);
                _nextObject = null;
                return(OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object()));
            }

            return(null);
        }
Exemple #8
0
        private AuthenticatedData(
            Asn1Sequence seq)
        {
            int index = 0;

            version = (DerInteger)seq[index++];

            Asn1Encodable tmp = seq[index++];

            if (tmp is Asn1TaggedObject)
            {
                originatorInfo = OriginatorInfo.GetInstance((Asn1TaggedObject)tmp, false);
                tmp            = seq[index++];
            }

            recipientInfos = Asn1Set.GetInstance(tmp);
            macAlgorithm   = AlgorithmIdentifier.GetInstance(seq[index++]);

            tmp = seq[index++];

            if (tmp is Asn1TaggedObject)
            {
                digestAlgorithm = AlgorithmIdentifier.GetInstance((Asn1TaggedObject)tmp, false);
                tmp             = seq[index++];
            }

            encapsulatedContentInfo = ContentInfo.GetInstance(tmp);

            tmp = seq[index++];

            if (tmp is Asn1TaggedObject)
            {
                authAttrs = Asn1Set.GetInstance((Asn1TaggedObject)tmp, false);
                tmp       = seq[index++];
            }

            mac = Asn1OctetString.GetInstance(tmp);

            if (seq.Count > index)
            {
                unauthAttrs = Asn1Set.GetInstance((Asn1TaggedObject)seq[index], false);
            }
        }
        public EnvelopedData(Asn1Sequence seq)
        {
            int num = 0;

            this.version = (DerInteger)seq[num++];
            object obj = seq[num++];

            if (obj is Asn1TaggedObject)
            {
                this.originatorInfo = OriginatorInfo.GetInstance((Asn1TaggedObject)obj, false);
                obj = seq[num++];
            }
            this.recipientInfos       = Asn1Set.GetInstance(obj);
            this.encryptedContentInfo = EncryptedContentInfo.GetInstance(seq[num++]);
            if (seq.Count > num)
            {
                this.unprotectedAttrs = Asn1Set.GetInstance((Asn1TaggedObject)seq[num], false);
            }
        }
Exemple #10
0
        public EnvelopedData(
            Asn1Sequence seq)
        {
            int index = 0;

            version = (DerInteger)seq[index++];

            object tmp = seq[index++];

            if (tmp is Asn1TaggedObject)
            {
                originatorInfo = OriginatorInfo.GetInstance((Asn1TaggedObject)tmp, false);
                tmp            = seq[index++];
            }

            recipientInfos       = Asn1Set.GetInstance(tmp);
            encryptedContentInfo = EncryptedContentInfo.GetInstance(seq[index++]);

            if (seq.Count > index)
            {
                unprotectedAttrs = Asn1Set.GetInstance((Asn1TaggedObject)seq[index], false);
            }
        }
Exemple #11
0
 public static OriginatorInfo GetInstance(Asn1TaggedObject obj, bool explicitly)
 {
     return(OriginatorInfo.GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }