OSSL_CMP_ITAV_set0.pod 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. ITAV is short for InfoTypeAndValue. This type is defined in RFC 4210
  20. section 5.3.19 and Appendix F. It is used at various places in CMP messages,
  21. e.g., in the generalInfo PKIHeader field, to hold a key-value pair.
  22. OSSL_CMP_ITAV_create() creates a new B<OSSL_CMP_ITAV> structure and fills it in.
  23. It combines OSSL_CMP_ITAV_new() and OSSL_CMP_ITAV_set0().
  24. OSSL_CMP_ITAV_set0() sets the I<itav> with an infoType of I<type> and an
  25. infoValue of I<value>. This function uses the pointers I<type> and I<value>
  26. internally, so they must B<not> be freed up after the call.
  27. OSSL_CMP_ITAV_get0_type() returns a direct pointer to the infoType in the
  28. I<itav>.
  29. OSSL_CMP_ITAV_get0_value() returns a direct pointer to the infoValue in
  30. the I<itav> as generic B<ASN1_TYPE> pointer.
  31. OSSL_CMP_ITAV_push0_stack_item() pushes I<itav> to the stack pointed to
  32. by I<*itav_sk_p>. It creates a new stack if I<*itav_sk_p> points to NULL.
  33. =head1 NOTES
  34. CMP is defined in RFC 4210 (and CRMF in RFC 4211).
  35. =head1 RETURN VALUES
  36. OSSL_CMP_ITAV_create() returns a pointer to the ITAV structure on success,
  37. or NULL on error.
  38. OSSL_CMP_ITAV_set0() does not return a value.
  39. OSSL_CMP_ITAV_get0_type() and OSSL_CMP_ITAV_get0_value()
  40. return the respective pointer or NULL if their input is NULL.
  41. OSSL_CMP_ITAV_push0_stack_item() returns 1 on success, 0 on error.
  42. =head1 EXAMPLES
  43. The following code creates and sets a structure representing a generic
  44. InfoTypeAndValue sequence, using an OID created from text as type, and an
  45. integer as value. Afterwards, it is pushed to the B<OSSL_CMP_CTX> to be later
  46. included in the requests' PKIHeader's genInfo field.
  47. ASN1_OBJECT *type = OBJ_txt2obj("1.2.3.4.5", 1);
  48. if (type == NULL) ...
  49. ASN1_INTEGER *asn1int = ASN1_INTEGER_new();
  50. if (asn1int == NULL || !ASN1_INTEGER_set(asn1int, 12345)) ...
  51. ASN1_TYPE *val = ASN1_TYPE_new();
  52. if (val == NULL) ...
  53. ASN1_TYPE_set(val, V_ASN1_INTEGER, asn1int);
  54. OSSL_CMP_ITAV *itav = OSSL_CMP_ITAV_create(type, val);
  55. if (itav == NULL) ...
  56. if (!OSSL_CMP_CTX_push0_geninfo_ITAV(ctx, itav)) {
  57. OSSL_CMP_ITAV_free(itav); /* also frees type and val */
  58. ...
  59. }
  60. ...
  61. OSSL_CMP_CTX_free(ctx); /* also frees itav */
  62. =head1 SEE ALSO
  63. L<OSSL_CMP_CTX_new(3)>, L<OSSL_CMP_CTX_free(3)>, L<ASN1_TYPE_set(3)>
  64. =head1 HISTORY
  65. The OpenSSL CMP support was added in OpenSSL 3.0.
  66. =head1 COPYRIGHT
  67. Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
  68. Licensed under the Apache License 2.0 (the "License"). You may not use
  69. this file except in compliance with the License. You can obtain a copy
  70. in the file LICENSE in the source distribution or at
  71. L<https://www.openssl.org/source/license.html>.
  72. =cut