コード例 #1
0
        private CmsAuthenticatedData Generate(CmsProcessable content, string macOid, CipherKeyGenerator keyGen)
        {
            //IL_0039: Unknown result type (might be due to invalid IL or missing references)
            //IL_0040: Expected O, but got Unknown
            //IL_009f: Expected O, but got Unknown
            KeyParameter        keyParameter;
            AlgorithmIdentifier algorithmIdentifier;
            Asn1OctetString     content2;
            Asn1OctetString     mac2;

            try
            {
                byte[] array = keyGen.GenerateKey();
                keyParameter = ParameterUtilities.CreateKeyParameter(macOid, array);
                Asn1Encodable asn1Params = GenerateAsn1Parameters(macOid, array);
                algorithmIdentifier = GetAlgorithmIdentifier(macOid, keyParameter, asn1Params, out var _);
                IMac mac = MacUtilities.GetMac(macOid);
                mac.Init(keyParameter);
                MemoryStream val  = new MemoryStream();
                Stream       val2 = (Stream)(object)new TeeOutputStream((Stream)(object)val, (Stream)(object)new MacOutputStream(mac));
                content.Write(val2);
                Platform.Dispose(val2);
                content2 = new BerOctetString(val.ToArray());
                byte[] str = MacUtilities.DoFinal(mac);
                mac2 = new DerOctetString(str);
            }
            catch (SecurityUtilityException e)
            {
                throw new CmsException("couldn't create cipher.", e);
            }
            catch (InvalidKeyException e2)
            {
                throw new CmsException("key invalid in message.", e2);
            }
            catch (IOException val3)
            {
                IOException e3 = val3;
                throw new CmsException("exception decoding algorithm parameters.", (global::System.Exception)(object) e3);
            }
            Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();

            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)recipientInfoGenerators).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    RecipientInfoGenerator recipientInfoGenerator = (RecipientInfoGenerator)enumerator.get_Current();
                    try
                    {
                        asn1EncodableVector.Add(recipientInfoGenerator.Generate(keyParameter, rand));
                    }
                    catch (InvalidKeyException e4)
                    {
                        throw new CmsException("key inappropriate for algorithm.", e4);
                    }
                    catch (GeneralSecurityException e5)
                    {
                        throw new CmsException("error making encrypted content.", e5);
                    }
                }
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            ContentInfo encapsulatedContent = new ContentInfo(CmsObjectIdentifiers.Data, content2);
            ContentInfo contentInfo         = new ContentInfo(CmsObjectIdentifiers.AuthenticatedData, new AuthenticatedData(null, new DerSet(asn1EncodableVector), algorithmIdentifier, null, encapsulatedContent, null, mac2, null));

            return(new CmsAuthenticatedData(contentInfo));
        }
コード例 #2
0
        internal static ISet GetDeltaCrls(global::System.DateTime currentDate, PkixParameters paramsPKIX, X509Crl completeCRL)
        {
            //IL_0023: Expected O, but got Unknown
            X509CrlStoreSelector x509CrlStoreSelector = new X509CrlStoreSelector();

            try
            {
                global::System.Collections.IList list = Platform.CreateArrayList();
                list.Add((object)completeCRL.IssuerDN);
                x509CrlStoreSelector.Issuers = (global::System.Collections.ICollection)list;
            }
            catch (IOException val)
            {
                IOException val2 = val;
                throw new global::System.Exception("Cannot extract issuer from CRL.", (global::System.Exception)(object) val2);
            }
            BigInteger bigInteger = null;

            try
            {
                Asn1Object extensionValue = GetExtensionValue(completeCRL, X509Extensions.CrlNumber);
                if (extensionValue != null)
                {
                    bigInteger = DerInteger.GetInstance(extensionValue).PositiveValue;
                }
            }
            catch (global::System.Exception ex)
            {
                throw new global::System.Exception("CRL number extension could not be extracted from CRL.", ex);
            }
            byte[] issuingDistributionPoint = null;
            try
            {
                Asn1Object extensionValue2 = GetExtensionValue(completeCRL, X509Extensions.IssuingDistributionPoint);
                if (extensionValue2 != null)
                {
                    issuingDistributionPoint = extensionValue2.GetDerEncoded();
                }
            }
            catch (global::System.Exception ex2)
            {
                throw new global::System.Exception("Issuing distribution point extension value could not be read.", ex2);
            }
            x509CrlStoreSelector.MinCrlNumber                    = bigInteger?.Add(BigInteger.One);
            x509CrlStoreSelector.IssuingDistributionPoint        = issuingDistributionPoint;
            x509CrlStoreSelector.IssuingDistributionPointEnabled = true;
            x509CrlStoreSelector.MaxBaseCrlNumber                = bigInteger;
            ISet set  = CrlUtilities.FindCrls(x509CrlStoreSelector, paramsPKIX, currentDate);
            ISet set2 = new HashSet();

            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)set).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    X509Crl x509Crl = (X509Crl)enumerator.get_Current();
                    if (isDeltaCrl(x509Crl))
                    {
                        set2.Add(x509Crl);
                    }
                }
                return(set2);
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
コード例 #3
0
        internal static global::System.Collections.ICollection FindCertificates(X509AttrCertStoreSelector certSelect, global::System.Collections.IList certStores)
        {
            ISet set = new HashSet();

            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)certStores).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    IX509Store iX509Store = (IX509Store)enumerator.get_Current();
                    try
                    {
                        global::System.Collections.IEnumerator enumerator2 = ((global::System.Collections.IEnumerable)iX509Store.GetMatches(certSelect)).GetEnumerator();
                        try
                        {
                            while (enumerator2.MoveNext())
                            {
                                X509V2AttributeCertificate o = (X509V2AttributeCertificate)enumerator2.get_Current();
                                set.Add(o);
                            }
                        }
                        finally
                        {
                            global::System.IDisposable disposable2 = enumerator2 as global::System.IDisposable;
                            if (disposable2 != null)
                            {
                                disposable2.Dispose();
                            }
                        }
                    }
                    catch (global::System.Exception ex)
                    {
                        throw new global::System.Exception("Problem while picking certificates from X.509 store.", ex);
                    }
                }
                return(set);
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
コード例 #4
0
        private static global::System.Collections.IList SortCerts(global::System.Collections.IList certs)
        {
            if (((global::System.Collections.ICollection)certs).get_Count() < 2)
            {
                return(certs);
            }
            X509Name issuerDN = ((X509Certificate)certs.get_Item(0)).IssuerDN;
            bool     flag     = true;

            for (int i = 1; i != ((global::System.Collections.ICollection)certs).get_Count(); i++)
            {
                X509Certificate x509Certificate = (X509Certificate)certs.get_Item(i);
                if (issuerDN.Equivalent(x509Certificate.SubjectDN, inOrder: true))
                {
                    issuerDN = ((X509Certificate)certs.get_Item(i)).IssuerDN;
                    continue;
                }
                flag = false;
                break;
            }
            if (flag)
            {
                return(certs);
            }
            global::System.Collections.IList list   = Platform.CreateArrayList(((global::System.Collections.ICollection)certs).get_Count());
            global::System.Collections.IList result = Platform.CreateArrayList((global::System.Collections.ICollection)certs);
            for (int j = 0; j < ((global::System.Collections.ICollection)certs).get_Count(); j++)
            {
                X509Certificate x509Certificate2 = (X509Certificate)certs.get_Item(j);
                bool            flag2            = false;
                X509Name        subjectDN        = x509Certificate2.SubjectDN;
                {
                    global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)certs).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            X509Certificate x509Certificate3 = (X509Certificate)enumerator.get_Current();
                            if (x509Certificate3.IssuerDN.Equivalent(subjectDN, inOrder: true))
                            {
                                flag2 = true;
                                break;
                            }
                        }
                    }
                    finally
                    {
                        global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
                if (!flag2)
                {
                    list.Add((object)x509Certificate2);
                    certs.RemoveAt(j);
                }
            }
            if (((global::System.Collections.ICollection)list).get_Count() > 1)
            {
                return(result);
            }
            for (int k = 0; k != ((global::System.Collections.ICollection)list).get_Count(); k++)
            {
                issuerDN = ((X509Certificate)list.get_Item(k)).IssuerDN;
                for (int l = 0; l < ((global::System.Collections.ICollection)certs).get_Count(); l++)
                {
                    X509Certificate x509Certificate4 = (X509Certificate)certs.get_Item(l);
                    if (issuerDN.Equivalent(x509Certificate4.SubjectDN, inOrder: true))
                    {
                        list.Add((object)x509Certificate4);
                        certs.RemoveAt(l);
                        break;
                    }
                }
            }
            if (((global::System.Collections.ICollection)certs).get_Count() > 0)
            {
                return(result);
            }
            return(list);
        }
