Example #1
0
        public CmsAuthenticatedData(
            ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;

            AuthenticatedData authData = AuthenticatedData.GetInstance(contentInfo.Content);

            //
            // read the encapsulated content info
            //
            ContentInfo encInfo = authData.EncapsulatedContentInfo;

            this.macAlg = authData.MacAlgorithm;
            this.mac    = authData.Mac.GetOctets();

            //
            // load the RecipientInfoStore
            //
            byte[] contentOctets = Asn1OctetString.GetInstance(encInfo.Content).GetOctets();
            IList  infos         = CmsEnvelopedHelper.ReadRecipientInfos(
                authData.RecipientInfos, contentOctets, null, macAlg, null);

            this.authAttrs          = authData.AuthAttrs;
            this.recipientInfoStore = new RecipientInformationStore(infos);
            this.unauthAttrs        = authData.UnauthAttrs;
        }
        public CmsAuthenticatedDataParser(
            Stream envelopedData)
            : base(envelopedData)
        {
            this.authAttrNotRead = true;
            this.authData        = new AuthenticatedDataParser(
                (Asn1SequenceParser)contentInfo.GetContent(Asn1Tags.Sequence));

            // TODO Validate version?
            //DerInteger version = this.authData.getVersion();

            //
            // read the recipients
            //
            Asn1Set recipientInfos = Asn1Set.GetInstance(authData.GetRecipientInfos().ToAsn1Object());

            this.macAlg = authData.GetMacAlgorithm();

            //
            // read the authenticated content info
            //
            ContentInfoParser data     = authData.GetEnapsulatedContentInfo();
            CmsReadable       readable = new CmsProcessableInputStream(
                ((Asn1OctetStringParser)data.GetContent(Asn1Tags.OctetString)).GetOctetStream());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsAuthenticatedSecureReadable(
                this.macAlg, readable);

            //
            // build the RecipientInformationStore
            //
            this._recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(
                recipientInfos, secureReadable);
        }
        public CmsAuthEnvelopedData(
            ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;

            AuthEnvelopedData authEnvData = AuthEnvelopedData.GetInstance(contentInfo.Content);

            this.originator = authEnvData.OriginatorInfo;

            //
            // read the encrypted content info
            //
            EncryptedContentInfo authEncInfo = authEnvData.AuthEncryptedContentInfo;

            this.authEncAlg = authEncInfo.ContentEncryptionAlgorithm;

            //
            // load the RecipientInfoStore
            //
            byte[] contentOctets = authEncInfo.EncryptedContent.GetOctets();
            IList  infos         = CmsEnvelopedHelper.ReadRecipientInfos(
                authEnvData.RecipientInfos, contentOctets, null, null, authEncAlg);

            this.recipientInfoStore = new RecipientInformationStore(infos);

            // FIXME These need to be passed to the AEAD cipher as AAD (Additional Authenticated Data)
            this.authAttrs = authEnvData.AuthAttrs;

            this.mac = authEnvData.Mac.GetOctets();

            this.unauthAttrs = authEnvData.UnauthAttrs;
        }
        public CmsEnvelopedDataParser(
            Stream envelopedData)
            : base(envelopedData)
        {
            this._attrNotRead  = true;
            this.envelopedData = new EnvelopedDataParser(
                (Asn1SequenceParser)this.contentInfo.GetContent(Asn1Tags.Sequence));

            // TODO Validate version?
            //DerInteger version = this.envelopedData.Version;

            //
            // read the recipients
            //
            Asn1Set recipientInfos = Asn1Set.GetInstance(this.envelopedData.GetRecipientInfos().ToAsn1Object());

            //
            // read the encrypted content info
            //
            EncryptedContentInfoParser encInfo = this.envelopedData.GetEncryptedContentInfo();

            this._encAlg = encInfo.ContentEncryptionAlgorithm;
            CmsReadable readable = new CmsProcessableInputStream(
                ((Asn1OctetStringParser)encInfo.GetEncryptedContent(Asn1Tags.OctetString)).GetOctetStream());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsEnvelopedSecureReadable(
                this._encAlg, readable);

            //
            // build the RecipientInformationStore
            //
            this.recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(
                recipientInfos, secureReadable);
        }
        public CmsAuthenticatedData(
            ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;

            AuthenticatedData authData = AuthenticatedData.GetInstance(contentInfo.Content);

            //
            // read the recipients
            //
            Asn1Set recipientInfos = authData.RecipientInfos;

            this.macAlg = authData.MacAlgorithm;

            //
            // read the authenticated content info
            //
            ContentInfo encInfo  = authData.EncapsulatedContentInfo;
            CmsReadable readable = new CmsProcessableByteArray(
                Asn1OctetString.GetInstance(encInfo.Content).GetOctets());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsAuthenticatedSecureReadable(
                this.macAlg, readable);

            //
            // build the RecipientInformationStore
            //
            this.recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(
                recipientInfos, secureReadable);

            this.authAttrs   = authData.AuthAttrs;
            this.mac         = authData.Mac.GetOctets();
            this.unauthAttrs = authData.UnauthAttrs;
        }
        public CmsEnvelopedData(
            ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;

            EnvelopedData envData = EnvelopedData.GetInstance(contentInfo.Content);

            //
            // read the recipients
            //
            Asn1Set recipientInfos = envData.RecipientInfos;

            //
            // read the encrypted content info
            //
            EncryptedContentInfo encInfo = envData.EncryptedContentInfo;

            this.encAlg = encInfo.ContentEncryptionAlgorithm;
            CmsReadable       readable       = new CmsProcessableByteArray(encInfo.EncryptedContent.GetOctets());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsEnvelopedSecureReadable(
                this.encAlg, readable);

            //
            // build the RecipientInformationStore
            //
            this.recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(
                recipientInfos, secureReadable);

            this.unprotectedAttributes = envData.UnprotectedAttrs;
        }
        public CmsAuthEnvelopedData(
            ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;

            AuthEnvelopedData authEnvData = AuthEnvelopedData.GetInstance(contentInfo.Content);

            this.originator = authEnvData.OriginatorInfo;

            //
            // read the recipients
            //
            Asn1Set recipientInfos = authEnvData.RecipientInfos;

            //
            // read the auth-encrypted content info
            //
            EncryptedContentInfo authEncInfo = authEnvData.AuthEncryptedContentInfo;

            this.authEncAlg = authEncInfo.ContentEncryptionAlgorithm;
            CmsSecureReadable secureReadable = new AuthEnvelopedSecureReadable(this);

            //
            // build the RecipientInformationStore
            //
            this.recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(
                recipientInfos, secureReadable);

            // FIXME These need to be passed to the AEAD cipher as AAD (Additional Authenticated Data)
            this.authAttrs   = authEnvData.AuthAttrs;
            this.mac         = authEnvData.Mac.GetOctets();
            this.unauthAttrs = authEnvData.UnauthAttrs;
        }
