1*2175Sjp161948=pod
2*2175Sjp161948
3*2175Sjp161948=head1 NAME
4*2175Sjp161948
5*2175Sjp161948ASN1_STRING_print_ex, ASN1_STRING_print_ex_fp - ASN1_STRING output routines.
6*2175Sjp161948
7*2175Sjp161948=head1 SYNOPSIS
8*2175Sjp161948
9*2175Sjp161948 #include <openssl/asn1.h>
10*2175Sjp161948
11*2175Sjp161948 int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
12*2175Sjp161948 int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
13*2175Sjp161948 int ASN1_STRING_print(BIO *out, ASN1_STRING *str);
14*2175Sjp161948
15*2175Sjp161948
16*2175Sjp161948=head1 DESCRIPTION
17*2175Sjp161948
18*2175Sjp161948These functions output an B<ASN1_STRING> structure. B<ASN1_STRING> is used to
19*2175Sjp161948represent all the ASN1 string types.
20*2175Sjp161948
21*2175Sjp161948ASN1_STRING_print_ex() outputs B<str> to B<out>, the format is determined by
22*2175Sjp161948the options B<flags>. ASN1_STRING_print_ex_fp() is identical except it outputs
23*2175Sjp161948to B<fp> instead.
24*2175Sjp161948
25*2175Sjp161948ASN1_STRING_print() prints B<str> to B<out> but using a different format to
26*2175Sjp161948ASN1_STRING_print_ex(). It replaces unprintable characters (other than CR, LF)
27*2175Sjp161948with '.'.
28*2175Sjp161948
29*2175Sjp161948=head1 NOTES
30*2175Sjp161948
31*2175Sjp161948ASN1_STRING_print() is a legacy function which should be avoided in new applications.
32*2175Sjp161948
33*2175Sjp161948Although there are a large number of options frequently B<ASN1_STRFLGS_RFC2253> is
34*2175Sjp161948suitable, or on UTF8 terminals B<ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB>.
35*2175Sjp161948
36*2175Sjp161948The complete set of supported options for B<flags> is listed below.
37*2175Sjp161948
38*2175Sjp161948Various characters can be escaped. If B<ASN1_STRFLGS_ESC_2253> is set the characters
39*2175Sjp161948determined by RFC2253 are escaped. If B<ASN1_STRFLGS_ESC_CTRL> is set control
40*2175Sjp161948characters are escaped. If B<ASN1_STRFLGS_ESC_MSB> is set characters with the
41*2175Sjp161948MSB set are escaped: this option should B<not> be used if the terminal correctly
42*2175Sjp161948interprets UTF8 sequences.
43*2175Sjp161948
44*2175Sjp161948Escaping takes several forms.
45*2175Sjp161948
46*2175Sjp161948If the character being escaped is a 16 bit character then the form "\WXXXX" is used
47*2175Sjp161948using exactly four characters for the hex representation. If it is 32 bits then
48*2175Sjp161948"\UXXXXXXXX" is used using eight characters of its hex representation. These forms
49*2175Sjp161948will only be used if UTF8 conversion is not set (see below).
50*2175Sjp161948
51*2175Sjp161948Printable characters are normally escaped using the backslash '\' character. If
52*2175Sjp161948B<ASN1_STRFLGS_ESC_QUOTE> is set then the whole string is instead surrounded by
53*2175Sjp161948double quote characters: this is arguably more readable than the backslash
54*2175Sjp161948notation. Other characters use the "\XX" using exactly two characters of the hex
55*2175Sjp161948representation.
56*2175Sjp161948
57*2175Sjp161948If B<ASN1_STRFLGS_UTF8_CONVERT> is set then characters are converted to UTF8
58*2175Sjp161948format first. If the terminal supports the display of UTF8 sequences then this
59*2175Sjp161948option will correctly display multi byte characters.
60*2175Sjp161948
61*2175Sjp161948If B<ASN1_STRFLGS_IGNORE_TYPE> is set then the string type is not interpreted at
62*2175Sjp161948all: everything is assumed to be one byte per character. This is primarily for
63*2175Sjp161948debugging purposes and can result in confusing output in multi character strings.
64*2175Sjp161948
65*2175Sjp161948If B<ASN1_STRFLGS_SHOW_TYPE> is set then the string type itself is printed out
66*2175Sjp161948before its value (for example "BMPSTRING"), this actually uses ASN1_tag2str().
67*2175Sjp161948
68*2175Sjp161948The content of a string instead of being interpreted can be "dumped": this just
69*2175Sjp161948outputs the value of the string using the form #XXXX using hex format for each
70*2175Sjp161948octet.
71*2175Sjp161948
72*2175Sjp161948If B<ASN1_STRFLGS_DUMP_ALL> is set then any type is dumped.
73*2175Sjp161948
74*2175Sjp161948Normally non character string types (such as OCTET STRING) are assumed to be
75*2175Sjp161948one byte per character, if B<ASN1_STRFLGS_DUMP_UNKNOWN> is set then they will
76*2175Sjp161948be dumped instead.
77*2175Sjp161948
78*2175Sjp161948When a type is dumped normally just the content octets are printed, if
79*2175Sjp161948B<ASN1_STRFLGS_DUMP_DER> is set then the complete encoding is dumped
80*2175Sjp161948instead (including tag and length octets).
81*2175Sjp161948
82*2175Sjp161948B<ASN1_STRFLGS_RFC2253> includes all the flags required by RFC2253. It is
83*2175Sjp161948equivalent to:
84*2175Sjp161948 ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB |
85*2175Sjp161948 ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN ASN1_STRFLGS_DUMP_DER
86*2175Sjp161948
87*2175Sjp161948=head1 SEE ALSO
88*2175Sjp161948
89*2175Sjp161948L<X509_NAME_print_ex(3)|X509_NAME_print_ex(3)>,
90*2175Sjp161948L<ASN1_tag2str(3)|ASN1_tag2str(3)>
91*2175Sjp161948
92*2175Sjp161948=head1 HISTORY
93*2175Sjp161948
94*2175Sjp161948TBA
95*2175Sjp161948
96*2175Sjp161948=cut
97