コード例 #5
0
        internal static TrustAnchor FindTrustAnchor(X509Certificate cert, ISet trustAnchors)
        {
            //IL_0028: Expected O, but got Unknown
            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)trustAnchors).GetEnumerator();
            TrustAnchor            trustAnchor            = null;
            AsymmetricKeyParameter asymmetricKeyParameter = null;

            global::System.Exception ex = null;
            X509CertStoreSelector    x509CertStoreSelector = new X509CertStoreSelector();

            try
            {
                x509CertStoreSelector.Subject = GetIssuerPrincipal(cert);
            }
            catch (IOException val)
            {
                IOException val2 = val;
                throw new global::System.Exception("Cannot set subject search criteria for trust anchor.", (global::System.Exception)(object) val2);
            }
            while (enumerator.MoveNext() && trustAnchor == null)
            {
                trustAnchor = (TrustAnchor)enumerator.get_Current();
                if (trustAnchor.TrustedCert != null)
                {
                    if (x509CertStoreSelector.Match(trustAnchor.TrustedCert))
                    {
                        asymmetricKeyParameter = trustAnchor.TrustedCert.GetPublicKey();
                    }
                    else
                    {
                        trustAnchor = null;
                    }
                }
                else if (trustAnchor.CAName != null && trustAnchor.CAPublicKey != null)
                {
                    try
                    {
                        X509Name issuerPrincipal = GetIssuerPrincipal(cert);
                        X509Name other           = new X509Name(trustAnchor.CAName);
                        if (issuerPrincipal.Equivalent(other, inOrder: true))
                        {
                            asymmetricKeyParameter = trustAnchor.CAPublicKey;
                        }
                        else
                        {
                            trustAnchor = null;
                        }
                    }
                    catch (InvalidParameterException)
                    {
                        trustAnchor = null;
                    }
                }
                else
                {
                    trustAnchor = null;
                }
                if (asymmetricKeyParameter != null)
                {
                    try
                    {
                        cert.Verify(asymmetricKeyParameter);
                    }
                    catch (global::System.Exception ex3)
                    {
                        ex          = ex3;
                        trustAnchor = null;
                    }
                }
            }
            if (trustAnchor == null && ex != null)
            {
                throw new global::System.Exception("TrustAnchor found but certificate validation failed.", ex);
            }
            return(trustAnchor);
        }
コード例 #6
0
        private CertTemplate(Asn1Sequence seq)
        {
            //IL_011d: Unknown result type (might be due to invalid IL or missing references)
            this.seq = seq;
            global::System.Collections.IEnumerator enumerator = seq.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    Asn1TaggedObject asn1TaggedObject = (Asn1TaggedObject)enumerator.get_Current();
                    switch (asn1TaggedObject.TagNo)
                    {
                    case 0:
                        version = DerInteger.GetInstance(asn1TaggedObject, isExplicit: false);
                        break;

                    case 1:
                        serialNumber = DerInteger.GetInstance(asn1TaggedObject, isExplicit: false);
                        break;

                    case 2:
                        signingAlg = AlgorithmIdentifier.GetInstance(asn1TaggedObject, explicitly: false);
                        break;

                    case 3:
                        issuer = X509Name.GetInstance(asn1TaggedObject, explicitly: true);
                        break;

                    case 4:
                        validity = OptionalValidity.GetInstance(Asn1Sequence.GetInstance(asn1TaggedObject, explicitly: false));
                        break;

                    case 5:
                        subject = X509Name.GetInstance(asn1TaggedObject, explicitly: true);
                        break;

                    case 6:
                        publicKey = SubjectPublicKeyInfo.GetInstance(asn1TaggedObject, explicitly: false);
                        break;

                    case 7:
                        issuerUID = DerBitString.GetInstance(asn1TaggedObject, isExplicit: false);
                        break;

                    case 8:
                        subjectUID = DerBitString.GetInstance(asn1TaggedObject, isExplicit: false);
                        break;

                    case 9:
                        extensions = X509Extensions.GetInstance(asn1TaggedObject, explicitly: false);
                        break;

                    default:
                        throw new ArgumentException(string.Concat((object)"unknown tag: ", (object)asn1TaggedObject.TagNo), "seq");
                    }
                }
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
コード例 #7
0
        public virtual bool Match(object obj)
        {
            X509Certificate x509Certificate = obj as X509Certificate;

            if (x509Certificate == null)
            {
                return(false);
            }
            if (!MatchExtension(authorityKeyIdentifier, x509Certificate, X509Extensions.AuthorityKeyIdentifier))
            {
                return(false);
            }
            if (basicConstraints != -1)
            {
                int num = x509Certificate.GetBasicConstraints();
                if (basicConstraints == -2)
                {
                    if (num != -1)
                    {
                        return(false);
                    }
                }
                else if (num < basicConstraints)
                {
                    return(false);
                }
            }
            if (certificate != null && !certificate.Equals(x509Certificate))
            {
                return(false);
            }
            if (certificateValid != null && !x509Certificate.IsValid(certificateValid.Value))
            {
                return(false);
            }
            if (extendedKeyUsage != null)
            {
                global::System.Collections.IList list = x509Certificate.GetExtendedKeyUsage();
                if (list != null)
                {
                    {
                        global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)extendedKeyUsage).GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                DerObjectIdentifier derObjectIdentifier = (DerObjectIdentifier)enumerator.get_Current();
                                if (!list.Contains((object)derObjectIdentifier.Id))
                                {
                                    return(false);
                                }
                            }
                        }
                        finally
                        {
                            global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                            if (disposable != null)
                            {
                                disposable.Dispose();
                            }
                        }
                    }
                }
            }
            if (issuer != null && !issuer.Equivalent(x509Certificate.IssuerDN, inOrder: true))
            {
                return(false);
            }
            if (keyUsage != null)
            {
                bool[] array = x509Certificate.GetKeyUsage();
                if (array != null)
                {
                    for (int i = 0; i < 9; i++)
                    {
                        if (keyUsage[i] && !array[i])
                        {
                            return(false);
                        }
                    }
                }
            }
            if (policy != null)
            {
                Asn1OctetString extensionValue = x509Certificate.GetExtensionValue(X509Extensions.CertificatePolicies);
                if (extensionValue == null)
                {
                    return(false);
                }
                Asn1Sequence instance = Asn1Sequence.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue));
                if (((global::System.Collections.ICollection)policy).get_Count() < 1 && instance.Count < 1)
                {
                    return(false);
                }
                bool flag = false;
                {
                    global::System.Collections.IEnumerator enumerator = instance.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            PolicyInformation policyInformation = (PolicyInformation)enumerator.get_Current();
                            if (policy.Contains(policyInformation.PolicyIdentifier))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    finally
                    {
                        global::System.IDisposable disposable2 = enumerator as global::System.IDisposable;
                        if (disposable2 != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                }
                if (!flag)
                {
                    return(false);
                }
            }
            if (privateKeyValid != null)
            {
                Asn1OctetString extensionValue2 = x509Certificate.GetExtensionValue(X509Extensions.PrivateKeyUsagePeriod);
                if (extensionValue2 == null)
                {
                    return(false);
                }
                PrivateKeyUsagePeriod   instance2 = PrivateKeyUsagePeriod.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue2));
                global::System.DateTime value     = privateKeyValid.Value;
                global::System.DateTime dateTime  = instance2.NotAfter.ToDateTime();
                global::System.DateTime dateTime2 = instance2.NotBefore.ToDateTime();
                if (value.CompareTo((object)dateTime) > 0 || value.CompareTo((object)dateTime2) < 0)
                {
                    return(false);
                }
            }
            if (serialNumber != null && !serialNumber.Equals(x509Certificate.SerialNumber))
            {
                return(false);
            }
            if (subject != null && !subject.Equivalent(x509Certificate.SubjectDN, inOrder: true))
            {
                return(false);
            }
            if (!MatchExtension(subjectKeyIdentifier, x509Certificate, X509Extensions.SubjectKeyIdentifier))
            {
                return(false);
            }
            if (subjectPublicKey != null && !subjectPublicKey.Equals(GetSubjectPublicKey(x509Certificate)))
            {
                return(false);
            }
            if (subjectPublicKeyAlgID != null && !subjectPublicKeyAlgID.Equals(GetSubjectPublicKey(x509Certificate).AlgorithmID))
            {
                return(false);
            }
            return(true);
        }
