2
0

ASN1_STRING_print_ex.pod 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. =pod
  2. =head1 NAME
  3. ASN1_tag2str, ASN1_STRING_print_ex, ASN1_STRING_print_ex_fp, ASN1_STRING_print
  4. - ASN1_STRING output routines
  5. =head1 SYNOPSIS
  6. #include <openssl/asn1.h>
  7. int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags);
  8. int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags);
  9. int ASN1_STRING_print(BIO *out, const ASN1_STRING *str);
  10. const char *ASN1_tag2str(int tag);
  11. =head1 DESCRIPTION
  12. These functions output an B<ASN1_STRING> structure. B<ASN1_STRING> is used to
  13. represent all the ASN1 string types.
  14. ASN1_STRING_print_ex() outputs I<str> to I<out>, the format is determined by
  15. the options I<flags>. ASN1_STRING_print_ex_fp() is identical except it outputs
  16. to I<fp> instead.
  17. ASN1_STRING_print() prints I<str> to I<out> but using a different format to
  18. ASN1_STRING_print_ex(). It replaces unprintable characters (other than CR, LF)
  19. with '.'.
  20. ASN1_tag2str() returns a human-readable name of the specified ASN.1 I<tag>.
  21. =head1 NOTES
  22. ASN1_STRING_print() is a deprecated function which should be avoided; use
  23. ASN1_STRING_print_ex() instead.
  24. Although there are a large number of options frequently B<ASN1_STRFLGS_RFC2253> is
  25. suitable, or on UTF8 terminals B<ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB>.
  26. The complete set of supported options for I<flags> is listed below.
  27. Various characters can be escaped. If B<ASN1_STRFLGS_ESC_2253> is set the characters
  28. determined by RFC2253 are escaped. If B<ASN1_STRFLGS_ESC_CTRL> is set control
  29. characters are escaped. If B<ASN1_STRFLGS_ESC_MSB> is set characters with the
  30. MSB set are escaped: this option should B<not> be used if the terminal correctly
  31. interprets UTF8 sequences.
  32. Escaping takes several forms.
  33. If the character being escaped is a 16 bit character then the form "\UXXXX" is used
  34. using exactly four characters for the hex representation. If it is 32 bits then
  35. "\WXXXXXXXX" is used using eight characters of its hex representation. These forms
  36. will only be used if UTF8 conversion is not set (see below).
  37. Printable characters are normally escaped using the backslash '\' character. If
  38. B<ASN1_STRFLGS_ESC_QUOTE> is set then the whole string is instead surrounded by
  39. double quote characters: this is arguably more readable than the backslash
  40. notation. Other characters use the "\XX" using exactly two characters of the hex
  41. representation.
  42. If B<ASN1_STRFLGS_UTF8_CONVERT> is set then characters are converted to UTF8
  43. format first. If the terminal supports the display of UTF8 sequences then this
  44. option will correctly display multi byte characters.
  45. If B<ASN1_STRFLGS_IGNORE_TYPE> is set then the string type is not interpreted at
  46. all: everything is assumed to be one byte per character. This is primarily for
  47. debugging purposes and can result in confusing output in multi character strings.
  48. If B<ASN1_STRFLGS_SHOW_TYPE> is set then the string type itself is printed out
  49. before its value (for example "BMPSTRING"), this actually uses ASN1_tag2str().
  50. The content of a string instead of being interpreted can be "dumped": this just
  51. outputs the value of the string using the form #XXXX using hex format for each
  52. octet.
  53. If B<ASN1_STRFLGS_DUMP_ALL> is set then any type is dumped.
  54. Normally non character string types (such as OCTET STRING) are assumed to be
  55. one byte per character, if B<ASN1_STRFLGS_DUMP_UNKNOWN> is set then they will
  56. be dumped instead.
  57. When a type is dumped normally just the content octets are printed, if
  58. B<ASN1_STRFLGS_DUMP_DER> is set then the complete encoding is dumped
  59. instead (including tag and length octets).
  60. B<ASN1_STRFLGS_RFC2253> includes all the flags required by RFC2253. It is
  61. equivalent to:
  62. ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB |
  63. ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN ASN1_STRFLGS_DUMP_DER
  64. =head1 RETURN VALUES
  65. ASN1_STRING_print_ex() and ASN1_STRING_print_ex_fp() return the number of
  66. characters written or -1 if an error occurred.
  67. ASN1_STRING_print() returns 1 on success or 0 on error.
  68. ASN1_tag2str() returns a human-readable name of the specified ASN.1 I<tag>.
  69. =head1 SEE ALSO
  70. L<X509_NAME_print_ex(3)>,
  71. L<ASN1_tag2str(3)>
  72. =head1 COPYRIGHT
  73. Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
  74. Licensed under the Apache License 2.0 (the "License"). You may not use
  75. this file except in compliance with the License. You can obtain a copy
  76. in the file LICENSE in the source distribution or at
  77. L<https://www.openssl.org/source/license.html>.
  78. =cut