ossl_cmp_asn1_octet_string_set1.pod 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. =pod
  2. =head1 NAME
  3. ossl_cmp_log_parse_metadata,
  4. ossl_cmp_add_error_txt,
  5. ossl_cmp_add_error_data,
  6. ossl_cmp_add_error_line,
  7. ossl_cmp_asn1_octet_string_set1,
  8. ossl_cmp_asn1_octet_string_set1_bytes,
  9. ossl_cmp_build_cert_chain
  10. - misc internal utility functions
  11. =head1 SYNOPSIS
  12. #include "cmp_local.h"
  13. const char *ossl_cmp_log_parse_metadata(const char *buf,
  14. OSSL_CMP_severity *level, char **func,
  15. char **file, int *line);
  16. void ossl_cmp_add_error_txt(const char *separator, const char *txt);
  17. #define ossl_cmp_add_error_data(txt)
  18. #define ossl_cmp_add_error_line(txt)
  19. int ossl_cmp_asn1_octet_string_set1(ASN1_OCTET_STRING **tgt,
  20. const ASN1_OCTET_STRING *src);
  21. int ossl_cmp_asn1_octet_string_set1_bytes(ASN1_OCTET_STRING **tgt,
  22. const unsigned char *bytes, int len);
  23. STACK_OF(X509) *ossl_cmp_build_cert_chain(STACK_OF(X509) *certs, X509 *cert);
  24. =head1 DESCRIPTION
  25. ossl_cmp_log_parse_metadata() parses the given message buffer I<buf> populated
  26. by L<OSSL_CMP_log(3)> etc.
  27. according to the pattern OSSL_CMP_LOG_START#level ": %s\n", filling in
  28. the variable pointed to by I<level> with the severity level or -1,
  29. the variable pointed to by I<func> with the function name string or NULL,
  30. the variable pointed to by I<file> with the filename string or NULL, and
  31. the variable pointed to by I<line> with the line number or -1.
  32. Any string returned via I<*func> and I<*file> must be freeed by the caller.
  33. ossl_cmp_add_error_txt() appends text to the extra data field of the last
  34. error message in the OpenSSL error queue, after adding the optional separator
  35. unless data has been empty so far. The text can be of arbitrary length,
  36. which is not possible when using L<ERR_add_error_data(3)> in conjunction with
  37. L<ERR_print_errors_cb(3)>.
  38. ossl_cmp_add_error_data() is a macro calling
  39. ossl_cmp_add_error_txt() with the separator being ":".
  40. ossl_cmp_add_error_line() is a macro calling
  41. ossl_cmp_add_error_txt() with the separator being "\n".
  42. ossl_cmp_asn1_octet_string_set1() frees any previous value of the variable
  43. referenced via the I<tgt> argument and assigns either a copy of
  44. the ASN1_OCTET_STRING given as the I<src> argument or NULL.
  45. It returns 1 on success, 0 on error.
  46. ossl_cmp_asn1_octet_string_set1_bytes() frees any previous value of the variable
  47. referenced via the I<tgt> argument and assigns either a copy of the given byte
  48. string (with the given length) or NULL. It returns 1 on success, 0 on error.
  49. ossl_cmp_build_cert_chain() builds up the certificate chain of cert as high up
  50. as possible using the given X509_STORE containing all possible intermediate
  51. certificates and optionally the (possible) trust anchor(s).
  52. =head1 RETURN VALUES
  53. ossl_cmp_log_parse_metadata() returns the pointer to the actual message text
  54. after the OSSL_CMP_LOG_PREFIX and level and ':' if found in the buffer,
  55. else the beginning of the buffer.
  56. ossl_cmp_add_error_txt()
  57. ossl_cmp_add_error_data(), and
  58. ossl_cmp_add_error_line()
  59. do not return anything.
  60. ossl_cmp_build_cert_chain()
  61. returns NULL on error, else a pointer to a stack of (up_ref'ed) certificates
  62. containing the EE certificate given in the function arguments (cert)
  63. and all intermediate certificates up the chain toward the trust anchor.
  64. The (self-signed) trust anchor is not included.
  65. All other functions return 1 on success, 0 on error.
  66. =head1 HISTORY
  67. The OpenSSL CMP support was added in OpenSSL 3.0.
  68. =head1 COPYRIGHT
  69. Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
  70. Licensed under the Apache License 2.0 (the "License"). You may not use
  71. this file except in compliance with the License. You can obtain a copy
  72. in the file LICENSE in the source distribution or at
  73. L<https://www.openssl.org/source/license.html>.
  74. =cut