コード例 #8
0
        private DerInteger CalculateVersion(DerObjectIdentifier contentOid)
        {
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;

            if (_certs != null)
            {
                {
                    global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)_certs).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            object current = enumerator.get_Current();
                            if (current is Asn1TaggedObject)
                            {
                                Asn1TaggedObject asn1TaggedObject = (Asn1TaggedObject)current;
                                if (asn1TaggedObject.TagNo == 1)
                                {
                                    flag3 = true;
                                }
                                else if (asn1TaggedObject.TagNo == 2)
                                {
                                    flag4 = true;
                                }
                                else if (asn1TaggedObject.TagNo == 3)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                        }
                    }
                    finally
                    {
                        global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
            }
            if (flag)
            {
                return(new DerInteger(5));
            }
            if (_crls != null)
            {
                {
                    global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)_crls).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            object current2 = enumerator.get_Current();
                            if (current2 is Asn1TaggedObject)
                            {
                                flag2 = true;
                                break;
                            }
                        }
                    }
                    finally
                    {
                        global::System.IDisposable disposable2 = enumerator as global::System.IDisposable;
                        if (disposable2 != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                }
            }
            if (flag2)
            {
                return(new DerInteger(5));
            }
            if (flag4)
            {
                return(new DerInteger(4));
            }
            if (flag3 || !CmsObjectIdentifiers.Data.Equals(contentOid) || CheckForVersion3(_signers))
            {
                return(new DerInteger(3));
            }
            return(new DerInteger(1));
        }
コード例 #9
0
        private bool DoVerify(AsymmetricKeyParameter key)
        {
            //IL_019b: Expected O, but got Unknown
            //IL_03a0: Expected O, but got Unknown
            string              digestAlgName  = Helper.GetDigestAlgName(DigestAlgOid);
            IDigest             digestInstance = Helper.GetDigestInstance(digestAlgName);
            DerObjectIdentifier algorithm      = encryptionAlgorithm.Algorithm;
            Asn1Encodable       parameters     = encryptionAlgorithm.Parameters;
            ISigner             signer;

            if (algorithm.Equals(PkcsObjectIdentifiers.IdRsassaPss))
            {
                if (parameters == null)
                {
                    throw new CmsException("RSASSA-PSS signature must specify algorithm parameters");
                }
                try
                {
                    RsassaPssParameters instance = RsassaPssParameters.GetInstance(parameters.ToAsn1Object());
                    if (!instance.HashAlgorithm.Algorithm.Equals(digestAlgorithm.Algorithm))
                    {
                        throw new CmsException("RSASSA-PSS signature parameters specified incorrect hash algorithm");
                    }
                    if (!instance.MaskGenAlgorithm.Algorithm.Equals(PkcsObjectIdentifiers.IdMgf1))
                    {
                        throw new CmsException("RSASSA-PSS signature parameters specified unknown MGF");
                    }
                    IDigest digest   = DigestUtilities.GetDigest(instance.HashAlgorithm.Algorithm);
                    int     intValue = instance.SaltLength.Value.IntValue;
                    byte    b        = (byte)instance.TrailerField.Value.IntValue;
                    if (b != 1)
                    {
                        throw new CmsException("RSASSA-PSS signature parameters must have trailerField of 1");
                    }
                    signer = new PssSigner(new RsaBlindedEngine(), digest, intValue);
                }
                catch (global::System.Exception e)
                {
                    throw new CmsException("failed to set RSASSA-PSS signature parameters", e);
                }
            }
            else
            {
                string algorithm2 = digestAlgName + "with" + Helper.GetEncryptionAlgName(EncryptionAlgOid);
                signer = Helper.GetSignatureInstance(algorithm2);
            }
            try
            {
                if (digestCalculator != null)
                {
                    resultDigest = digestCalculator.GetDigest();
                }
                else
                {
                    if (content != null)
                    {
                        content.Write((Stream)(object)new DigOutputStream(digestInstance));
                    }
                    else if (signedAttributeSet == null)
                    {
                        throw new CmsException("data not encapsulated in signature - use detached constructor.");
                    }
                    resultDigest = DigestUtilities.DoFinal(digestInstance);
                }
            }
            catch (IOException val)
            {
                IOException e2 = val;
                throw new CmsException("can't process mime object to create signature.", (global::System.Exception)(object) e2);
            }
            Asn1Object singleValuedSignedAttribute = GetSingleValuedSignedAttribute(CmsAttributes.ContentType, "content-type");

            if (singleValuedSignedAttribute == null)
            {
                if (!isCounterSignature && signedAttributeSet != null)
                {
                    throw new CmsException("The content-type attribute type MUST be present whenever signed attributes are present in signed-data");
                }
            }
            else
            {
                if (isCounterSignature)
                {
                    throw new CmsException("[For counter signatures,] the signedAttributes field MUST NOT contain a content-type attribute");
                }
                if (!(singleValuedSignedAttribute is DerObjectIdentifier))
                {
                    throw new CmsException("content-type attribute value not of ASN.1 type 'OBJECT IDENTIFIER'");
                }
                DerObjectIdentifier derObjectIdentifier = (DerObjectIdentifier)singleValuedSignedAttribute;
                if (!derObjectIdentifier.Equals(contentType))
                {
                    throw new CmsException("content-type attribute value does not match eContentType");
                }
            }
            Asn1Object singleValuedSignedAttribute2 = GetSingleValuedSignedAttribute(CmsAttributes.MessageDigest, "message-digest");

            if (singleValuedSignedAttribute2 == null)
            {
                if (signedAttributeSet != null)
                {
                    throw new CmsException("the message-digest signed attribute type MUST be present when there are any signed attributes present");
                }
            }
            else
            {
                if (!(singleValuedSignedAttribute2 is Asn1OctetString))
                {
                    throw new CmsException("message-digest attribute value not of ASN.1 type 'OCTET STRING'");
                }
                Asn1OctetString asn1OctetString = (Asn1OctetString)singleValuedSignedAttribute2;
                if (!Arrays.AreEqual(resultDigest, asn1OctetString.GetOctets()))
                {
                    throw new CmsException("message-digest attribute value does not match calculated value");
                }
            }
            Org.BouncyCastle.Asn1.Cms.AttributeTable signedAttributes = SignedAttributes;
            if (signedAttributes != null && signedAttributes.GetAll(CmsAttributes.CounterSignature).Count > 0)
            {
                throw new CmsException("A countersignature attribute MUST NOT be a signed attribute");
            }
            Org.BouncyCastle.Asn1.Cms.AttributeTable unsignedAttributes = UnsignedAttributes;
            if (unsignedAttributes != null)
            {
                {
                    global::System.Collections.IEnumerator enumerator = unsignedAttributes.GetAll(CmsAttributes.CounterSignature).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            Attribute attribute = (Attribute)enumerator.get_Current();
                            if (attribute.AttrValues.Count < 1)
                            {
                                throw new CmsException("A countersignature attribute MUST contain at least one AttributeValue");
                            }
                        }
                    }
                    finally
                    {
                        global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
            }
            try
            {
                signer.Init(forSigning: false, key);
                if (signedAttributeSet == null)
                {
                    if (digestCalculator != null)
                    {
                        return(VerifyDigest(resultDigest, key, GetSignature()));
                    }
                    if (content != null)
                    {
                        content.Write((Stream)(object)new SigOutputStream(signer));
                    }
                }
                else
                {
                    byte[] encodedSignedAttributes = GetEncodedSignedAttributes();
                    signer.BlockUpdate(encodedSignedAttributes, 0, encodedSignedAttributes.Length);
                }
                return(signer.VerifySignature(GetSignature()));
            }
            catch (InvalidKeyException e3)
            {
                throw new CmsException("key not appropriate to signature in message.", e3);
            }
            catch (IOException val2)
            {
                IOException e4 = val2;
                throw new CmsException("can't process mime object to create signature.", (global::System.Exception)(object) e4);
            }
            catch (SignatureException ex)
            {
                throw new CmsException("invalid signature format in message: " + ((global::System.Exception)ex).get_Message(), ex);
            }
        }
