Exemplo n.º 1
0
        public static Asn1Node GetDecendantNodeByOid(string oid, Asn1Node startNode)
        {
            Asn1Node asn1Node = (Asn1Node)null;
            Oid      oid1     = new Oid();

            for (int index = 0; (long)index < startNode.ChildNodeCount; ++index)
            {
                Asn1Node childNode = startNode.GetChildNode(index);
                if (((int)childNode.tag & 31) == 6 && oid == oid1.Decode(childNode.Data))
                {
                    asn1Node = childNode;
                    break;
                }
                asn1Node = Asn1Node.GetDecendantNodeByOid(oid, childNode);
                if (asn1Node != null)
                {
                    break;
                }
            }
            return(asn1Node);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get node label string.
        /// </summary>
        /// <param name="mask">
        /// <code>
		/// SHOW_OFFSET
		/// SHOW_DATA
		/// USE_HEX_OFFSET
		/// SHOW_TAG_NUMBER
		/// SHOW_PATH</code>
		/// </param>
        /// <returns>string</returns>
        public string GetLabel(uint mask)
        {
            string nodeStr = "";
            string dataStr = "";
            string offsetStr = "";
            if ((mask & TagTextMask.USE_HEX_OFFSET) != 0)
            {
                if ((mask & TagTextMask.SHOW_TAG_NUMBER) != 0)
                    offsetStr = String.Format("(0x{0:X2},0x{1:X6},0x{2:X4})", tag, dataOffset, dataLength);
                else
                    offsetStr = String.Format("(0x{0:X6},0x{1:X4})", dataOffset, dataLength);
            }
            else
            {
                if ((mask & TagTextMask.SHOW_TAG_NUMBER) != 0)
                    offsetStr = String.Format("({0},{1},{2})", tag, dataOffset, dataLength);
                else
                    offsetStr = String.Format("({0},{1})", dataOffset, dataLength);
            }
            string oid, oidName;
            switch (tag)
            {
                case Asn1Tag.BIT_STRING:
                    if ((mask & TagTextMask.SHOW_OFFSET) != 0)
                    {
                        nodeStr += offsetStr;
                    }
                    nodeStr += " " + TagName + " UnusedBits: " + unusedBits.ToString();
                    if ((mask & TagTextMask.SHOW_DATA) != 0)
                    {
                        dataStr = Asn1Util.ToHexString(data);
                        nodeStr += ((dataStr.Length>0) ? " : '" + dataStr + "'" : "");
                    }
                    break;
                case Asn1Tag.OBJECT_IDENTIFIER:
                    Oid xoid = new Oid();
                    oid = xoid.Decode(data);
                    oidName = xoid.GetOidName(oid);
                    if ((mask & TagTextMask.SHOW_OFFSET) != 0)
                    {
                        nodeStr += offsetStr;
                    }
                    nodeStr += " " + TagName;
                    nodeStr += " : " + oidName;
                    if ((mask & TagTextMask.SHOW_DATA) != 0)
                    {
                        nodeStr += ((oid.Length>0) ? " : '" + oid + "'" : "");
                    }
                    break;
                case Asn1Tag.RELATIVE_OID:
                    RelativeOid roid = new RelativeOid();
                    oid = roid.Decode(data);
                    oidName = "";
                    if ((mask & TagTextMask.SHOW_OFFSET) != 0)
                    {
                        nodeStr += offsetStr;
                    }
                    nodeStr += " " + TagName;
                    nodeStr += " : " + oidName;
                    if ((mask & TagTextMask.SHOW_DATA) != 0)
                    {
                        nodeStr += ((oid.Length>0) ? " : '" + oid + "'" : "");
                    }
                    break;
                case Asn1Tag.PRINTABLE_STRING:
                case Asn1Tag.IA5_STRING:
                case Asn1Tag.UNIVERSAL_STRING:
                case Asn1Tag.VISIBLE_STRING:
                case Asn1Tag.NUMERIC_STRING:
                case Asn1Tag.UTC_TIME:
                case Asn1Tag.UTF8_STRING:
                case Asn1Tag.BMPSTRING:
				case Asn1Tag.GENERAL_STRING:
                case Asn1Tag.GENERALIZED_TIME:
                    if ((mask & TagTextMask.SHOW_OFFSET) != 0)
                    {
                        nodeStr += offsetStr;
                    }
                    nodeStr += " " + TagName;
                    if ((mask & TagTextMask.SHOW_DATA) != 0)
                    {
						if ( tag == Asn1Tag.UTF8_STRING )
						{
							UTF8Encoding unicode = new UTF8Encoding();
							dataStr = unicode.GetString(data);
						} 
						else 
						{
							dataStr = Asn1Util.BytesToString(data);
						}
						nodeStr += ((dataStr.Length>0) ? " : '" + dataStr + "'" : "");
                    }
                    break;
                case Asn1Tag.INTEGER:
                    if ((mask & TagTextMask.SHOW_OFFSET) != 0)
                    {
                        nodeStr += offsetStr;
                    }
                    nodeStr += " " + TagName;
                    if ((mask & TagTextMask.SHOW_DATA) != 0)
                    {
                        if (data != null && dataLength < 8)
                        {
                            dataStr = Asn1Util.BytesToLong(data).ToString();
                        }
                        else
                        {
                            dataStr = Asn1Util.ToHexString(data);
                        }
                        nodeStr += ((dataStr.Length>0) ? " : '" + dataStr + "'" : "");
                    }
                    break;
                default:
                    if ((mask & TagTextMask.SHOW_OFFSET) != 0)
                    {
                        nodeStr += offsetStr;
                    }
                    nodeStr += " " + TagName;
                    if ((mask & TagTextMask.SHOW_DATA) != 0)
                    {
                        if ((tag & Asn1Tag.TAG_MASK) == 6) // Visible string for certificate
                        {
                            dataStr = Asn1Util.BytesToString(data);
                        }
                        else
                        {
                            dataStr = Asn1Util.ToHexString(data);
                        }
                        nodeStr += ((dataStr.Length>0) ? " : '" + dataStr + "'" : "");
                    }
                    break;
            };
            if ((mask & TagTextMask.SHOW_PATH) != 0)
            {
                nodeStr = "(" + path + ") " + nodeStr;
            }
            return nodeStr;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieve the node description.
        /// </summary>
        /// <param name="pureHexMode">true:Return hex string only;
        /// false:Convert to more readable string depending on the node tag.</param>
        /// <returns>string</returns>
        public string GetDataStr(bool pureHexMode)
        {
            const int lineLen = 32;
            string dataStr = "";
            if (pureHexMode)
            {
                dataStr = Asn1Util.FormatString(Asn1Util.ToHexString(data), lineLen, 2);
            }
            else
            {
                switch (tag)
                {
                    case Asn1Tag.BIT_STRING:
                        dataStr = Asn1Util.FormatString(Asn1Util.ToHexString(data), lineLen, 2);
                        break;
                    case Asn1Tag.OBJECT_IDENTIFIER:
                        Oid xoid = new Oid();
                        dataStr = xoid.Decode(new MemoryStream(data));
                        break;
                    case Asn1Tag.RELATIVE_OID:
                        RelativeOid roid = new RelativeOid();
                        dataStr = roid.Decode(new MemoryStream(data));
                        break;
                    case Asn1Tag.PRINTABLE_STRING:
                    case Asn1Tag.IA5_STRING:
                    case Asn1Tag.UNIVERSAL_STRING:
                    case Asn1Tag.VISIBLE_STRING:
                    case Asn1Tag.NUMERIC_STRING:
                    case Asn1Tag.UTC_TIME:
                    case Asn1Tag.BMPSTRING:
					case Asn1Tag.GENERAL_STRING:
                    case Asn1Tag.GENERALIZED_TIME:
                        dataStr = Asn1Util.BytesToString(data);
                        break;
					case Asn1Tag.UTF8_STRING:
						UTF8Encoding utf8 = new UTF8Encoding();
						dataStr = utf8.GetString(data);
						break;
					case Asn1Tag.INTEGER:
                        dataStr = Asn1Util.FormatString(Asn1Util.ToHexString(data), lineLen, 2);
                        break;
                    default:
                        if ((tag & Asn1Tag.TAG_MASK) == 6) // Visible string for certificate
                        {
                            dataStr = Asn1Util.BytesToString(data);
                        }
                        else
                        {
                            dataStr = Asn1Util.FormatString(Asn1Util.ToHexString(data), lineLen, 2);
                        }
                        break;
                };
            }
            return dataStr;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get the node and all the descendents text description.
        /// </summary>
        /// <param name="startNode">starting node.</param>
        /// <param name="lineLen">line length.</param>
        /// <returns></returns>
        public string GetText(Asn1Node startNode, int lineLen)
        {
            string nodeStr = "";
            string baseLine = "";
            string dataStr = "";
            const string lStr = "      |      |       | ";
            string oid, oidName;
            switch (tag)
            {
                case Asn1Tag.BIT_STRING:
                    baseLine = 
                        String.Format("{0,6}|{1,6}|{2,7}|{3} {4} UnusedBits:{5} : ", 
                        dataOffset, 
                        dataLength, 
                        lengthFieldBytes, 
                        GetIndentStr(startNode), 
                        TagName, 
                        unusedBits
                        ); 
                    dataStr = Asn1Util.ToHexString(data);
                    if (baseLine.Length + dataStr.Length < lineLen)
                    {
                        if (dataStr.Length<1)
                        {
                            nodeStr += baseLine + "\r\n";
                        }
                        else
                        {
                            nodeStr += baseLine + "'" + dataStr + "'\r\n";
                        }
                    }
                    else
                    {
                        nodeStr += baseLine + FormatLineHexString(
                            lStr, 
                            GetIndentStr(startNode).Length, 
                            lineLen, 
                            dataStr + "\r\n"
                            );
                    }
                    break;
                case Asn1Tag.OBJECT_IDENTIFIER:
                    Oid xoid  = new Oid();
                    oid = xoid.Decode(new MemoryStream(data));
                    oidName = xoid.GetOidName(oid);
                    nodeStr += String.Format("{0,6}|{1,6}|{2,7}|{3} {4} : {5} [{6}]\r\n", 
                        dataOffset,
                        dataLength, 
                        lengthFieldBytes, 
                        GetIndentStr(startNode), 
                        TagName, 
                        oidName,
                        oid
                        ); 
                    break;
                case Asn1Tag.RELATIVE_OID:
                    RelativeOid xiod = new RelativeOid();
                    oid = xiod.Decode(new MemoryStream(data));
                    oidName = "";
                    nodeStr += String.Format("{0,6}|{1,6}|{2,7}|{3} {4} : {5} [{6}]\r\n", 
                        dataOffset,
                        dataLength, 
                        lengthFieldBytes, 
                        GetIndentStr(startNode), 
                        TagName, 
                        oidName,
                        oid
                        ); 
                    break;
                case Asn1Tag.PRINTABLE_STRING:
                case Asn1Tag.IA5_STRING:
                case Asn1Tag.UNIVERSAL_STRING:
                case Asn1Tag.VISIBLE_STRING:
                case Asn1Tag.NUMERIC_STRING:
                case Asn1Tag.UTC_TIME:
                case Asn1Tag.UTF8_STRING:
                case Asn1Tag.BMPSTRING:
				case Asn1Tag.GENERAL_STRING:
                case Asn1Tag.GENERALIZED_TIME:
                    baseLine = 
                        String.Format("{0,6}|{1,6}|{2,7}|{3} {4} : ", 
                        dataOffset,
                        dataLength, 
                        lengthFieldBytes, 
                        GetIndentStr(startNode), 
                        TagName
                        );
					if ( tag == Asn1Tag.UTF8_STRING )
					{
						UTF8Encoding unicode = new UTF8Encoding();
						dataStr = unicode.GetString(data);
					} 
					else 
					{
						dataStr = Asn1Util.BytesToString(data);
					}
                    if (baseLine.Length + dataStr.Length < lineLen)
                    {
                        nodeStr += baseLine + "'" + dataStr + "'\r\n";
                    }
                    else
                    {
                        nodeStr += baseLine + FormatLineString(
                            lStr, 
                            GetIndentStr(startNode).Length, 
                            lineLen, 
                            dataStr) + "\r\n";
                    }
                    break;
                case Asn1Tag.INTEGER:
                    if (data != null && dataLength < 8)
                    {
                        nodeStr += String.Format("{0,6}|{1,6}|{2,7}|{3} {4} : {5}\r\n", 
                            dataOffset,
                            dataLength, 
                            lengthFieldBytes, 
                            GetIndentStr(startNode), 
                            TagName,
                            Asn1Util.BytesToLong(data).ToString()
                            );
                    }
                    else
                    {
                        baseLine = 
                            String.Format("{0,6}|{1,6}|{2,7}|{3} {4} : ", 
                            dataOffset,
                            dataLength, 
                            lengthFieldBytes, 
                            GetIndentStr(startNode), 
                            TagName
                            );
                        nodeStr += GetHexPrintingStr(startNode, baseLine, lStr, lineLen);
                    }
                    break;
                default:
                    if ((tag & Asn1Tag.TAG_MASK) == 6) // Visible string for certificate
                    {
                        baseLine = 
                            String.Format("{0,6}|{1,6}|{2,7}|{3} {4} : ", 
                            dataOffset,
                            dataLength, 
                            lengthFieldBytes, 
                            GetIndentStr(startNode), 
                            TagName
                            );
                        dataStr = Asn1Util.BytesToString(data);
                        if (baseLine.Length + dataStr.Length < lineLen)
                        {
                            nodeStr += baseLine + "'" + dataStr + "'\r\n";
                        }
                        else
                        {
                            nodeStr += baseLine + FormatLineString(
                                lStr, 
                                GetIndentStr(startNode).Length, 
                                lineLen, 
                                dataStr) + "\r\n";
                        }
                    }
                    else
                    {
                        baseLine = 
                            String.Format("{0,6}|{1,6}|{2,7}|{3} {4} : ", 
                            dataOffset,
                            dataLength, 
                            lengthFieldBytes, 
                            GetIndentStr(startNode), 
                            TagName
                            );
                        nodeStr += GetHexPrintingStr(startNode, baseLine, lStr, lineLen);
                    }
                    break;
            };
            if (childNodeList.Count >= 0)
            {
                nodeStr += GetListStr(startNode, lineLen);
            }
            return nodeStr;
        }
Exemplo n.º 5
0
		/// <summary>
		/// Get node by OID.
		/// </summary>
		/// <param name="oid">OID.</param>
		/// <param name="startNode">Starting node.</param>
		/// <returns>Null or Asn1Node.</returns>
		static public Asn1Node GetDecendantNodeByOid(string oid, Asn1Node startNode)
		{
			Asn1Node retval = null;
            Oid xoid = new Oid();
			for (int i = 0; i<startNode.ChildNodeCount; i++)
			{
				Asn1Node childNode = startNode.GetChildNode(i);
				int tmpTag = childNode.tag & Asn1Tag.TAG_MASK;
				if (tmpTag == Asn1Tag.OBJECT_IDENTIFIER)
				{
					if (oid == xoid.Decode(childNode.Data))
					{
						retval = childNode;
						break;
					}
				}
				retval = GetDecendantNodeByOid(oid, childNode);
				if (retval != null) break;
			}
			return retval;
		}
        public DistinguishedName(Asn1Node n)
        {
            /* Name:
             * SET
             *   SEQ (attr)
             *     Object Identifier
             *     Printable String || UTF8String
             */
            if (n.MaskedTag == Asn1Tag.SEQUENCE)
            {
                for (int i = 0; i < n.ChildNodeCount; i++)
                {
                    Asn1Node tt = n.GetChildNode(i);
                    if (tt.MaskedTag != Asn1Tag.SET || tt.ChildNodeCount != 1)
                    {
                        throw new InvalidX509Data();
                    }

                    tt = tt.GetChildNode(0);
                    if (tt.MaskedTag != Asn1Tag.SEQUENCE || tt.ChildNodeCount != 2)
                    {
                        throw new InvalidX509Data();
                    }

                    Asn1Node oi  = tt.GetChildNode(0);
                    Asn1Node txt = tt.GetChildNode(1);

                    if (oi.MaskedTag != Asn1Tag.OBJECT_IDENTIFIER ||
                        !(
                            (txt.MaskedTag == Asn1Tag.PRINTABLE_STRING) ||
                            (txt.MaskedTag == Asn1Tag.UTF8_STRING) ||
                            (txt.MaskedTag == Asn1Tag.IA5_STRING)))
                    {
                        throw new InvalidX509Data();
                    }
                    var    xoid   = new LipingShare.LCLib.Asn1Processor.Oid();
                    string oiName = xoid.Decode(oi.Data);
                    var    enc    = new System.Text.UTF8Encoding();

                    switch (oiName)
                    {
                    case "2.5.4.6":                     // countryName
                        Country = enc.GetString(txt.Data);
                        break;

                    case "2.5.4.10":                     // organizationName
                        Organization = enc.GetString(txt.Data);
                        break;

                    case "2.5.4.11":                     // organizationalUnit
                        OrganizationalUnit = enc.GetString(txt.Data);
                        break;

                    case "2.5.4.3":                     // commonName
                        CommonName = enc.GetString(txt.Data);
                        break;

                    case "2.5.4.5":                     // serial number
                        SerialNumber = Asn1Util.ToHexString(txt.Data);
                        break;

                    case "2.5.4.46":                     // dnq
                        Dnq = enc.GetString(txt.Data);
                        break;

                    case "2.5.4.8":                     // state
                        State = enc.GetString(txt.Data);
                        break;
                    }
                }
            }
        }
Exemplo n.º 7
0
        public string GetLabel(uint mask)
        {
            string str1 = "";
            string str2 = ((int)mask & 4) == 0 ? (((int)mask & 8) == 0 ? string.Format("({0},{1})", (object)this.dataOffset, (object)this.dataLength) : string.Format("({0},{1},{2})", (object)this.tag, (object)this.dataOffset, (object)this.dataLength)) : (((int)mask & 8) == 0 ? string.Format("(0x{0:X6},0x{1:X4})", (object)this.dataOffset, (object)this.dataLength) : string.Format("(0x{0:X2},0x{1:X6},0x{2:X4})", (object)this.tag, (object)this.dataOffset, (object)this.dataLength));
            string str3;

            switch (this.tag)
            {
            case 2:
                if (((int)mask & 1) != 0)
                {
                    str1 += str2;
                }
                str3 = str1 + " " + this.TagName;
                if (((int)mask & 2) != 0)
                {
                    string str4 = this.data == null || this.dataLength >= 8L ? Asn1Util.ToHexString(this.data) : Asn1Util.BytesToLong(this.data).ToString();
                    str3 += str4.Length > 0 ? " : '" + str4 + "'" : "";
                    break;
                }
                break;

            case 3:
                if (((int)mask & 1) != 0)
                {
                    str1 += str2;
                }
                str3 = str1 + " " + this.TagName + " UnusedBits: " + this.unusedBits.ToString();
                if (((int)mask & 2) != 0)
                {
                    string hexString = Asn1Util.ToHexString(this.data);
                    str3 += hexString.Length > 0 ? " : '" + hexString + "'" : "";
                    break;
                }
                break;

            case 6:
                Oid    oid      = new Oid();
                string inOidStr = oid.Decode(this.data);
                string oidName  = oid.GetOidName(inOidStr);
                if (((int)mask & 1) != 0)
                {
                    str1 += str2;
                }
                str3 = str1 + " " + this.TagName + " : " + oidName;
                if (((int)mask & 2) != 0)
                {
                    str3 += inOidStr.Length > 0 ? " : '" + inOidStr + "'" : "";
                    break;
                }
                break;

            case 12:
            case 18:
            case 19:
            case 22:
            case 23:
            case 24:
            case 26:
            case 27:
            case 28:
            case 30:
                if (((int)mask & 1) != 0)
                {
                    str1 += str2;
                }
                str3 = str1 + " " + this.TagName;
                if (((int)mask & 2) != 0)
                {
                    string str4 = this.tag != (byte)12 ? Asn1Util.BytesToString(this.data) : new UTF8Encoding().GetString(this.data);
                    str3 += str4.Length > 0 ? " : '" + str4 + "'" : "";
                    break;
                }
                break;

            case 13:
                string str5 = new RelativeOid().Decode(this.data);
                string str6 = "";
                if (((int)mask & 1) != 0)
                {
                    str1 += str2;
                }
                str3 = str1 + " " + this.TagName + " : " + str6;
                if (((int)mask & 2) != 0)
                {
                    str3 += str5.Length > 0 ? " : '" + str5 + "'" : "";
                    break;
                }
                break;

            default:
                if (((int)mask & 1) != 0)
                {
                    str1 += str2;
                }
                str3 = str1 + " " + this.TagName;
                if (((int)mask & 2) != 0)
                {
                    string str4 = ((int)this.tag & 31) == 6 || Asn1Util.IsAsciiString(this.Data) ? Asn1Util.BytesToString(this.data) : Asn1Util.ToHexString(this.data);
                    str3 += str4.Length > 0 ? " : '" + str4 + "'" : "";
                    break;
                }
                break;
            }
            if (((int)mask & 16) != 0)
            {
                str3 = "(" + this.path + ") " + str3;
            }
            return(str3);
        }
Exemplo n.º 8
0
        public string GetText(Asn1Node startNode, int lineLen)
        {
            string str1 = "";
            string str2;

            switch (this.tag)
            {
            case 2:
                if (this.data != null && this.dataLength < 8L)
                {
                    str2 = str1 + string.Format("{0,6}|{1,6}|{2,7}|{3} {4} : {5}\r\n", (object)this.dataOffset, (object)this.dataLength, (object)this.lengthFieldBytes, (object)this.GetIndentStr(startNode), (object)this.TagName, (object)Asn1Util.BytesToLong(this.data).ToString());
                    break;
                }
                string baseLine1 = string.Format("{0,6}|{1,6}|{2,7}|{3} {4} : ", (object)this.dataOffset, (object)this.dataLength, (object)this.lengthFieldBytes, (object)this.GetIndentStr(startNode), (object)this.TagName);
                str2 = str1 + this.GetHexPrintingStr(startNode, baseLine1, "      |      |       | ", lineLen);
                break;

            case 3:
                string str3      = string.Format("{0,6}|{1,6}|{2,7}|{3} {4} UnusedBits:{5} : ", (object)this.dataOffset, (object)this.dataLength, (object)this.lengthFieldBytes, (object)this.GetIndentStr(startNode), (object)this.TagName, (object)this.unusedBits);
                string hexString = Asn1Util.ToHexString(this.data);
                if (str3.Length + hexString.Length < lineLen)
                {
                    if (hexString.Length < 1)
                    {
                        str2 = str1 + str3 + "\r\n";
                        break;
                    }
                    str2 = str1 + str3 + "'" + hexString + "'\r\n";
                    break;
                }
                str2 = str1 + str3 + this.FormatLineHexString("      |      |       | ", this.GetIndentStr(startNode).Length, lineLen, hexString + "\r\n");
                break;

            case 6:
                Oid    oid      = new Oid();
                string inOidStr = oid.Decode((Stream) new MemoryStream(this.data));
                string oidName  = oid.GetOidName(inOidStr);
                str2 = str1 + string.Format("{0,6}|{1,6}|{2,7}|{3} {4} : {5} [{6}]\r\n", (object)this.dataOffset, (object)this.dataLength, (object)this.lengthFieldBytes, (object)this.GetIndentStr(startNode), (object)this.TagName, (object)oidName, (object)inOidStr);
                break;

            case 12:
            case 18:
            case 19:
            case 22:
            case 23:
            case 24:
            case 26:
            case 27:
            case 28:
            case 30:
                string str4 = string.Format("{0,6}|{1,6}|{2,7}|{3} {4} : ", (object)this.dataOffset, (object)this.dataLength, (object)this.lengthFieldBytes, (object)this.GetIndentStr(startNode), (object)this.TagName);
                string msg1 = this.tag != (byte)12 ? Asn1Util.BytesToString(this.data) : new UTF8Encoding().GetString(this.data);
                if (str4.Length + msg1.Length < lineLen)
                {
                    str2 = str1 + str4 + "'" + msg1 + "'\r\n";
                    break;
                }
                str2 = str1 + str4 + this.FormatLineString("      |      |       | ", this.GetIndentStr(startNode).Length, lineLen, msg1) + "\r\n";
                break;

            case 13:
                string str5 = new RelativeOid().Decode((Stream) new MemoryStream(this.data));
                string str6 = "";
                str2 = str1 + string.Format("{0,6}|{1,6}|{2,7}|{3} {4} : {5} [{6}]\r\n", (object)this.dataOffset, (object)this.dataLength, (object)this.lengthFieldBytes, (object)this.GetIndentStr(startNode), (object)this.TagName, (object)str6, (object)str5);
                break;

            default:
                if (((int)this.tag & 31) == 6 || Asn1Util.IsAsciiString(this.Data))
                {
                    string str7 = string.Format("{0,6}|{1,6}|{2,7}|{3} {4} : ", (object)this.dataOffset, (object)this.dataLength, (object)this.lengthFieldBytes, (object)this.GetIndentStr(startNode), (object)this.TagName);
                    string msg2 = Asn1Util.BytesToString(this.data);
                    if (str7.Length + msg2.Length < lineLen)
                    {
                        str2 = str1 + str7 + "'" + msg2 + "'\r\n";
                        break;
                    }
                    str2 = str1 + str7 + this.FormatLineString("      |      |       | ", this.GetIndentStr(startNode).Length, lineLen, msg2) + "\r\n";
                    break;
                }
                string baseLine2 = string.Format("{0,6}|{1,6}|{2,7}|{3} {4} : ", (object)this.dataOffset, (object)this.dataLength, (object)this.lengthFieldBytes, (object)this.GetIndentStr(startNode), (object)this.TagName);
                str2 = str1 + this.GetHexPrintingStr(startNode, baseLine2, "      |      |       | ", lineLen);
                break;
            }
            if (this.childNodeList.Count >= 0)
            {
                str2 += this.GetListStr(startNode, lineLen);
            }
            return(str2);
        }