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);
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
            }
        }