コード例 #10
0
        private static global::System.Collections.ICollection GetAlternativeName(Asn1OctetString extVal)
        {
            //IL_010c: Unknown result type (might be due to invalid IL or missing references)
            global::System.Collections.IList list = Platform.CreateArrayList();
            if (extVal != null)
            {
                try
                {
                    Asn1Sequence instance = Asn1Sequence.GetInstance(FromExtensionValue(extVal));
                    global::System.Collections.IEnumerator enumerator = instance.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            GeneralName generalName = (GeneralName)enumerator.get_Current();
                            global::System.Collections.IList list2 = Platform.CreateArrayList();
                            list2.Add((object)generalName.TagNo);
                            switch (generalName.TagNo)
                            {
                            case 0:
                            case 3:
                            case 5:
                                list2.Add((object)generalName.Name.ToAsn1Object());
                                break;

                            case 4:
                                list2.Add((object)X509Name.GetInstance(generalName.Name).ToString());
                                break;

                            case 1:
                            case 2:
                            case 6:
                                list2.Add((object)((IAsn1String)generalName.Name).GetString());
                                break;

                            case 8:
                                list2.Add((object)DerObjectIdentifier.GetInstance(generalName.Name).Id);
                                break;

                            case 7:
                                list2.Add((object)Asn1OctetString.GetInstance(generalName.Name).GetOctets());
                                break;

                            default:
                                throw new IOException(string.Concat((object)"Bad tag number: ", (object)generalName.TagNo));
                            }
                            list.Add((object)list2);
                        }
                        return((global::System.Collections.ICollection)list);
                    }
                    finally
                    {
                        global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
                catch (global::System.Exception ex)
                {
                    throw new CertificateParsingException(ex.get_Message());
                }
            }
            return((global::System.Collections.ICollection)list);
        }
コード例 #11
0
            private void DoClose()
            {
                //IL_00b4: Unknown result type (might be due to invalid IL or missing references)
                //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
                Platform.Dispose(_out);
                _eiGen.Close();
                outer._digests.Clear();
                if (((global::System.Collections.ICollection)outer._certs).get_Count() > 0)
                {
                    Asn1Set obj = CmsUtilities.CreateBerSetFromList(outer._certs);
                    WriteToGenerator(_sigGen, new BerTaggedObject(explicitly: false, 0, obj));
                }
                if (((global::System.Collections.ICollection)outer._crls).get_Count() > 0)
                {
                    Asn1Set obj2 = CmsUtilities.CreateBerSetFromList(outer._crls);
                    WriteToGenerator(_sigGen, new BerTaggedObject(explicitly: false, 1, obj2));
                }
                IDictionaryEnumerator enumerator = outer._messageDigests.GetEnumerator();

                try
                {
                    while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
                    {
                        DictionaryEntry val = (DictionaryEntry)((global::System.Collections.IEnumerator)enumerator).get_Current();
                        outer._messageHashes.Add(((DictionaryEntry)(ref val)).get_Key(), (object)DigestUtilities.DoFinal((IDigest)((DictionaryEntry)(ref val)).get_Value()));
                    }
                }
                finally
                {
                    (enumerator as global::System.IDisposable)?.Dispose();
                }
                Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();

                global::System.Collections.IEnumerator enumerator2 = ((global::System.Collections.IEnumerable)outer._signerInfs).GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        DigestAndSignerInfoGeneratorHolder digestAndSignerInfoGeneratorHolder = (DigestAndSignerInfoGeneratorHolder)enumerator2.get_Current();
                        AlgorithmIdentifier digestAlgorithm = digestAndSignerInfoGeneratorHolder.DigestAlgorithm;
                        byte[] array = (byte[])outer._messageHashes.get_Item((object)Helper.GetDigestAlgName(digestAndSignerInfoGeneratorHolder.digestOID));
                        outer._digests.set_Item((object)digestAndSignerInfoGeneratorHolder.digestOID, ((global::System.Array)array).Clone());
                        asn1EncodableVector.Add(digestAndSignerInfoGeneratorHolder.signerInf.Generate(_contentOID, digestAlgorithm, array));
                    }
                }
                finally
                {
                    global::System.IDisposable disposable = enumerator2 as global::System.IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                enumerator2 = ((global::System.Collections.IEnumerable)outer._signers).GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        SignerInformation signerInformation = (SignerInformation)enumerator2.get_Current();
                        asn1EncodableVector.Add(signerInformation.ToSignerInfo());
                    }
                }
                finally
                {
                    global::System.IDisposable disposable2 = enumerator2 as global::System.IDisposable;
                    if (disposable2 != null)
                    {
                        disposable2.Dispose();
                    }
                }
                WriteToGenerator(_sigGen, new DerSet(asn1EncodableVector));
                _sigGen.Close();
                _sGen.Close();
            }
コード例 #12
0
        private OcspReq GenerateRequest(DerObjectIdentifier signingAlgorithm, AsymmetricKeyParameter privateKey, X509Certificate[] chain, SecureRandom random)
        {
            //IL_018f: Expected O, but got Unknown
            Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();

            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)list).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    RequestObject requestObject = (RequestObject)enumerator.get_Current();
                    try
                    {
                        asn1EncodableVector.Add(requestObject.ToRequest());
                    }
                    catch (global::System.Exception e)
                    {
                        throw new OcspException("exception creating Request", e);
                    }
                }
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            TbsRequest tbsRequest        = new TbsRequest(requestorName, new DerSequence(asn1EncodableVector), requestExtensions);
            ISigner    signer            = null;
            Signature  optionalSignature = null;

            if (signingAlgorithm != null)
            {
                if (requestorName == null)
                {
                    throw new OcspException("requestorName must be specified if request is signed.");
                }
                try
                {
                    signer = SignerUtilities.GetSigner(signingAlgorithm.Id);
                    if (random != null)
                    {
                        signer.Init(forSigning: true, new ParametersWithRandom(privateKey, random));
                    }
                    else
                    {
                        signer.Init(forSigning: true, privateKey);
                    }
                }
                catch (global::System.Exception ex)
                {
                    throw new OcspException(string.Concat((object)"exception creating signature: ", (object)ex), ex);
                }
                DerBitString derBitString = null;
                try
                {
                    byte[] encoded = tbsRequest.GetEncoded();
                    signer.BlockUpdate(encoded, 0, encoded.Length);
                    derBitString = new DerBitString(signer.GenerateSignature());
                }
                catch (global::System.Exception ex2)
                {
                    throw new OcspException(string.Concat((object)"exception processing TBSRequest: ", (object)ex2), ex2);
                }
                AlgorithmIdentifier signatureAlgorithm = new AlgorithmIdentifier(signingAlgorithm, DerNull.Instance);
                if (chain != null && chain.Length > 0)
                {
                    Asn1EncodableVector asn1EncodableVector2 = new Asn1EncodableVector();
                    try
                    {
                        for (int i = 0; i != chain.Length; i++)
                        {
                            asn1EncodableVector2.Add(X509CertificateStructure.GetInstance(Asn1Object.FromByteArray(chain[i].GetEncoded())));
                        }
                    }
                    catch (IOException val)
                    {
                        IOException e2 = val;
                        throw new OcspException("error processing certs", (global::System.Exception)(object) e2);
                    }
                    catch (CertificateEncodingException e3)
                    {
                        throw new OcspException("error encoding certs", e3);
                    }
                    optionalSignature = new Signature(signatureAlgorithm, derBitString, new DerSequence(asn1EncodableVector2));
                }
                else
                {
                    optionalSignature = new Signature(signatureAlgorithm, derBitString);
                }
            }
            return(new OcspReq(new OcspRequest(tbsRequest, optionalSignature)));
        }
コード例 #13
0
        private ProfessionInfo(Asn1Sequence seq)
        {
            //IL_0024: Unknown result type (might be due to invalid IL or missing references)
            //IL_0070: Unknown result type (might be due to invalid IL or missing references)
            //IL_010d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0168: Unknown result type (might be due to invalid IL or missing references)
            //IL_01a7: Unknown result type (might be due to invalid IL or missing references)
            if (seq.Count > 5)
            {
                throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count));
            }
            global::System.Collections.IEnumerator enumerator = seq.GetEnumerator();
            enumerator.MoveNext();
            Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current();

            if (asn1Encodable is Asn1TaggedObject)
            {
                Asn1TaggedObject asn1TaggedObject = (Asn1TaggedObject)asn1Encodable;
                if (asn1TaggedObject.TagNo != 0)
                {
                    throw new ArgumentException(string.Concat((object)"Bad tag number: ", (object)asn1TaggedObject.TagNo));
                }
                namingAuthority = NamingAuthority.GetInstance(asn1TaggedObject, isExplicit: true);
                enumerator.MoveNext();
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
            }
            professionItems = Asn1Sequence.GetInstance(asn1Encodable);
            if (enumerator.MoveNext())
            {
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
                if (asn1Encodable is Asn1Sequence)
                {
                    professionOids = Asn1Sequence.GetInstance(asn1Encodable);
                }
                else if (asn1Encodable is DerPrintableString)
                {
                    registrationNumber = DerPrintableString.GetInstance(asn1Encodable).GetString();
                }
                else
                {
                    if (!(asn1Encodable is Asn1OctetString))
                    {
                        throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
                    }
                    addProfessionInfo = Asn1OctetString.GetInstance(asn1Encodable);
                }
            }
            if (enumerator.MoveNext())
            {
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
                if (asn1Encodable is DerPrintableString)
                {
                    registrationNumber = DerPrintableString.GetInstance(asn1Encodable).GetString();
                }
                else
                {
                    if (!(asn1Encodable is DerOctetString))
                    {
                        throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
                    }
                    addProfessionInfo = (DerOctetString)asn1Encodable;
                }
            }
            if (enumerator.MoveNext())
            {
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
                if (!(asn1Encodable is DerOctetString))
                {
                    throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
                }
                addProfessionInfo = (DerOctetString)asn1Encodable;
            }
        }
