Ejemplo n.º 1
0
        static void Reg(string oid, string name)
        {
            if (!OIDToName.ContainsKey(oid))
            {
                OIDToName.Add(oid, name);
            }
            string nn = Normalize(name);

            if (NameToOID.ContainsKey(nn))
            {
                throw new Exception("OID name collision: " + nn);
            }
            NameToOID.Add(nn, oid);

            /* Many names start with 'id-??-' and we want to support the short names (without that
             * prefix) as aliases. But we must take care of some collisions on short names. */
            if (name.StartsWith("id-") && name.Length >= 7 && name[5] == '-')
            {
                if (name.StartsWith("id-ad-"))
                {
                    Reg(oid, name.Substring(6) + "-IA");
                }
                else if (name.StartsWith("id-kp-"))
                {
                    Reg(oid, name.Substring(6) + "-EKU");
                }
                else
                {
                    Reg(oid, name.Substring(6));
                }
            }
        }
Ejemplo n.º 2
0
        public static string ToOID(string name)
        {
            if (IsNumericOID(name))
            {
                return(name);
            }
            string nn = Normalize(name);

            if (!NameToOID.ContainsKey(nn))
            {
                throw new AsnException("unrecognized OID name: " + name);
            }
            return(NameToOID[nn]);
        }