// 0x0B EMBEDDED PDV (PRESENTATION DATA VALUE) private void PrintEmbeddedPDV(StringBuilder sb, int level, ASN1Element asn) { PrintToDo("EMBEDDED PDV", sb, level, asn); }
// 0x0C UTF8 STRING private void PrintUtf8String(StringBuilder sb, int level, ASN1Element asn) { sb.Append("UTF8String"); PrintString(sb, level, Encoding.UTF8.GetString(asn.Value)); }
// 0x09 REAL private void PrintReal(StringBuilder sb, int level, ASN1Element asn) { PrintToDo("REAL", sb, level, asn); }
// 0x0A ENUMERATED private void PrintEnumerated(StringBuilder sb, int level, ASN1Element asn) { PrintToDo("ENUMERATED", sb, level, asn); }
// 0x1A VISIBLE STRING private void PrintVisibleString(StringBuilder sb, int level, ASN1Element asn) { sb.Append("VisibleString"); // ASCII subset PrintString(sb, level, Encoding.ASCII.GetString(asn.Value)); }
// 0x08 EXTERNAL private void PrintExternal(StringBuilder sb, int level, ASN1Element asn) { PrintToDo("EXTERNAL", sb, level, asn); }
// 0x01 BOOLEAN private void PrintBoolean(StringBuilder sb, int level, ASN1Element asn) { byte[] value = asn.Value; sb.AppendFormat("BOOLEAN {0}", (value [0] == 1) ? "FALSE" : "TRUE"); }
// 0x15 VIDEOTEX STRING private void PrintVideotexString(StringBuilder sb, int level, ASN1Element asn) { sb.Append("VideotexString"); PrintString(sb, level, Encoding.ASCII.GetString(asn.Value)); }
private void GetTagName(StringBuilder sb, int level, ASN1Element asn) { switch (asn.Tag) { case 0x01: PrintBoolean(sb, level, asn); break; case 0x02: PrintInteger(sb, level, asn); break; case 0x03: PrintBitString(sb, level, asn); break; case 0x04: PrintOctetString(sb, level, asn); break; case 0x05: PrintNull(sb, level, asn); break; case 0x06: PrintOID(sb, level, asn); break; case 0x07: PrintObjectDescriptor(sb, level, asn); break; case 0x08: PrintExternal(sb, level, asn); break; case 0x09: PrintReal(sb, level, asn); break; case 0x0A: PrintEnumerated(sb, level, asn); break; case 0x0B: PrintEmbeddedPDV(sb, level, asn); break; case 0x0C: PrintUtf8String(sb, level, asn); break; case 0x0D: PrintRelativeOid(sb, level, asn); break; // 0x0E RFU // 0x0F RFU case 0x10: sb.Append("SEQUENCE"); // non-constructed version break; case 0x11: sb.Append("SET"); // non-constructed version break; case 0x12: PrintNumericString(sb, level, asn); break; case 0x13: PrintPrintableString(sb, level, asn); break; case 0x14: PrintT61String(sb, level, asn); break; case 0x15: PrintVideotexString(sb, level, asn); break; case 0x16: PrintIA5String(sb, level, asn); break; case 0x17: PrintUtcTime(sb, level, asn); break; case 0x18: PrintGeneralizedTime(sb, level, asn); break; case 0x19: PrintGraphicString(sb, level, asn); break; case 0x1A: PrintVisibleString(sb, level, asn); break; case 0x1B: PrintGeneralString(sb, level, asn); break; case 0x1C: PrintUniversalString(sb, level, asn); break; case 0x1D: PrintCharacterString(sb, level, asn); break; case 0x1E: PrintBMPString(sb, level, asn); break; case 0x30: sb.Append("SEQUENCE {"); break; case 0x31: sb.Append("SET {"); break; default: PrintOtherData(sb, level, asn); break; } }
private void PrintToDo(string s, StringBuilder sb, int level, ASN1Element asn) { sb.AppendFormat("{0} (TODO)", s); byte[] value = asn.Value; PrintData(sb, level, value, 0, value.Length); }
public PrettyPrinter(ASN1Element asn) { _asn = asn; _options.Copy(_defaults); }
// 0x1E BMP STRING private void PrintBMPString(StringBuilder sb, int level, ASN1Element asn) { sb.Append("BMPString"); // Unicode PrintString(sb, level, Encoding.BigEndianUnicode.GetString(asn.Value)); }
// 0x1D CHARACTER STRING private void PrintCharacterString(StringBuilder sb, int level, ASN1Element asn) { PrintToDo("CHARACTER STRING", sb, level, asn); }
// 0x0D RELATIVE-OID private void PrintRelativeOid(StringBuilder sb, int level, ASN1Element asn) { PrintToDo("RELATIVE-OID", sb, level, asn); }
// 0x05 NULL private void PrintNull(StringBuilder sb, int level, ASN1Element asn) { // FIXME: report errors if length != 0 (in ASNElement ?) sb.Append("NULL"); }
// 0x12 NUMERIC STRING private void PrintNumericString(StringBuilder sb, int level, ASN1Element asn) { sb.Append("NumericString"); // FIXME: should contain only ' ' and '0' to '9' PrintString(sb, level, Encoding.ASCII.GetString(asn.Value)); }
// 0x07 OBJECT DESCRIPTOR private void PrintObjectDescriptor(StringBuilder sb, int level, ASN1Element asn) { sb.Append("ObjectDescriptor"); PrintString(sb, level, Encoding.ASCII.GetString(asn.Value)); }
// 0x16 IA5 STRING private void PrintIA5String(StringBuilder sb, int level, ASN1Element asn) { sb.Append("IA5String"); // ASCII PrintString(sb, level, Encoding.ASCII.GetString(asn.Value)); }
// 0x18 GENERALIZED TIME private void PrintGeneralizedTime(StringBuilder sb, int level, ASN1Element asn) { sb.AppendFormat("GeneralizedTime '{0}'", Encoding.ASCII.GetString(asn.Value)); // TODO: option to show as local time ? }