GetInstance() публичный статический Метод

public static GetInstance ( object obj ) : EncryptedContentInfo
obj object
Результат EncryptedContentInfo
Пример #1
0
        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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 private EncryptedData(Asn1Sequence seq)
 {
     if (seq == null)
     {
         throw new ArgumentNullException("seq");
     }
     if (seq.Count < 2 || seq.Count > 3)
     {
         throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
     }
     this.version = DerInteger.GetInstance(seq[0]);
     this.encryptedContentInfo = EncryptedContentInfo.GetInstance(seq[1]);
     if (seq.Count > 2)
     {
         this.unprotectedAttrs = Asn1Set.GetInstance((Asn1TaggedObject)seq[2], false);
     }
 }
Пример #5
0
        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);
            }
        }
Пример #6
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);
            }
        }