コード例 #14
0
        protected virtual ISet GetExtensionOids(bool critical)
        {
            X509Extensions x509Extensions = GetX509Extensions();

            if (x509Extensions != null)
            {
                HashSet hashSet = new HashSet();
                {
                    global::System.Collections.IEnumerator enumerator = x509Extensions.ExtensionOids.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DerObjectIdentifier derObjectIdentifier = (DerObjectIdentifier)enumerator.get_Current();
                            X509Extension       extension           = x509Extensions.GetExtension(derObjectIdentifier);
                            if (extension.IsCritical == critical)
                            {
                                hashSet.Add(derObjectIdentifier.Id);
                            }
                        }
                        return(hashSet);
                    }
                    finally
                    {
                        global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
            }
            return(null);
        }
コード例 #15
0
        public virtual PkixCertPathValidatorResult Validate(PkixCertPath certPath, PkixParameters paramsPkix)
        {
            //IL_0012: Unknown result type (might be due to invalid IL or missing references)
            //IL_0170: Expected O, but got Unknown
            if (paramsPkix.GetTrustAnchors() == null)
            {
                throw new ArgumentException("trustAnchors is null, this is not allowed for certification path validation.", "parameters");
            }
            global::System.Collections.IList certificates = certPath.Certificates;
            int count = ((global::System.Collections.ICollection)certificates).get_Count();

            if (((global::System.Collections.ICollection)certificates).get_Count() == 0)
            {
                throw new PkixCertPathValidatorException("Certification path is empty.", null, certPath, 0);
            }
            ISet        initialPolicies = paramsPkix.GetInitialPolicies();
            TrustAnchor trustAnchor;

            try
            {
                trustAnchor = PkixCertPathValidatorUtilities.FindTrustAnchor((X509Certificate)certificates.get_Item(((global::System.Collections.ICollection)certificates).get_Count() - 1), paramsPkix.GetTrustAnchors());
            }
            catch (global::System.Exception ex)
            {
                throw new PkixCertPathValidatorException(ex.get_Message(), ex, certPath, ((global::System.Collections.ICollection)certificates).get_Count() - 1);
            }
            if (trustAnchor == null)
            {
                throw new PkixCertPathValidatorException("Trust anchor for certification path not found.", null, certPath, -1);
            }
            int num = 0;

            global::System.Collections.IList[] array = new global::System.Collections.IList[count + 1];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = Platform.CreateArrayList();
            }
            ISet set = new HashSet();

            set.Add(Rfc3280CertPathUtilities.ANY_POLICY);
            PkixPolicyNode pkixPolicyNode = new PkixPolicyNode(Platform.CreateArrayList(), 0, set, null, new HashSet(), Rfc3280CertPathUtilities.ANY_POLICY, critical: false);

            array[0].Add((object)pkixPolicyNode);
            PkixNameConstraintValidator nameConstraintValidator = new PkixNameConstraintValidator();
            ISet                   acceptablePolicies           = new HashSet();
            int                    explicitPolicy   = ((!paramsPkix.IsExplicitPolicyRequired) ? (count + 1) : 0);
            int                    inhibitAnyPolicy = ((!paramsPkix.IsAnyPolicyInhibited) ? (count + 1) : 0);
            int                    policyMapping    = ((!paramsPkix.IsPolicyMappingInhibited) ? (count + 1) : 0);
            X509Certificate        x509Certificate  = trustAnchor.TrustedCert;
            X509Name               workingIssuerName;
            AsymmetricKeyParameter asymmetricKeyParameter;

            try
            {
                if (x509Certificate != null)
                {
                    workingIssuerName      = x509Certificate.SubjectDN;
                    asymmetricKeyParameter = x509Certificate.GetPublicKey();
                }
                else
                {
                    workingIssuerName      = new X509Name(trustAnchor.CAName);
                    asymmetricKeyParameter = trustAnchor.CAPublicKey;
                }
            }
            catch (ArgumentException val)
            {
                ArgumentException cause = val;
                throw new PkixCertPathValidatorException("Subject of trust anchor could not be (re)encoded.", (global::System.Exception)(object) cause, certPath, -1);
            }
            try
            {
                PkixCertPathValidatorUtilities.GetAlgorithmIdentifier(asymmetricKeyParameter);
            }
            catch (PkixCertPathValidatorException cause2)
            {
                throw new PkixCertPathValidatorException("Algorithm identifier of public key of trust anchor could not be read.", cause2, certPath, -1);
            }
            int maxPathLength = count;
            X509CertStoreSelector targetCertConstraints = paramsPkix.GetTargetCertConstraints();

            if (targetCertConstraints != null && !targetCertConstraints.Match((X509Certificate)certificates.get_Item(0)))
            {
                throw new PkixCertPathValidatorException("Target certificate in certification path does not match targetConstraints.", null, certPath, 0);
            }
            global::System.Collections.IList       certPathCheckers = paramsPkix.GetCertPathCheckers();
            global::System.Collections.IEnumerator enumerator       = ((global::System.Collections.IEnumerable)certPathCheckers).GetEnumerator();
            while (enumerator.MoveNext())
            {
                ((PkixCertPathChecker)enumerator.get_Current()).Init(forward: false);
            }
            X509Certificate x509Certificate2 = null;

            for (num = ((global::System.Collections.ICollection)certificates).get_Count() - 1; num >= 0; num--)
            {
                int num2 = count - num;
                x509Certificate2 = (X509Certificate)certificates.get_Item(num);
                Rfc3280CertPathUtilities.ProcessCertA(certPath, paramsPkix, num, asymmetricKeyParameter, workingIssuerName, x509Certificate);
                Rfc3280CertPathUtilities.ProcessCertBC(certPath, num, nameConstraintValidator);
                pkixPolicyNode = Rfc3280CertPathUtilities.ProcessCertD(certPath, num, acceptablePolicies, pkixPolicyNode, array, inhibitAnyPolicy);
                pkixPolicyNode = Rfc3280CertPathUtilities.ProcessCertE(certPath, num, pkixPolicyNode);
                Rfc3280CertPathUtilities.ProcessCertF(certPath, num, pkixPolicyNode, explicitPolicy);
                if (num2 != count)
                {
                    if (x509Certificate2 != null && x509Certificate2.Version == 1)
                    {
                        throw new PkixCertPathValidatorException("Version 1 certificates can't be used as CA ones.", null, certPath, num);
                    }
                    Rfc3280CertPathUtilities.PrepareNextCertA(certPath, num);
                    pkixPolicyNode = Rfc3280CertPathUtilities.PrepareCertB(certPath, num, array, pkixPolicyNode, policyMapping);
                    Rfc3280CertPathUtilities.PrepareNextCertG(certPath, num, nameConstraintValidator);
                    explicitPolicy   = Rfc3280CertPathUtilities.PrepareNextCertH1(certPath, num, explicitPolicy);
                    policyMapping    = Rfc3280CertPathUtilities.PrepareNextCertH2(certPath, num, policyMapping);
                    inhibitAnyPolicy = Rfc3280CertPathUtilities.PrepareNextCertH3(certPath, num, inhibitAnyPolicy);
                    explicitPolicy   = Rfc3280CertPathUtilities.PrepareNextCertI1(certPath, num, explicitPolicy);
                    policyMapping    = Rfc3280CertPathUtilities.PrepareNextCertI2(certPath, num, policyMapping);
                    inhibitAnyPolicy = Rfc3280CertPathUtilities.PrepareNextCertJ(certPath, num, inhibitAnyPolicy);
                    Rfc3280CertPathUtilities.PrepareNextCertK(certPath, num);
                    maxPathLength = Rfc3280CertPathUtilities.PrepareNextCertL(certPath, num, maxPathLength);
                    maxPathLength = Rfc3280CertPathUtilities.PrepareNextCertM(certPath, num, maxPathLength);
                    Rfc3280CertPathUtilities.PrepareNextCertN(certPath, num);
                    ISet criticalExtensionOids = x509Certificate2.GetCriticalExtensionOids();
                    if (criticalExtensionOids != null)
                    {
                        criticalExtensionOids = new HashSet(criticalExtensionOids);
                        criticalExtensionOids.Remove(X509Extensions.KeyUsage.Id);
                        criticalExtensionOids.Remove(X509Extensions.CertificatePolicies.Id);
                        criticalExtensionOids.Remove(X509Extensions.PolicyMappings.Id);
                        criticalExtensionOids.Remove(X509Extensions.InhibitAnyPolicy.Id);
                        criticalExtensionOids.Remove(X509Extensions.IssuingDistributionPoint.Id);
                        criticalExtensionOids.Remove(X509Extensions.DeltaCrlIndicator.Id);
                        criticalExtensionOids.Remove(X509Extensions.PolicyConstraints.Id);
                        criticalExtensionOids.Remove(X509Extensions.BasicConstraints.Id);
                        criticalExtensionOids.Remove(X509Extensions.SubjectAlternativeName.Id);
                        criticalExtensionOids.Remove(X509Extensions.NameConstraints.Id);
                    }
                    else
                    {
                        criticalExtensionOids = new HashSet();
                    }
                    Rfc3280CertPathUtilities.PrepareNextCertO(certPath, num, criticalExtensionOids, certPathCheckers);
                    x509Certificate   = x509Certificate2;
                    workingIssuerName = x509Certificate.SubjectDN;
                    try
                    {
                        asymmetricKeyParameter = PkixCertPathValidatorUtilities.GetNextWorkingKey(certPath.Certificates, num);
                    }
                    catch (PkixCertPathValidatorException cause3)
                    {
                        throw new PkixCertPathValidatorException("Next working key could not be retrieved.", cause3, certPath, num);
                    }
                    PkixCertPathValidatorUtilities.GetAlgorithmIdentifier(asymmetricKeyParameter);
                }
            }
            explicitPolicy = Rfc3280CertPathUtilities.WrapupCertA(explicitPolicy, x509Certificate2);
            explicitPolicy = Rfc3280CertPathUtilities.WrapupCertB(certPath, num + 1, explicitPolicy);
            ISet criticalExtensionOids2 = x509Certificate2.GetCriticalExtensionOids();

            if (criticalExtensionOids2 != null)
            {
                criticalExtensionOids2 = new HashSet(criticalExtensionOids2);
                criticalExtensionOids2.Remove(X509Extensions.KeyUsage.Id);
                criticalExtensionOids2.Remove(X509Extensions.CertificatePolicies.Id);
                criticalExtensionOids2.Remove(X509Extensions.PolicyMappings.Id);
                criticalExtensionOids2.Remove(X509Extensions.InhibitAnyPolicy.Id);
                criticalExtensionOids2.Remove(X509Extensions.IssuingDistributionPoint.Id);
                criticalExtensionOids2.Remove(X509Extensions.DeltaCrlIndicator.Id);
                criticalExtensionOids2.Remove(X509Extensions.PolicyConstraints.Id);
                criticalExtensionOids2.Remove(X509Extensions.BasicConstraints.Id);
                criticalExtensionOids2.Remove(X509Extensions.SubjectAlternativeName.Id);
                criticalExtensionOids2.Remove(X509Extensions.NameConstraints.Id);
                criticalExtensionOids2.Remove(X509Extensions.CrlDistributionPoints.Id);
            }
            else
            {
                criticalExtensionOids2 = new HashSet();
            }
            Rfc3280CertPathUtilities.WrapupCertF(certPath, num + 1, certPathCheckers, criticalExtensionOids2);
            PkixPolicyNode pkixPolicyNode2 = Rfc3280CertPathUtilities.WrapupCertG(certPath, paramsPkix, initialPolicies, num + 1, array, pkixPolicyNode, acceptablePolicies);

            if (explicitPolicy > 0 || pkixPolicyNode2 != null)
            {
                return(new PkixCertPathValidatorResult(trustAnchor, pkixPolicyNode2, x509Certificate2.GetPublicKey()));
            }
            throw new PkixCertPathValidatorException("Path processing failed on policy.", null, certPath, num);
        }