Example #8
0
        internal static RecipientInformationStore BuildRecipientInformationStore(Asn1Set recipientInfos, CmsSecureReadable secureReadable)
        {
            IList list = Platform.CreateArrayList();

            for (int num = 0; num != recipientInfos.Count; num++)
            {
                RecipientInfo instance = RecipientInfo.GetInstance(recipientInfos[num]);
                CmsEnvelopedHelper.ReadRecipientInfo(list, instance, secureReadable);
            }
            return(new RecipientInformationStore(list));
        }
        public CmsEnvelopedDataParser(Stream envelopedData) : base(envelopedData)
        {
            this._attrNotRead  = true;
            this.envelopedData = new EnvelopedDataParser((Asn1SequenceParser)this.contentInfo.GetContent(16));
            Asn1Set instance = Asn1Set.GetInstance(this.envelopedData.GetRecipientInfos().ToAsn1Object());
            EncryptedContentInfoParser encryptedContentInfo = this.envelopedData.GetEncryptedContentInfo();

            this._encAlg = encryptedContentInfo.ContentEncryptionAlgorithm;
            CmsReadable       readable       = new CmsProcessableInputStream(((Asn1OctetStringParser)encryptedContentInfo.GetEncryptedContent(4)).GetOctetStream());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsEnvelopedSecureReadable(this._encAlg, readable);

            this.recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(instance, secureReadable);
        }
        }        //IL_0003: Unknown result type (might be due to invalid IL or missing references)

        //IL_000d: Expected O, but got Unknown


        public CmsAuthenticatedDataParser(Stream envelopedData)
            : base(envelopedData)
        {
            authAttrNotRead = true;
            authData        = new AuthenticatedDataParser((Asn1SequenceParser)contentInfo.GetContent(16));
            Asn1Set instance = Asn1Set.GetInstance(authData.GetRecipientInfos().ToAsn1Object());

            macAlg = authData.GetMacAlgorithm();
            ContentInfoParser enapsulatedContentInfo = authData.GetEnapsulatedContentInfo();
            CmsReadable       readable       = new CmsProcessableInputStream(((Asn1OctetStringParser)enapsulatedContentInfo.GetContent(4)).GetOctetStream());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsAuthenticatedSecureReadable(macAlg, readable);

            _recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(instance, secureReadable);
        }
 static CmsEnvelopedHelper()
 {
     Instance        = new CmsEnvelopedHelper();
     KeySizes        = Platform.CreateHashtable();
     BaseCipherNames = Platform.CreateHashtable();
     KeySizes.Add((object)CmsEnvelopedGenerator.DesEde3Cbc, (object)192);
     KeySizes.Add((object)CmsEnvelopedGenerator.Aes128Cbc, (object)128);
     KeySizes.Add((object)CmsEnvelopedGenerator.Aes192Cbc, (object)192);
     KeySizes.Add((object)CmsEnvelopedGenerator.Aes256Cbc, (object)256);
     BaseCipherNames.Add((object)CmsEnvelopedGenerator.DesEde3Cbc, (object)"DESEDE");
     BaseCipherNames.Add((object)CmsEnvelopedGenerator.Aes128Cbc, (object)"AES");
     BaseCipherNames.Add((object)CmsEnvelopedGenerator.Aes192Cbc, (object)"AES");
     BaseCipherNames.Add((object)CmsEnvelopedGenerator.Aes256Cbc, (object)"AES");
 }
