Exemplo n.º 1
0
        public EnvelopedData(
            OriginatorInfo originatorInfo,
            ASN1Set recipientInfos,
            EncryptedContentInfo encryptedContentInfo,
            ASN1Set unprotectedAttrs)
        {
            if (originatorInfo != null || unprotectedAttrs != null)
            {
                version = new DERInteger(2);
            }
            else
            {
                version = new DERInteger(0);

                IEnumerator e = recipientInfos.getObjects();

                while (e.MoveNext())
                {
                    RecipientInfo ri = RecipientInfo.getInstance(e.Current);

                    if (!ri.getVersion().Equals(version))
                    {
                        version = new DERInteger(2);
                        break;
                    }
                }
            }

            this.originatorInfo       = originatorInfo;
            this.recipientInfos       = recipientInfos;
            this.encryptedContentInfo = encryptedContentInfo;
            this.unprotectedAttrs     = unprotectedAttrs;
        }
Exemplo n.º 2
0
        public SignedData(
            ASN1Set digestAlgorithms,
            ContentInfo contentInfo,
            ASN1Set certificates,
            ASN1Set crls,
            ASN1Set signerInfos)
        {
            if (contentInfo.getContentType().Equals(CMSObjectIdentifiers.data))
            {
                //
                // we should also be looking for attribute certificates here,
                // later.
                //
                IEnumerator e       = signerInfos.getObjects();
                bool        v3Found = false;

                while (e.MoveNext())
                {
                    SignerInfo s = SignerInfo.getInstance(e.Current);

                    if (s.getVersion().getValue().intValue() == 3)
                    {
                        v3Found = true;
                    }
                }

                if (v3Found)
                {
                    this.version = new DERInteger(3);
                }
                else
                {
                    this.version = new DERInteger(1);
                }
            }
            else
            {
                this.version = new DERInteger(3);
            }

            this.digestAlgorithms = digestAlgorithms;
            this.contentInfo      = contentInfo;
            this.certificates     = certificates;
            this.crls             = crls;
            this.signerInfos      = signerInfos;
        }