コード例 #16
0
ファイル: Asn1Dump.cs プロジェクト: smdx24/CPI-Source-Code
 private static void AsString(string indent, bool verbose, Asn1Object obj, StringBuilder buf)
 {
     if (obj is Asn1Sequence)
     {
         string text = indent + "    ";
         buf.Append(indent);
         if (obj is BerSequence)
         {
             buf.Append("BER Sequence");
         }
         else if (obj is DerSequence)
         {
             buf.Append("DER Sequence");
         }
         else
         {
             buf.Append("Sequence");
         }
         buf.Append(NewLine);
         {
             global::System.Collections.IEnumerator enumerator = ((Asn1Sequence)obj).GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current();
                     if (asn1Encodable == null || asn1Encodable is Asn1Null)
                     {
                         buf.Append(text);
                         buf.Append("NULL");
                         buf.Append(NewLine);
                     }
                     else
                     {
                         AsString(text, verbose, asn1Encodable.ToAsn1Object(), buf);
                     }
                 }
             }
             finally
             {
                 global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                 if (disposable != null)
                 {
                     disposable.Dispose();
                 }
             }
         }
     }
     else if (obj is DerTaggedObject)
     {
         string text2 = indent + "    ";
         buf.Append(indent);
         if (obj is BerTaggedObject)
         {
             buf.Append("BER Tagged [");
         }
         else
         {
             buf.Append("Tagged [");
         }
         DerTaggedObject derTaggedObject = (DerTaggedObject)obj;
         buf.Append(derTaggedObject.TagNo.ToString());
         buf.Append(']');
         if (!derTaggedObject.IsExplicit())
         {
             buf.Append(" IMPLICIT ");
         }
         buf.Append(NewLine);
         if (derTaggedObject.IsEmpty())
         {
             buf.Append(text2);
             buf.Append("EMPTY");
             buf.Append(NewLine);
         }
         else
         {
             AsString(text2, verbose, derTaggedObject.GetObject(), buf);
         }
     }
     else if (obj is BerSet)
     {
         string text3 = indent + "    ";
         buf.Append(indent);
         buf.Append("BER Set");
         buf.Append(NewLine);
         {
             global::System.Collections.IEnumerator enumerator = ((Asn1Set)obj).GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     Asn1Encodable asn1Encodable2 = (Asn1Encodable)enumerator.get_Current();
                     if (asn1Encodable2 == null)
                     {
                         buf.Append(text3);
                         buf.Append("NULL");
                         buf.Append(NewLine);
                     }
                     else
                     {
                         AsString(text3, verbose, asn1Encodable2.ToAsn1Object(), buf);
                     }
                 }
             }
             finally
             {
                 global::System.IDisposable disposable2 = enumerator as global::System.IDisposable;
                 if (disposable2 != null)
                 {
                     disposable2.Dispose();
                 }
             }
         }
     }
     else if (obj is DerSet)
     {
         string text4 = indent + "    ";
         buf.Append(indent);
         buf.Append("DER Set");
         buf.Append(NewLine);
         {
             global::System.Collections.IEnumerator enumerator = ((Asn1Set)obj).GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     Asn1Encodable asn1Encodable3 = (Asn1Encodable)enumerator.get_Current();
                     if (asn1Encodable3 == null)
                     {
                         buf.Append(text4);
                         buf.Append("NULL");
                         buf.Append(NewLine);
                     }
                     else
                     {
                         AsString(text4, verbose, asn1Encodable3.ToAsn1Object(), buf);
                     }
                 }
             }
             finally
             {
                 global::System.IDisposable disposable3 = enumerator as global::System.IDisposable;
                 if (disposable3 != null)
                 {
                     disposable3.Dispose();
                 }
             }
         }
     }
     else if (obj is DerObjectIdentifier)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "ObjectIdentifier(",
             ((DerObjectIdentifier)obj).Id,
             ")",
             NewLine
         }));
     }
     else if (obj is DerBoolean)
     {
         buf.Append(string.Concat(new object[5]
         {
             indent,
             "Boolean(",
             ((DerBoolean)obj).IsTrue,
             ")",
             NewLine
         }));
     }
     else if (obj is DerInteger)
     {
         buf.Append(string.Concat(new object[5]
         {
             indent,
             "Integer(",
             ((DerInteger)obj).Value,
             ")",
             NewLine
         }));
     }
     else if (obj is BerOctetString)
     {
         byte[] octets = ((Asn1OctetString)obj).GetOctets();
         string text5  = (verbose ? dumpBinaryDataAsString(indent, octets) : "");
         buf.Append(string.Concat(new object[6] {
             indent, "BER Octet String[", octets.Length, "] ", text5, NewLine
         }));
     }
     else if (obj is DerOctetString)
     {
         byte[] octets2 = ((Asn1OctetString)obj).GetOctets();
         string text6   = (verbose ? dumpBinaryDataAsString(indent, octets2) : "");
         buf.Append(string.Concat(new object[6] {
             indent, "DER Octet String[", octets2.Length, "] ", text6, NewLine
         }));
     }
     else if (obj is DerBitString)
     {
         DerBitString derBitString = (DerBitString)obj;
         byte[]       bytes        = derBitString.GetBytes();
         string       text7        = (verbose ? dumpBinaryDataAsString(indent, bytes) : "");
         buf.Append(string.Concat(new object[8] {
             indent, "DER Bit String[", bytes.Length, ", ", derBitString.PadBits, "] ", text7, NewLine
         }));
     }
     else if (obj is DerIA5String)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "IA5String(",
             ((DerIA5String)obj).GetString(),
             ") ",
             NewLine
         }));
     }
     else if (obj is DerUtf8String)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "UTF8String(",
             ((DerUtf8String)obj).GetString(),
             ") ",
             NewLine
         }));
     }
     else if (obj is DerPrintableString)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "PrintableString(",
             ((DerPrintableString)obj).GetString(),
             ") ",
             NewLine
         }));
     }
     else if (obj is DerVisibleString)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "VisibleString(",
             ((DerVisibleString)obj).GetString(),
             ") ",
             NewLine
         }));
     }
     else if (obj is DerBmpString)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "BMPString(",
             ((DerBmpString)obj).GetString(),
             ") ",
             NewLine
         }));
     }
     else if (obj is DerT61String)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "T61String(",
             ((DerT61String)obj).GetString(),
             ") ",
             NewLine
         }));
     }
     else if (obj is DerGraphicString)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "GraphicString(",
             ((DerGraphicString)obj).GetString(),
             ") ",
             NewLine
         }));
     }
     else if (obj is DerVideotexString)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "VideotexString(",
             ((DerVideotexString)obj).GetString(),
             ") ",
             NewLine
         }));
     }
     else if (obj is DerUtcTime)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "UTCTime(",
             ((DerUtcTime)obj).TimeString,
             ") ",
             NewLine
         }));
     }
     else if (obj is DerGeneralizedTime)
     {
         buf.Append(string.Concat(new string[5]
         {
             indent,
             "GeneralizedTime(",
             ((DerGeneralizedTime)obj).GetTime(),
             ") ",
             NewLine
         }));
     }
     else if (obj is BerApplicationSpecific)
     {
         buf.Append(outputApplicationSpecific("BER", indent, verbose, (BerApplicationSpecific)obj));
     }
     else if (obj is DerApplicationSpecific)
     {
         buf.Append(outputApplicationSpecific("DER", indent, verbose, (DerApplicationSpecific)obj));
     }
     else if (obj is DerEnumerated)
     {
         DerEnumerated derEnumerated = (DerEnumerated)obj;
         buf.Append(string.Concat(new object[5] {
             indent, "DER Enumerated(", derEnumerated.Value, ")", NewLine
         }));
     }
     else if (obj is DerExternal)
     {
         DerExternal derExternal = (DerExternal)obj;
         buf.Append(indent + "External " + NewLine);
         string text8 = indent + "    ";
         if (derExternal.DirectReference != null)
         {
             buf.Append(text8 + "Direct Reference: " + derExternal.DirectReference.Id + NewLine);
         }
         if (derExternal.IndirectReference != null)
         {
             buf.Append(text8 + "Indirect Reference: " + derExternal.IndirectReference.ToString() + NewLine);
         }
         if (derExternal.DataValueDescriptor != null)
         {
             AsString(text8, verbose, derExternal.DataValueDescriptor, buf);
         }
         buf.Append(string.Concat(new object[4] {
             text8, "Encoding: ", derExternal.Encoding, NewLine
         }));
         AsString(text8, verbose, derExternal.ExternalContent, buf);
     }
     else
     {
         buf.Append(indent + ((object)obj).ToString() + NewLine);
     }
 }