Example #12
0
        public CmsEnvelopedData(ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;
            EnvelopedData        instance             = EnvelopedData.GetInstance(contentInfo.Content);
            Asn1Set              recipientInfos       = instance.RecipientInfos;
            EncryptedContentInfo encryptedContentInfo = instance.EncryptedContentInfo;

            encAlg = encryptedContentInfo.ContentEncryptionAlgorithm;
            CmsReadable       readable       = new CmsProcessableByteArray(encryptedContentInfo.EncryptedContent.GetOctets());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsEnvelopedSecureReadable(encAlg, readable);

            recipientInfoStore    = CmsEnvelopedHelper.BuildRecipientInformationStore(recipientInfos, secureReadable);
            unprotectedAttributes = instance.UnprotectedAttrs;
        }
Example #13
0
 static CmsEnvelopedHelper()
 {
     CmsEnvelopedHelper.Instance        = new CmsEnvelopedHelper();
     CmsEnvelopedHelper.KeySizes        = Platform.CreateHashtable();
     CmsEnvelopedHelper.BaseCipherNames = Platform.CreateHashtable();
     CmsEnvelopedHelper.KeySizes.Add(CmsEnvelopedGenerator.DesEde3Cbc, 192);
     CmsEnvelopedHelper.KeySizes.Add(CmsEnvelopedGenerator.Aes128Cbc, 128);
     CmsEnvelopedHelper.KeySizes.Add(CmsEnvelopedGenerator.Aes192Cbc, 192);
     CmsEnvelopedHelper.KeySizes.Add(CmsEnvelopedGenerator.Aes256Cbc, 256);
     CmsEnvelopedHelper.BaseCipherNames.Add(CmsEnvelopedGenerator.DesEde3Cbc, "DESEDE");
     CmsEnvelopedHelper.BaseCipherNames.Add(CmsEnvelopedGenerator.Aes128Cbc, "AES");
     CmsEnvelopedHelper.BaseCipherNames.Add(CmsEnvelopedGenerator.Aes192Cbc, "AES");
     CmsEnvelopedHelper.BaseCipherNames.Add(CmsEnvelopedGenerator.Aes256Cbc, "AES");
 }
Example #14
0
        public CmsAuthenticatedData(ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;
            AuthenticatedData instance       = AuthenticatedData.GetInstance(contentInfo.Content);
            Asn1Set           recipientInfos = instance.RecipientInfos;

            this.macAlg = instance.MacAlgorithm;
            ContentInfo       encapsulatedContentInfo = instance.EncapsulatedContentInfo;
            CmsReadable       readable       = new CmsProcessableByteArray(Asn1OctetString.GetInstance(encapsulatedContentInfo.Content).GetOctets());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsAuthenticatedSecureReadable(this.macAlg, readable);

            this.recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(recipientInfos, secureReadable);
            this.authAttrs          = instance.AuthAttrs;
            this.mac         = instance.Mac.GetOctets();
            this.unauthAttrs = instance.UnauthAttrs;
        }
Example #15
0
        public CmsAuthEnvelopedData(ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;
            AuthEnvelopedData instance = AuthEnvelopedData.GetInstance(contentInfo.Content);

            originator = instance.OriginatorInfo;
            Asn1Set recipientInfos = instance.RecipientInfos;
            EncryptedContentInfo authEncryptedContentInfo = instance.AuthEncryptedContentInfo;

            authEncAlg = authEncryptedContentInfo.ContentEncryptionAlgorithm;
            CmsSecureReadable secureReadable = new AuthEnvelopedSecureReadable(this);

            recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(recipientInfos, secureReadable);
            authAttrs          = instance.AuthAttrs;
            mac         = instance.Mac.GetOctets();
            unauthAttrs = instance.UnauthAttrs;
        }
