.\" $OpenBSD: ASN1_STRING_print_ex.3,v 1.7 2017/03/25 16:30:10 schwarze Exp $ .\" OpenSSL 9e183d22 Sat Mar 11 08:56:44 2017 -0500 .\" OpenSSL bb9ad09e Mon Jun 6 00:43:05 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson. .\" Copyright (c) 2002, 2004, 2007, 2013, 2016, 2017 The OpenSSL Project. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in .\" the documentation and/or other materials provided with the .\" distribution. .\" .\" 3. All advertising materials mentioning features or use of this .\" software must display the following acknowledgment: .\" "This product includes software developed by the OpenSSL Project .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" .\" .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to .\" endorse or promote products derived from this software without .\" prior written permission. For written permission, please contact .\" openssl-core@openssl.org. .\" .\" 5. Products derived from this software may not be called "OpenSSL" .\" nor may "OpenSSL" appear in their names without prior written .\" permission of the OpenSSL Project. .\" .\" 6. Redistributions of any form whatsoever must retain the following .\" acknowledgment: .\" "This product includes software developed by the OpenSSL Project .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" .\" .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" .Dd $Mdocdate: March 25 2017 $ .Dt ASN1_STRING_PRINT_EX 3 .Os .Sh NAME .Nm ASN1_STRING_print_ex , .Nm ASN1_STRING_print_ex_fp , .Nm ASN1_STRING_print , .Nm ASN1_tag2str .Nd ASN1_STRING output routines .Sh SYNOPSIS .In openssl/asn1.h .Ft int .Fo ASN1_STRING_print_ex .Fa "BIO *out" .Fa "ASN1_STRING *str" .Fa "unsigned long flags" .Fc .Ft int .Fo ASN1_STRING_print_ex_fp .Fa "FILE *fp" .Fa "ASN1_STRING *str" .Fa "unsigned long flags" .Fc .Ft int .Fo ASN1_STRING_print .Fa "BIO *out" .Fa "ASN1_STRING *str" .Fc .Ft const char * .Fo ASN1_tag2str .Fa "int tag" .Fc .Sh DESCRIPTION These functions output an .Vt ASN1_STRING structure. .Vt ASN1_STRING is used to represent all the ASN.1 string types. .Pp .Fn ASN1_STRING_print_ex outputs .Fa str to .Fa out , the format being determined by the options .Fa flags . .Fn ASN1_STRING_print_ex_fp is identical except it outputs to .Fa fp instead. .Pp .Fn ASN1_STRING_print prints .Fa str to .Fa out but using a different format to .Fn ASN1_STRING_print_ex . It replaces unprintable characters (other than CR, LF) with .Sq \&. . .Pp .Fn ASN1_tag2str returns a human-readable name of the specified ASN.1 .Fa tag . .Pp .Fn ASN1_STRING_print is a legacy function which should be avoided in new applications. .Pp Although there are a large number of options, .Dv ASN1_STRFLGS_RFC2253 is often suitable, or on UTF-8 terminals .Dv ASN1_STRFLGS_RFC2253 and .Pf ~ Dv ASN1_STRFLGS_ESC_MSB . .Pp The complete set of supported options for .Fa flags is listed below. .Pp Various characters can be escaped. If .Dv ASN1_STRFLGS_ESC_2253 is set, the characters determined by RFC 2253 are escaped. If .Dv ASN1_STRFLGS_ESC_CTRL is set, control characters are escaped. If .Dv ASN1_STRFLGS_ESC_MSB is set, characters with the MSB set are escaped: this option should .Em not be used if the terminal correctly interprets UTF-8 sequences. .Pp Escaping takes several forms. If the character being escaped is a 16-bit character then the form "\eUXXXX" is used using exactly four characters for the hex representation. If it is 32 bits then "\eWXXXXXXXX" is used using eight characters of its hex representation. These forms will only be used if UTF-8 conversion is not set (see below). .Pp Printable characters are normally escaped using the backslash .Pq Sq \e character. If .Dv ASN1_STRFLGS_ESC_QUOTE is set, then the whole string is instead surrounded by double quote characters: this is arguably more readable than the backslash notation. Other characters use the "\eXX" using exactly two characters of the hex representation. .Pp If .Dv ASN1_STRFLGS_UTF8_CONVERT is set, then characters are converted to UTF-8 format first. If the terminal supports the display of UTF-8 sequences then this option will correctly display multi-byte characters. .Pp If .Dv ASN1_STRFLGS_IGNORE_TYPE is set, then the string type is not interpreted at all: everything is assumed to be one byte per character. This is primarily for debugging purposes and can result in confusing output in multi-character strings. .Pp If .Dv ASN1_STRFLGS_SHOW_TYPE is set, then the string type itself is printed before its value (for example "BMPSTRING"), using .Fn ASN1_tag2str . .Pp Instead of being interpreted the contents of a string can be "dumped": this just outputs the value of the string using the form #XXXX using hex format for each octet. .Pp If .Dv ASN1_STRFLGS_DUMP_ALL is set, then any type is dumped. .Pp Normally non-character string types (such as OCTET STRING) are assumed to be one byte per character; if .Dv ASN1_STRFLGS_DUMP_UNKNOWN is set, then they will be dumped instead. .Pp When a type is dumped normally just the content octets are printed; if .Dv ASN1_STRFLGS_DUMP_DER is set, then the complete encoding is dumped instead (including tag and length octets). .Pp .Dv ASN1_STRFLGS_RFC2253 includes all the flags required by RFC 2253. It is equivalent to .Dv ASN1_STRFLGS_ESC_2253 | .Dv ASN1_STRFLGS_ESC_CTRL | .Dv ASN1_STRFLGS_ESC_MSB | .Dv ASN1_STRFLGS_UTF8_CONVERT | .Dv ASN1_STRFLGS_DUMP_UNKNOWN | .Dv ASN1_STRFLGS_DUMP_DER . .Sh SEE ALSO .Xr X509_NAME_print_ex 3