コード例 #17
0
        public override void Finish()
        {
            if (entries == null)
            {
                return;
            }
            if (curEntry != null)
            {
                CloseEntry();
            }
            long noOfEntries = entries.get_Count();
            long num         = 0L;

            global::System.Collections.IEnumerator enumerator = entries.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    ZipEntry zipEntry = (ZipEntry)enumerator.get_Current();
                    WriteLeInt(33639248);
                    WriteLeShort(51);
                    WriteLeShort(zipEntry.Version);
                    WriteLeShort(zipEntry.Flags);
                    WriteLeShort((short)zipEntry.CompressionMethodForHeader);
                    WriteLeInt((int)zipEntry.DosTime);
                    WriteLeInt((int)zipEntry.Crc);
                    if (zipEntry.IsZip64Forced() || zipEntry.CompressedSize >= 4294967295u)
                    {
                        WriteLeInt(-1);
                    }
                    else
                    {
                        WriteLeInt((int)zipEntry.CompressedSize);
                    }
                    if (zipEntry.IsZip64Forced() || zipEntry.Size >= 4294967295u)
                    {
                        WriteLeInt(-1);
                    }
                    else
                    {
                        WriteLeInt((int)zipEntry.Size);
                    }
                    byte[] array = ZipConstants.ConvertToArray(zipEntry.Flags, zipEntry.Name);
                    if (array.Length > 65535)
                    {
                        throw new ZipException("Name too long.");
                    }
                    ZipExtraData zipExtraData = new ZipExtraData(zipEntry.ExtraData);
                    if (zipEntry.CentralHeaderRequiresZip64)
                    {
                        zipExtraData.StartNewEntry();
                        if (zipEntry.IsZip64Forced() || zipEntry.Size >= 4294967295u)
                        {
                            zipExtraData.AddLeLong(zipEntry.Size);
                        }
                        if (zipEntry.IsZip64Forced() || zipEntry.CompressedSize >= 4294967295u)
                        {
                            zipExtraData.AddLeLong(zipEntry.CompressedSize);
                        }
                        if (zipEntry.Offset >= 4294967295u)
                        {
                            zipExtraData.AddLeLong(zipEntry.Offset);
                        }
                        zipExtraData.AddNewEntry(1);
                    }
                    else
                    {
                        zipExtraData.Delete(1);
                    }
                    byte[] entryData = zipExtraData.GetEntryData();
                    byte[] array2    = ((zipEntry.Comment != null) ? ZipConstants.ConvertToArray(zipEntry.Flags, zipEntry.Comment) : new byte[0]);
                    if (array2.Length > 65535)
                    {
                        throw new ZipException("Comment too long.");
                    }
                    WriteLeShort(array.Length);
                    WriteLeShort(entryData.Length);
                    WriteLeShort(array2.Length);
                    WriteLeShort(0);
                    WriteLeShort(0);
                    if (zipEntry.ExternalFileAttributes != -1)
                    {
                        WriteLeInt(zipEntry.ExternalFileAttributes);
                    }
                    else if (zipEntry.IsDirectory)
                    {
                        WriteLeInt(16);
                    }
                    else
                    {
                        WriteLeInt(0);
                    }
                    if (zipEntry.Offset >= 4294967295u)
                    {
                        WriteLeInt(-1);
                    }
                    else
                    {
                        WriteLeInt((int)zipEntry.Offset);
                    }
                    if (array.Length > 0)
                    {
                        baseOutputStream_.Write(array, 0, array.Length);
                    }
                    if (entryData.Length > 0)
                    {
                        baseOutputStream_.Write(entryData, 0, entryData.Length);
                    }
                    if (array2.Length > 0)
                    {
                        baseOutputStream_.Write(array2, 0, array2.Length);
                    }
                    num += 46 + array.Length + entryData.Length + array2.Length;
                }
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            ZipHelperStream zipHelperStream = new ZipHelperStream(baseOutputStream_);

            try
            {
                zipHelperStream.WriteEndOfCentralDirectory(noOfEntries, num, offset, zipComment);
            }
            finally
            {
                ((global::System.IDisposable)zipHelperStream)?.Dispose();
            }
            entries = null;
        }
