1=pod 2 3=head1 NAME 4 5OSSL_CMP_ITAV_create, 6OSSL_CMP_ITAV_set0, 7OSSL_CMP_ITAV_get0_type, 8OSSL_CMP_ITAV_get0_value, 9OSSL_CMP_ITAV_push0_stack_item, 10OSSL_CMP_ITAV_new0_certProfile, 11OSSL_CMP_ITAV_get0_certProfile 12- OSSL_CMP_ITAV utility functions 13 14=head1 SYNOPSIS 15 16 #include <openssl/cmp.h> 17 18 OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value); 19 void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type, 20 ASN1_TYPE *value); 21 ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav); 22 ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav); 23 int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p, 24 OSSL_CMP_ITAV *itav); 25 OSSL_CMP_ITAV 26 *OSSL_CMP_ITAV_new0_certProfile(STACK_OF(ASN1_UTF8STRING) *certProfile); 27 int OSSL_CMP_ITAV_get0_certProfile(const OSSL_CMP_ITAV *itav, 28 STACK_OF(ASN1_UTF8STRING) **out); 29 30=head1 DESCRIPTION 31 32ITAV is short for InfoTypeAndValue. This type is defined in RFC 4210 33section 5.3.19 and Appendix F. It is used at various places in CMP messages, 34e.g., in the generalInfo PKIHeader field, to hold a key-value pair. 35 36OSSL_CMP_ITAV_create() creates a new B<OSSL_CMP_ITAV> structure and fills it in. 37It combines OSSL_CMP_ITAV_new() and OSSL_CMP_ITAV_set0(). 38 39OSSL_CMP_ITAV_set0() sets the I<itav> with an infoType of I<type> and an 40infoValue of I<value>. This function uses the pointers I<type> and I<value> 41internally, so they must B<not> be freed up after the call. 42 43OSSL_CMP_ITAV_get0_type() returns a direct pointer to the infoType in the 44I<itav>. 45 46OSSL_CMP_ITAV_get0_value() returns a direct pointer to the infoValue in 47the I<itav> as generic B<ASN1_TYPE> pointer. 48 49OSSL_CMP_ITAV_push0_stack_item() pushes I<itav> to the stack pointed to 50by I<*itav_sk_p>. It creates a new stack if I<*itav_sk_p> points to NULL. 51 52OSSL_CMP_ITAV_new0_certProfile() creates a new B<OSSL_CMP_ITAV> structure 53of type B<certProfile> that includes the optionally given list of profile names. 54On success, ownership of the list is with the new B<OSSL_CMP_ITAV> structure. 55 56OSSL_CMP_ITAV_get0_certProfile() on success assigns to I<*out> 57an internal pointer to the 58list of certificate profile names contained in the infoValue field of I<itav>. 59The pointer may be NULL if no profile name is included. 60It is an error if the infoType of I<itav> is not B<certProfile>. 61 62=head1 NOTES 63 64CMP is defined in RFC 4210 and RFC 9480 (and CRMF in RFC 4211). 65 66OIDs to use as types in B<OSSL_CMP_ITAV> can be found at 67L<https://datatracker.ietf.org/doc/html/rfc9480#section-4.2.2>. 68The respective OpenSSL NIDs, such as B<NID_id_it_certProfile>, 69are defined in the F<< <openssl/obj_mac.h> >> header file. 70 71=head1 RETURN VALUES 72 73OSSL_CMP_ITAV_create() and OSSL_CMP_ITAV_new0_certProfile() 74return a pointer to an ITAV structure on success, or NULL on error. 75 76OSSL_CMP_ITAV_set0() does not return a value. 77 78OSSL_CMP_ITAV_get0_type() and OSSL_CMP_ITAV_get0_value() 79return the respective pointer or NULL if their input is NULL. 80 81OSSL_CMP_ITAV_push0_stack_item() and OSSL_CMP_ITAV_get0_certProfile() 82return 1 on success, 0 on error. 83 84=head1 EXAMPLES 85 86The following code creates and sets a structure representing a generic 87InfoTypeAndValue sequence, using an OID created from text as type, and an 88integer as value. Afterwards, it is pushed to the B<OSSL_CMP_CTX> to be later 89included in the requests' PKIHeader's genInfo field. 90 91 ASN1_OBJECT *type = OBJ_txt2obj("1.2.3.4.5", 1); 92 if (type == NULL) ... 93 94 ASN1_INTEGER *asn1int = ASN1_INTEGER_new(); 95 if (asn1int == NULL || !ASN1_INTEGER_set(asn1int, 12345)) ... 96 97 ASN1_TYPE *val = ASN1_TYPE_new(); 98 if (val == NULL) ... 99 ASN1_TYPE_set(val, V_ASN1_INTEGER, asn1int); 100 101 OSSL_CMP_ITAV *itav = OSSL_CMP_ITAV_create(type, val); 102 if (itav == NULL) ... 103 104 if (!OSSL_CMP_CTX_push0_geninfo_ITAV(ctx, itav)) { 105 OSSL_CMP_ITAV_free(itav); /* also frees type and val */ 106 ... 107 } 108 109 ... 110 111 OSSL_CMP_CTX_free(ctx); /* also frees itav */ 112 113=head1 SEE ALSO 114 115L<OSSL_CMP_CTX_new(3)>, L<OSSL_CMP_CTX_free(3)>, L<ASN1_TYPE_set(3)> 116 117=head1 HISTORY 118 119The OpenSSL CMP support was added in OpenSSL 3.0. 120 121OSSL_CMP_ITAV_new0_certProfile() and OSSL_CMP_ITAV_get0_certProfile() 122were added in OpenSSL 3.3. 123 124=head1 COPYRIGHT 125 126Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved. 127 128Licensed under the Apache License 2.0 (the "License"). You may not use 129this file except in compliance with the License. You can obtain a copy 130in the file LICENSE in the source distribution or at 131L<https://www.openssl.org/source/license.html>. 132 133=cut 134