xref: /freebsd/crypto/openssl/doc/man3/ASN1_STRING_print_ex.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimASN1_tag2str, ASN1_STRING_print_ex, ASN1_STRING_print_ex_fp, ASN1_STRING_print
6e71b7053SJung-uk Kim- ASN1_STRING output routines
7e71b7053SJung-uk Kim
8e71b7053SJung-uk Kim=head1 SYNOPSIS
9e71b7053SJung-uk Kim
10e71b7053SJung-uk Kim #include <openssl/asn1.h>
11e71b7053SJung-uk Kim
12e71b7053SJung-uk Kim int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags);
13e71b7053SJung-uk Kim int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags);
14e71b7053SJung-uk Kim int ASN1_STRING_print(BIO *out, const ASN1_STRING *str);
15e71b7053SJung-uk Kim
16e71b7053SJung-uk Kim const char *ASN1_tag2str(int tag);
17e71b7053SJung-uk Kim
18e71b7053SJung-uk Kim=head1 DESCRIPTION
19e71b7053SJung-uk Kim
20e71b7053SJung-uk KimThese functions output an B<ASN1_STRING> structure. B<ASN1_STRING> is used to
21e71b7053SJung-uk Kimrepresent all the ASN1 string types.
22e71b7053SJung-uk Kim
23*b077aed3SPierre ProncheryASN1_STRING_print_ex() outputs I<str> to I<out>, the format is determined by
24*b077aed3SPierre Proncherythe options I<flags>. ASN1_STRING_print_ex_fp() is identical except it outputs
25*b077aed3SPierre Proncheryto I<fp> instead.
26e71b7053SJung-uk Kim
27*b077aed3SPierre ProncheryASN1_STRING_print() prints I<str> to I<out> but using a different format to
28e71b7053SJung-uk KimASN1_STRING_print_ex(). It replaces unprintable characters (other than CR, LF)
29e71b7053SJung-uk Kimwith '.'.
30e71b7053SJung-uk Kim
31*b077aed3SPierre ProncheryASN1_tag2str() returns a human-readable name of the specified ASN.1 I<tag>.
32e71b7053SJung-uk Kim
33e71b7053SJung-uk Kim=head1 NOTES
34e71b7053SJung-uk Kim
35e71b7053SJung-uk KimASN1_STRING_print() is a deprecated function which should be avoided; use
36e71b7053SJung-uk KimASN1_STRING_print_ex() instead.
37e71b7053SJung-uk Kim
38e71b7053SJung-uk KimAlthough there are a large number of options frequently B<ASN1_STRFLGS_RFC2253> is
39e71b7053SJung-uk Kimsuitable, or on UTF8 terminals B<ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB>.
40e71b7053SJung-uk Kim
41*b077aed3SPierre ProncheryThe complete set of supported options for I<flags> is listed below.
42e71b7053SJung-uk Kim
43e71b7053SJung-uk KimVarious characters can be escaped. If B<ASN1_STRFLGS_ESC_2253> is set the characters
44e71b7053SJung-uk Kimdetermined by RFC2253 are escaped. If B<ASN1_STRFLGS_ESC_CTRL> is set control
45e71b7053SJung-uk Kimcharacters are escaped. If B<ASN1_STRFLGS_ESC_MSB> is set characters with the
46e71b7053SJung-uk KimMSB set are escaped: this option should B<not> be used if the terminal correctly
47e71b7053SJung-uk Kiminterprets UTF8 sequences.
48e71b7053SJung-uk Kim
49e71b7053SJung-uk KimEscaping takes several forms.
50e71b7053SJung-uk Kim
51e71b7053SJung-uk KimIf the character being escaped is a 16 bit character then the form "\UXXXX" is used
52e71b7053SJung-uk Kimusing exactly four characters for the hex representation. If it is 32 bits then
53e71b7053SJung-uk Kim"\WXXXXXXXX" is used using eight characters of its hex representation. These forms
54e71b7053SJung-uk Kimwill only be used if UTF8 conversion is not set (see below).
55e71b7053SJung-uk Kim
56e71b7053SJung-uk KimPrintable characters are normally escaped using the backslash '\' character. If
57e71b7053SJung-uk KimB<ASN1_STRFLGS_ESC_QUOTE> is set then the whole string is instead surrounded by
58e71b7053SJung-uk Kimdouble quote characters: this is arguably more readable than the backslash
59e71b7053SJung-uk Kimnotation. Other characters use the "\XX" using exactly two characters of the hex
60e71b7053SJung-uk Kimrepresentation.
61e71b7053SJung-uk Kim
62e71b7053SJung-uk KimIf B<ASN1_STRFLGS_UTF8_CONVERT> is set then characters are converted to UTF8
63e71b7053SJung-uk Kimformat first. If the terminal supports the display of UTF8 sequences then this
64e71b7053SJung-uk Kimoption will correctly display multi byte characters.
65e71b7053SJung-uk Kim
66e71b7053SJung-uk KimIf B<ASN1_STRFLGS_IGNORE_TYPE> is set then the string type is not interpreted at
67e71b7053SJung-uk Kimall: everything is assumed to be one byte per character. This is primarily for
68e71b7053SJung-uk Kimdebugging purposes and can result in confusing output in multi character strings.
69e71b7053SJung-uk Kim
70e71b7053SJung-uk KimIf B<ASN1_STRFLGS_SHOW_TYPE> is set then the string type itself is printed out
71e71b7053SJung-uk Kimbefore its value (for example "BMPSTRING"), this actually uses ASN1_tag2str().
72e71b7053SJung-uk Kim
73e71b7053SJung-uk KimThe content of a string instead of being interpreted can be "dumped": this just
74e71b7053SJung-uk Kimoutputs the value of the string using the form #XXXX using hex format for each
75e71b7053SJung-uk Kimoctet.
76e71b7053SJung-uk Kim
77e71b7053SJung-uk KimIf B<ASN1_STRFLGS_DUMP_ALL> is set then any type is dumped.
78e71b7053SJung-uk Kim
79e71b7053SJung-uk KimNormally non character string types (such as OCTET STRING) are assumed to be
80e71b7053SJung-uk Kimone byte per character, if B<ASN1_STRFLGS_DUMP_UNKNOWN> is set then they will
81e71b7053SJung-uk Kimbe dumped instead.
82e71b7053SJung-uk Kim
83e71b7053SJung-uk KimWhen a type is dumped normally just the content octets are printed, if
84e71b7053SJung-uk KimB<ASN1_STRFLGS_DUMP_DER> is set then the complete encoding is dumped
85e71b7053SJung-uk Kiminstead (including tag and length octets).
86e71b7053SJung-uk Kim
87e71b7053SJung-uk KimB<ASN1_STRFLGS_RFC2253> includes all the flags required by RFC2253. It is
88e71b7053SJung-uk Kimequivalent to:
89e71b7053SJung-uk Kim ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB |
90e71b7053SJung-uk Kim ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN ASN1_STRFLGS_DUMP_DER
91e71b7053SJung-uk Kim
92e71b7053SJung-uk Kim=head1 RETURN VALUES
93e71b7053SJung-uk Kim
94e71b7053SJung-uk KimASN1_STRING_print_ex() and ASN1_STRING_print_ex_fp() return the number of
95e71b7053SJung-uk Kimcharacters written or -1 if an error occurred.
96e71b7053SJung-uk Kim
97e71b7053SJung-uk KimASN1_STRING_print() returns 1 on success or 0 on error.
98e71b7053SJung-uk Kim
99*b077aed3SPierre ProncheryASN1_tag2str() returns a human-readable name of the specified ASN.1 I<tag>.
100e71b7053SJung-uk Kim
101e71b7053SJung-uk Kim=head1 SEE ALSO
102e71b7053SJung-uk Kim
103e71b7053SJung-uk KimL<X509_NAME_print_ex(3)>,
104e71b7053SJung-uk KimL<ASN1_tag2str(3)>
105e71b7053SJung-uk Kim
106e71b7053SJung-uk Kim=head1 COPYRIGHT
107e71b7053SJung-uk Kim
108e71b7053SJung-uk KimCopyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
109e71b7053SJung-uk Kim
110*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
111e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
112e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
113e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
114e71b7053SJung-uk Kim
115e71b7053SJung-uk Kim=cut
116