コード例 #18
0
 internal static void AddAdditionalStoresFromAltNames(X509Certificate cert, PkixParameters pkixParams)
 {
     if (cert.GetIssuerAlternativeNames() == null)
     {
         return;
     }
     global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)cert.GetIssuerAlternativeNames()).GetEnumerator();
     while (enumerator.MoveNext())
     {
         global::System.Collections.IList list = (global::System.Collections.IList)enumerator.get_Current();
         if (list.get_Item(0).Equals((object)6))
         {
             string location = (string)list.get_Item(1);
             AddAdditionalStoreFromLocation(location, pkixParams);
         }
     }
 }
コード例 #19
0
        protected internal static void WriteSupplementalData(Stream output, global::System.Collections.IList supplementalData)
        {
            //IL_0000: Unknown result type (might be due to invalid IL or missing references)
            //IL_0006: Expected O, but got Unknown
            MemoryStream val = new MemoryStream();

            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)supplementalData).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    SupplementalDataEntry supplementalDataEntry = (SupplementalDataEntry)enumerator.get_Current();
                    int dataType = supplementalDataEntry.DataType;
                    TlsUtilities.CheckUint16(dataType);
                    TlsUtilities.WriteUint16(dataType, (Stream)(object)val);
                    TlsUtilities.WriteOpaque16(supplementalDataEntry.Data, (Stream)(object)val);
                }
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            byte[] buf = val.ToArray();
            TlsUtilities.WriteOpaque24(buf, output);
        }
コード例 #20
0
        internal static void PrepareNextCertB1(int i, global::System.Collections.IList[] policyNodes, string id_p, IDictionary m_idp, X509Certificate cert)
        {
            bool flag = false;

            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)policyNodes[i]).GetEnumerator();
            while (enumerator.MoveNext())
            {
                PkixPolicyNode pkixPolicyNode = (PkixPolicyNode)enumerator.get_Current();
                if (pkixPolicyNode.ValidPolicy.Equals(id_p))
                {
                    flag = true;
                    pkixPolicyNode.ExpectedPolicies = (ISet)m_idp.get_Item((object)id_p);
                    break;
                }
            }
            if (flag)
            {
                return;
            }
            enumerator = ((global::System.Collections.IEnumerable)policyNodes[i]).GetEnumerator();
            while (enumerator.MoveNext())
            {
                PkixPolicyNode pkixPolicyNode2 = (PkixPolicyNode)enumerator.get_Current();
                if (!ANY_POLICY.Equals(pkixPolicyNode2.ValidPolicy))
                {
                    continue;
                }
                ISet         policyQualifiers = null;
                Asn1Sequence asn1Sequence     = null;
                try
                {
                    asn1Sequence = Asn1Sequence.GetInstance(GetExtensionValue(cert, X509Extensions.CertificatePolicies));
                }
                catch (global::System.Exception ex)
                {
                    throw new global::System.Exception("Certificate policies cannot be decoded.", ex);
                }
                global::System.Collections.IEnumerator enumerator2 = asn1Sequence.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    PolicyInformation policyInformation = null;
                    try
                    {
                        policyInformation = PolicyInformation.GetInstance(enumerator2.get_Current());
                    }
                    catch (global::System.Exception ex2)
                    {
                        throw new global::System.Exception("Policy information cannot be decoded.", ex2);
                    }
                    if (ANY_POLICY.Equals(policyInformation.PolicyIdentifier.Id))
                    {
                        try
                        {
                            policyQualifiers = GetQualifierSet(policyInformation.PolicyQualifiers);
                        }
                        catch (PkixCertPathValidatorException cause)
                        {
                            throw new PkixCertPathValidatorException("Policy qualifier info set could not be built.", cause);
                        }
                        break;
                    }
                }
                bool critical = false;
                ISet criticalExtensionOids = cert.GetCriticalExtensionOids();
                if (criticalExtensionOids != null)
                {
                    critical = criticalExtensionOids.Contains(X509Extensions.CertificatePolicies.Id);
                }
                PkixPolicyNode parent = pkixPolicyNode2.Parent;
                if (ANY_POLICY.Equals(parent.ValidPolicy))
                {
                    PkixPolicyNode pkixPolicyNode3 = new PkixPolicyNode(Platform.CreateArrayList(), i, (ISet)m_idp.get_Item((object)id_p), parent, policyQualifiers, id_p, critical);
                    parent.AddChild(pkixPolicyNode3);
                    policyNodes[i].Add((object)pkixPolicyNode3);
                }
                break;
            }
        }
コード例 #21
0
        internal static PkixCertPath ProcessAttrCert1(IX509AttributeCertificate attrCert, PkixParameters pkixParams)
        {
            PkixCertPathBuilderResult pkixCertPathBuilderResult = null;
            ISet set = new HashSet();

            if (attrCert.Holder.GetIssuer() != null)
            {
                X509CertStoreSelector x509CertStoreSelector = new X509CertStoreSelector();
                x509CertStoreSelector.SerialNumber = attrCert.Holder.SerialNumber;
                X509Name[] issuer = attrCert.Holder.GetIssuer();
                for (int i = 0; i < issuer.Length; i++)
                {
                    try
                    {
                        x509CertStoreSelector.Issuer = issuer[i];
                        set.AddAll((global::System.Collections.IEnumerable)PkixCertPathValidatorUtilities.FindCertificates(x509CertStoreSelector, pkixParams.GetStores()));
                    }
                    catch (global::System.Exception cause)
                    {
                        throw new PkixCertPathValidatorException("Public key certificate for attribute certificate cannot be searched.", cause);
                    }
                }
                if (set.IsEmpty)
                {
                    throw new PkixCertPathValidatorException("Public key certificate specified in base certificate ID for attribute certificate cannot be found.");
                }
            }
            if (attrCert.Holder.GetEntityNames() != null)
            {
                X509CertStoreSelector x509CertStoreSelector2 = new X509CertStoreSelector();
                X509Name[]            entityNames            = attrCert.Holder.GetEntityNames();
                for (int j = 0; j < entityNames.Length; j++)
                {
                    try
                    {
                        x509CertStoreSelector2.Issuer = entityNames[j];
                        set.AddAll((global::System.Collections.IEnumerable)PkixCertPathValidatorUtilities.FindCertificates(x509CertStoreSelector2, pkixParams.GetStores()));
                    }
                    catch (global::System.Exception cause2)
                    {
                        throw new PkixCertPathValidatorException("Public key certificate for attribute certificate cannot be searched.", cause2);
                    }
                }
                if (set.IsEmpty)
                {
                    throw new PkixCertPathValidatorException("Public key certificate specified in entity name for attribute certificate cannot be found.");
                }
            }
            PkixBuilderParameters          instance = PkixBuilderParameters.GetInstance(pkixParams);
            PkixCertPathValidatorException ex       = null;

            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)set).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    X509Certificate       certificate            = (X509Certificate)enumerator.get_Current();
                    X509CertStoreSelector x509CertStoreSelector3 = new X509CertStoreSelector();
                    x509CertStoreSelector3.Certificate = certificate;
                    instance.SetTargetConstraints(x509CertStoreSelector3);
                    PkixCertPathBuilder pkixCertPathBuilder = new PkixCertPathBuilder();
                    try
                    {
                        pkixCertPathBuilderResult = pkixCertPathBuilder.Build(PkixBuilderParameters.GetInstance(instance));
                    }
                    catch (PkixCertPathBuilderException cause3)
                    {
                        ex = new PkixCertPathValidatorException("Certification path for public key certificate of attribute certificate could not be build.", cause3);
                    }
                }
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            if (ex != null)
            {
                throw ex;
            }
            return(pkixCertPathBuilderResult.CertPath);
        }
コード例 #22
0
 public RecipientInformationStore(global::System.Collections.ICollection recipientInfos)
 {
     global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)recipientInfos).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             RecipientInformation             recipientInformation = (RecipientInformation)enumerator.get_Current();
             RecipientID                      recipientID          = recipientInformation.RecipientID;
             global::System.Collections.IList list = (global::System.Collections.IList)table.get_Item((object)recipientID);
             if (list == null)
             {
                 table.set_Item((object)recipientID, (object)(list = Platform.CreateArrayList(1)));
             }
             list.Add((object)recipientInformation);
         }
     }
     finally
     {
         global::System.IDisposable disposable = enumerator as global::System.IDisposable;
         if (disposable != null)
         {
             disposable.Dispose();
         }
     }
     all = Platform.CreateArrayList(recipientInfos);
 }