OSSL_CMP_ITAV_set0.pod 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. =pod
  2. =head1 NAME
  3. OSSL_CMP_ITAV_create,
  4. OSSL_CMP_ITAV_set0,
  5. OSSL_CMP_ITAV_get0_type,
  6. OSSL_CMP_ITAV_get0_value,
  7. OSSL_CMP_ITAV_push0_stack_item
  8. - OSSL_CMP_ITAV utility functions
  9. =head1 SYNOPSIS
  10. #include <openssl/cmp.h>
  11. OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value);
  12. void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
  13. ASN1_TYPE *value);
  14. ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav);
  15. ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav);
  16. int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p,
  17. OSSL_CMP_ITAV *itav);
  18. =head1 DESCRIPTION
  19. Certificate Management Protocol (CMP, RFC 4210) extension to OpenSSL
  20. ITAV is short for InfoTypeAndValue. This type is defined in RFC 4210
  21. section 5.3.19 and Appendix F. It is used at various places in CMP messages,
  22. e.g., in the generalInfo PKIHeader field, to hold a key-value pair.
  23. OSSL_CMP_ITAV_create() creates a new B<OSSL_CMP_ITAV> structure and fills it in.
  24. It combines OSSL_CMP_ITAV_new() and OSSL_CMP_ITAV_set0().
  25. OSSL_CMP_ITAV_set0() sets the I<itav> with an infoType of I<type> and an
  26. infoValue of I<value>. This function uses the pointers I<type> and I<value>
  27. internally, so they must B<not> be freed up after the call.
  28. OSSL_CMP_ITAV_get0_type() returns a direct pointer to the infoType in the
  29. I<itav>.
  30. OSSL_CMP_ITAV_get0_value() returns a direct pointer to the infoValue in
  31. the I<itav> as generic B<ASN1_TYPE> pointer.
  32. OSSL_CMP_ITAV_push0_stack_item() pushes I<itav> to the stack pointed to
  33. by I<*itav_sk_p>. It creates a new stack if I<*itav_sk_p> points to NULL.
  34. =head1 NOTES
  35. CMP is defined in RFC 4210 (and CRMF in RFC 4211).
  36. =head1 RETURN VALUES
  37. OSSL_CMP_ITAV_create() returns a pointer to the ITAV structure on success,
  38. or NULL on error.
  39. OSSL_CMP_ITAV_set0() does not return a value.
  40. OSSL_CMP_ITAV_get0_type() and OSSL_CMP_ITAV_get0_value()
  41. return the respective pointer or NULL if their input is NULL.
  42. OSSL_CMP_ITAV_push0_stack_item() returns 1 on success, 0 on error.
  43. =head1 EXAMPLES
  44. The following code creates and sets a structure representing a generic
  45. InfoTypeAndValue sequence, using an OID created from text as type, and an
  46. integer as value. Afterwards, it is pushed to the B<OSSL_CMP_CTX> to be later
  47. included in the requests' PKIHeader's genInfo field.
  48. ASN1_OBJECT *type = OBJ_txt2obj("1.2.3.4.5", 1);
  49. if (type == NULL) ...
  50. ASN1_INTEGER *asn1int = ASN1_INTEGER_new();
  51. if (asn1int == NULL || !ASN1_INTEGER_set(asn1int, 12345)) ...
  52. ASN1_TYPE *val = ASN1_TYPE_new();
  53. if (val == NULL) ...
  54. ASN1_TYPE_set(val, V_ASN1_INTEGER, asn1int);
  55. OSSL_CMP_ITAV *itav = OSSL_CMP_ITAV_create(type, val);
  56. if (itav == NULL) ...
  57. OSSL_CMP_CTX *ctx = OSSL_CMP_CTX_new();
  58. if (ctx == NULL || !OSSL_CMP_CTX_geninfo_push0_ITAV(ctx, itav)) {
  59. OSSL_CMP_ITAV_free(itav); /* also frees type and val */
  60. goto err;
  61. }
  62. ...
  63. OSSL_CMP_CTX_free(ctx); /* also frees itav */
  64. =head1 SEE ALSO
  65. L<OSSL_CMP_CTX_new(3)>, L<OSSL_CMP_CTX_free(3)>, L<ASN1_TYPE_set(3)>
  66. =head1 HISTORY
  67. The OpenSSL CMP support was added in OpenSSL 3.0.
  68. =head1 COPYRIGHT
  69. Copyright 2007-2021 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