OSSL_CMP_ITAV_set0.pod 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 OSSL_CMP_ITAV structure and fills it in.
  23. It combines B<OSSL_CMP_ITAV_new()> and B<OSSL_CMP_ITAV_set0>.
  24. OSSL_CMP_ITAV_set0() sets the B<itav> with an infoType of B<type> and an
  25. infoValue of B<value>. This function uses the pointers B<type> and B<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. B<itav>.
  29. OSSL_CMP_ITAV_get0_value() returns a direct pointer to the infoValue in
  30. the B<itav> as generic ASN1_TYPE*.
  31. OSSL_CMP_ITAV_push0_stack_item() pushes B<itav> to the stack pointed to
  32. by B<*itav_sk_p>. It creates a new stack if B<*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 EXAMPLE
  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 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. OSSL_CMP_CTX *ctx = OSSL_CMP_CTX_new();
  57. if (ctx == NULL || !OSSL_CMP_CTX_geninfo_push0_ITAV(ctx, itav)) {
  58. OSSL_CMP_ITAV_free(itav); /* also frees type and val */
  59. goto err;
  60. }
  61. ...
  62. OSSL_CMP_CTX_free(ctx); /* also frees itav */
  63. =head1 SEE ALSO
  64. L<OSSL_CMP_CTX_new(3)>, L<OSSL_CMP_CTX_free(3)>, L<ASN1_TYPE_set(3)>
  65. =head1 COPYRIGHT
  66. Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
  67. Licensed under the Apache License 2.0 (the "License"). You may not use
  68. this file except in compliance with the License. You can obtain a copy
  69. in the file LICENSE in the source distribution or at
  70. L<https://www.openssl.org/source/license.html>.
  71. =cut