Example #16
0
        public CmsEnvelopedData(
            ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;

            try
            {
                EnvelopedData envData = EnvelopedData.GetInstance(contentInfo.Content);

                if (envData.OriginatorInfo != null)
                {
                    originatorInfo = new OriginatorInformation(envData.OriginatorInfo);
                }

                //
                // read the recipients
                //
                Asn1Set recipientInfos = envData.RecipientInfos;

                //
                // read the encrypted content info
                //
                EncryptedContentInfo encInfo = envData.EncryptedContentInfo;
                this.encAlg = encInfo.ContentEncryptionAlgorithm;
                CmsReadable        readable       = new CmsProcessableByteArray(encInfo.EncryptedContent.GetOctets());
                ICmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsEnvelopedSecureReadable(
                    this.encAlg, readable);

                //
                // build the RecipientInformationStore
                //
                this.recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(
                    recipientInfos, this.encAlg, secureReadable);

                this.unprotectedAttributes = envData.UnprotectedAttrs;
            }
            catch (Exception e)
            {
                throw new CmsException("malformed content", e);
            }
        }
Example #17
0
        public CmsEnvelopedDataParser(
            Stream envelopedData)
            : base(envelopedData)
        {
            this._attrNotRead  = true;
            this.envelopedData = new EnvelopedDataParser(
                (Asn1SequenceParser)this.contentInfo.GetContent(Asn1Tags.Sequence));

            // TODO Validate version?
            //DerInteger version = this.envelopedData.Version;

            //
            // load the RecipientInfoStore
            //
            Asn1SetParser s         = this.envelopedData.GetRecipientInfos();
            IList         baseInfos = new ArrayList();

            IAsn1Convertible entry;

            while ((entry = s.ReadObject()) != null)
            {
                baseInfos.Add(RecipientInfo.GetInstance(entry.ToAsn1Object()));
            }

            //
            // read the encrypted content info
            //
            EncryptedContentInfoParser encInfo = this.envelopedData.GetEncryptedContentInfo();

            this._encAlg = encInfo.ContentEncryptionAlgorithm;

            //
            // prime the recipients
            //
            Stream contentStream = ((Asn1OctetStringParser)encInfo.GetEncryptedContent(Asn1Tags.OctetString)).GetOctetStream();
            IList  infos         = CmsEnvelopedHelper.ReadRecipientInfos(
                baseInfos, contentStream, _encAlg, null, null);

            this.recipientInfoStore = new RecipientInformationStore(infos);
        }
        public CmsAuthenticatedDataParser(
            Stream envelopedData)
            : base(envelopedData)
        {
            this.authAttrNotRead = true;
            this.authData        = new AuthenticatedDataParser(
                (Asn1SequenceParser)contentInfo.GetContent(Asn1Tags.Sequence));

            // TODO Validate version?
            //DerInteger version = this.authData.getVersion();

            //
            // load the RecipientInfoStore
            //
            Asn1SetParser s         = authData.GetRecipientInfos();
            IList         baseInfos = new ArrayList();

            IAsn1Convertible entry;

            while ((entry = s.ReadObject()) != null)
            {
                baseInfos.Add(RecipientInfo.GetInstance(entry.ToAsn1Object()));
            }

            this.macAlg = authData.GetMacAlgorithm();

            //
            // read the encrypted content info
            //
            ContentInfoParser data = authData.GetEnapsulatedContentInfo();

            //
            // prime the recipients
            //
            Stream contentStream = ((Asn1OctetStringParser)data.GetContent(Asn1Tags.OctetString)).GetOctetStream();
            IList  infos         = CmsEnvelopedHelper.ReadRecipientInfos(
                baseInfos, contentStream, null, macAlg, null);

            _recipientInfoStore = new RecipientInformationStore(infos);
        }
Example #19
0
        public CmsEnvelopedData(
            ContentInfo contentInfo)
        {
            this.contentInfo = contentInfo;

            EnvelopedData envData = EnvelopedData.GetInstance(contentInfo.Content);

            //
            // read the encrypted content info
            //
            EncryptedContentInfo encInfo = envData.EncryptedContentInfo;

            this.encAlg = encInfo.ContentEncryptionAlgorithm;

            //
            // load the RecipientInfoStore
            //
            byte[] contentOctets = encInfo.EncryptedContent.GetOctets();
            IList  infos         = CmsEnvelopedHelper.ReadRecipientInfos(
                envData.RecipientInfos, contentOctets, encAlg, null, null);

            this.recipientInfoStore    = new RecipientInformationStore(infos);
            this.unprotectedAttributes = envData.UnprotectedAttrs;
        }