Example #1
0
        public string GetDataStr(bool pureHexMode)
        {
            string str;

            if (pureHexMode)
            {
                str = Asn1Util.FormatString(Asn1Util.ToHexString(this.data), 32, 2);
            }
            else
            {
                switch (this.tag)
                {
                case 2:
                    str = Asn1Util.FormatString(Asn1Util.ToHexString(this.data), 32, 2);
                    break;

                case 3:
                    str = Asn1Util.FormatString(Asn1Util.ToHexString(this.data), 32, 2);
                    break;

                case 6:
                    str = new Oid().Decode((Stream) new MemoryStream(this.data));
                    break;

                case 12:
                    str = new UTF8Encoding().GetString(this.data);
                    break;

                case 13:
                    str = new RelativeOid().Decode((Stream) new MemoryStream(this.data));
                    break;

                case 18:
                case 19:
                case 22:
                case 23:
                case 24:
                case 26:
                case 27:
                case 28:
                case 30:
                    str = Asn1Util.BytesToString(this.data);
                    break;

                default:
                    str = ((int)this.tag & 31) == 6 || Asn1Util.IsAsciiString(this.Data) ? Asn1Util.BytesToString(this.data) : Asn1Util.FormatString(Asn1Util.ToHexString(this.data), 32, 2);
                    break;
                }
            }
            return(str);
        }
Example #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;
        }
Example #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;
        }
Example #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;
        }
 public static bool IsRoidStr(string inStr)
 {
     bool retval = false;
     MemoryStream ms = new MemoryStream();
     RelativeOid roid = new RelativeOid();
     roid.Encode(ms, inStr);
     ms.Close();
     retval = true;
     return retval;
 }
 public static bool EditNode(IWin32Window parent, Asn1Node aNode, bool enableTagEdit, bool pureHexMode)
 {
     byte[] val;
     byte[] data;
     FormNodeContentEditor ed = new FormNodeContentEditor();
     ed.aNode = aNode;
     MemoryStream ms = new MemoryStream();
     ed.checker = FormNodeContentEditor.DataChecker.None;
     ed.enableTagEdit = enableTagEdit;
     ed.pureHexMode = pureHexMode;
     if (
         ((aNode.Tag&Asn1Tag.TAG_MASK) == Asn1Tag.BIT_STRING) &&
         (aNode.ChildNodeCount<1))
     {
         ed.panelUnusedBits.Visible = true;
         ed.textBoxUnusedBits.Text = aNode.UnusedBits.ToString();
     }
     else
     {
         ed.panelUnusedBits.Visible = false;
     }
     if (pureHexMode)
     {
         ed.checker = DataChecker.Hex;
         ed.ShowDialog(parent);
         if (!ed.isOK) return false;
         data = Asn1Util.HexStrToBytes(ed.GetValueStr());
         aNode.Data = data;
     }
     else
     {
         byte[] oidVal;
         switch (aNode.Tag)
         {
             case Asn1Tag.OBJECT_IDENTIFIER:
                 ed.checker = DataChecker.Oid;
                 ed.ShowDialog(parent);
                 if (!ed.isOK) return false;
                 Oid xoid = new Oid();
                 xoid.Encode(ms, ed.GetValueStr());
                 ms.Position = 0;
                 oidVal = new byte[ms.Length];
                 ms.Read(oidVal, 0, (int)ms.Length);
                 ms.Close();
                 aNode.Data = oidVal;
                 break;
             case Asn1Tag.RELATIVE_OID:
                 ed.checker = DataChecker.Roid;
                 ed.ShowDialog(parent);
                 if (!ed.isOK) return false;
                 RelativeOid roid = new RelativeOid();
                 roid.Encode(ms, ed.GetValueStr());
                 ms.Position = 0;
                 oidVal = new byte[ms.Length];
                 ms.Read(oidVal, 0, (int)ms.Length);
                 ms.Close();
                 aNode.Data = oidVal;
                 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.GENERAL_STRING:
             case Asn1Tag.GENERALIZED_TIME:
                 ed.ShowDialog(parent);
                 if (!ed.isOK) return false;
                 val = Asn1Util.StringToBytes(ed.GetValueStr());
                 aNode.Data = val;
                 break;
             case Asn1Tag.UTF8_STRING:
                 ed.ShowDialog(parent);
                 if (!ed.isOK) return false;
                 UTF8Encoding u8 = new UTF8Encoding(false);
                 val = u8.GetBytes(ed.GetValueStr());
                 aNode.Data = val;
                 break;
             case Asn1Tag.BMPSTRING:
                 ed.ShowDialog(parent);
                 if (!ed.isOK) return false;
                 byte[] tmpval = Asn1Util.StringToBytes(ed.GetValueStr());
                 val = new byte[tmpval.Length*2];
                 for (int i = 0; i<tmpval.Length; i++)
                 {
                     val[i*2] = 0;
                     val[i*2+1] = tmpval[i];
                 }
                 aNode.Data = val;
                 break;
             case Asn1Tag.INTEGER:
             case Asn1Tag.BIT_STRING:
                 ed.checker = DataChecker.Hex;
                 ed.ShowDialog(parent);
                 if (!ed.isOK) return false;
                 aNode.UnusedBits = (byte)(Convert.ToUInt16(ed.textBoxUnusedBits.Text)%8);
                 data = Asn1Util.HexStrToBytes(ed.GetValueStr());
                 aNode.Data = data;
                 break;
             default:
                 if ((aNode.Tag & Asn1Tag.TAG_MASK) == 6) // Visible string for certificate
                 {
                     ed.ShowDialog(parent);
                     if (!ed.isOK) return false;
                     val = Asn1Util.StringToBytes(ed.GetValueStr());
                     aNode.Data = val;
                 }
                 else
                 {
                     ed.checker = DataChecker.Hex;
                     ed.ShowDialog(parent);
                     if (!ed.isOK) return false;
                     data = Asn1Util.HexStrToBytes(ed.GetValueStr());
                     aNode.Data = data;
                 }
                 break;
         };
     }
     return true;
 }
Example #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);
        }
Example #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);
        }