.\" $OpenBSD: ASN1_STRING_print_ex.3,v 1.14 2018/04/25 15:17:52 schwarze Exp $ .\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" .\" 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: April 25 2018 $ .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 "const ASN1_STRING *str" .Fa "unsigned long flags" .Fc .Ft int .Fo ASN1_STRING_print_ex_fp .Fa "FILE *fp" .Fa "const ASN1_STRING *str" .Fa "unsigned long flags" .Fc .Ft int .Fo ASN1_STRING_print .Fa "BIO *out" .Fa "const 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 deprecated function which should be avoided; use .Fn ASN1_STRING_print_ex instead. .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 RETURN VALUES .Fn ASN1_STRING_print_ex and .Fn ASN1_STRING_print_ex_fp return the number of characters written or \-1 if an error occurred. .Pp .Fn ASN1_STRING_print returns 1 on success or 0 on error. .Pp .Fn ASN1_tag2str returns a static string. .Sh SEE ALSO .Xr X509_NAME_print_ex 3 .Sh HISTORY .Fn ASN1_STRING_print first appeared in SSLeay 0.6.5 and has been available since .Ox 2.4 . .Pp .Fn ASN1_tag2str first appeared in OpenSSL 0.9.5 and has been available since .Ox 2.7 . .Pp .Fn ASN1_STRING_print_ex and .Fn ASN1_STRING_print_ex_fp first appeared in OpenSSL 0.9.6 and have been available since .Ox 2.9 .