예제 #1
0
 private static String LookupMnemonicByOID(DerObjectIdentifier oid)
 {
     if (oid.Equals(X509ObjectIdentifiers.Organization)) { return "O"; }
     if (oid.Equals(X509ObjectIdentifiers.OrganizationalUnitName)) { return "OU"; }
     if (oid.Equals(X509ObjectIdentifiers.CommonName)) { return "CN"; }
     if (oid.Equals(X509ObjectIdentifiers.CountryName)) { return "C"; }
     if (oid.Equals(X509ObjectIdentifiers.StateOrProvinceName)) { return "ST"; }
     if (oid.Equals(X509ObjectIdentifiers.LocalityName)) { return "L"; }
     if (oid.Equals(X509ObjectIdentifiers.IdSha1)) { return "SHA1"; }
     if (oid.Equals(NistObjectIdentifiers.IdSha224)) { return "SHA224"; }
     if (oid.Equals(NistObjectIdentifiers.IdSha256)) { return "SHA256"; }
     if (oid.Equals(NistObjectIdentifiers.IdSha384)) { return "SHA384"; }
     if (oid.Equals(NistObjectIdentifiers.IdSha512)) { return "SHA512"; }
     if (oid.Equals(PKCS1_SHA256_WITH_RSA_OID)) { return "SHA256withRSA"; }
     if (oid.Equals(PKCS1_SHA384_WITH_RSA_OID)) { return "SHA384withRSA"; }
     if (oid.Equals(PKCS1_SHA512_WITH_RSA_OID)) { return "SHA512withRSA"; }
     if (oid.Equals(PKCS1_SHA224_WITH_RSA_OID)) { return "SHA224withRSA"; }
     throw new ArgumentException("Unknown OID " + oid);
 }
        private void DoGetCapabilitiesForOid(DerObjectIdentifier capability, IList list)
        {
            if (capability == null)
            {
                foreach (object o in capabilities)
                {
                    SmimeCapability cap = SmimeCapability.GetInstance(o);

                    list.Add(cap);
                }
            }
            else
            {
                foreach (object o in capabilities)
                {
                    SmimeCapability cap = SmimeCapability.GetInstance(o);

                    if (capability.Equals(cap.CapabilityID))
                    {
                        list.Add(cap);
                    }
                }
            }
        }
예제 #3
0
        // RFC3852, section 5.1:
        // IF ((certificates is present) AND
        //    (any certificates with a type of other are present)) OR
        //    ((crls is present) AND
        //    (any crls with a type of other are present))
        // THEN version MUST be 5
        // ELSE
        //    IF (certificates is present) AND
        //       (any version 2 attribute certificates are present)
        //    THEN version MUST be 4
        //    ELSE
        //       IF ((certificates is present) AND
        //          (any version 1 attribute certificates are present)) OR
        //          (any SignerInfo structures are version 3) OR
        //          (encapContentInfo eContentType is other than id-data)
        //       THEN version MUST be 3
        //       ELSE version MUST be 1
        //
        private DerInteger CalculateVersion(
			DerObjectIdentifier	contentOid,
			Asn1Set				certs,
			Asn1Set				crls,
			Asn1Set				signerInfs)
        {
            bool otherCert = false;
            bool otherCrl = false;
            bool attrCertV1Found = false;
            bool attrCertV2Found = false;

            if (certs != null)
            {
                foreach (object obj in certs)
                {
                    if (obj is Asn1TaggedObject)
                    {
                        Asn1TaggedObject tagged = (Asn1TaggedObject)obj;

                        if (tagged.TagNo == 1)
                        {
                            attrCertV1Found = true;
                        }
                        else if (tagged.TagNo == 2)
                        {
                            attrCertV2Found = true;
                        }
                        else if (tagged.TagNo == 3)
                        {
                            otherCert = true;
                            break;
                        }
                    }
                }
            }

            if (otherCert)
            {
                return new DerInteger(5);
            }

            if (crls != null)
            {
                foreach (object obj in crls)
                {
                    if (obj is Asn1TaggedObject)
                    {
                        otherCrl = true;
                        break;
                    }
                }
            }

            if (otherCrl)
            {
                return new DerInteger(5);
            }

            if (attrCertV2Found)
            {
                return new DerInteger(4);
            }

            if (attrCertV1Found)
            {
                return new DerInteger(3);
            }

            if (contentOid.Equals(CmsObjectIdentifiers.Data)
                && !CheckForVersion3(signerInfs))
            {
                return new DerInteger(1);
            }

            return new DerInteger(3);
        }
 private static String GetAccessDescriptionUrlForOid(DerObjectIdentifier oid, AccessDescription[] authorityInformationAccessArray)
 {
     foreach (AccessDescription authorityInformationAcces in authorityInformationAccessArray)
     {
         if (oid.Equals(authorityInformationAcces.AccessMethod))
         {
             var name = authorityInformationAcces.AccessLocation;
             return ((DerIA5String)name.Name).GetString();
         }
     }
     return null;
 }
예제 #5
0
		/**
         * returns an ArrayList with 0 or more objects of all the capabilities
         * matching the passed in capability Oid. If the Oid passed is null the
         * entire set is returned.
         */
        public ArrayList GetCapabilities(
            DerObjectIdentifier capability)
        {
            ArrayList list = new ArrayList();

			if (capability == null)
            {
				foreach (object o in capabilities)
				{
                    SmimeCapability cap = SmimeCapability.GetInstance(o);

					list.Add(cap);
                }
            }
            else
            {
				foreach (object o in capabilities)
				{
                    SmimeCapability cap = SmimeCapability.GetInstance(o);

					if (capability.Equals(cap.CapabilityID))
                    {
                        list.Add(cap);
                    }
                }
            }

			return list;
        }