1*b077aed3SPierre Pronchery=pod 2*b077aed3SPierre Pronchery 3*b077aed3SPierre Pronchery=head1 NAME 4*b077aed3SPierre Pronchery 5*b077aed3SPierre ProncheryOSSL_CMP_ITAV_create, 6*b077aed3SPierre ProncheryOSSL_CMP_ITAV_set0, 7*b077aed3SPierre ProncheryOSSL_CMP_ITAV_get0_type, 8*b077aed3SPierre ProncheryOSSL_CMP_ITAV_get0_value, 9*b077aed3SPierre ProncheryOSSL_CMP_ITAV_push0_stack_item 10*b077aed3SPierre Pronchery- OSSL_CMP_ITAV utility functions 11*b077aed3SPierre Pronchery 12*b077aed3SPierre Pronchery=head1 SYNOPSIS 13*b077aed3SPierre Pronchery 14*b077aed3SPierre Pronchery #include <openssl/cmp.h> 15*b077aed3SPierre Pronchery OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value); 16*b077aed3SPierre Pronchery void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type, 17*b077aed3SPierre Pronchery ASN1_TYPE *value); 18*b077aed3SPierre Pronchery ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav); 19*b077aed3SPierre Pronchery ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav); 20*b077aed3SPierre Pronchery 21*b077aed3SPierre Pronchery int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p, 22*b077aed3SPierre Pronchery OSSL_CMP_ITAV *itav); 23*b077aed3SPierre Pronchery 24*b077aed3SPierre Pronchery=head1 DESCRIPTION 25*b077aed3SPierre Pronchery 26*b077aed3SPierre ProncheryCertificate Management Protocol (CMP, RFC 4210) extension to OpenSSL 27*b077aed3SPierre Pronchery 28*b077aed3SPierre ProncheryITAV is short for InfoTypeAndValue. This type is defined in RFC 4210 29*b077aed3SPierre Proncherysection 5.3.19 and Appendix F. It is used at various places in CMP messages, 30*b077aed3SPierre Proncherye.g., in the generalInfo PKIHeader field, to hold a key-value pair. 31*b077aed3SPierre Pronchery 32*b077aed3SPierre ProncheryOSSL_CMP_ITAV_create() creates a new B<OSSL_CMP_ITAV> structure and fills it in. 33*b077aed3SPierre ProncheryIt combines OSSL_CMP_ITAV_new() and OSSL_CMP_ITAV_set0(). 34*b077aed3SPierre Pronchery 35*b077aed3SPierre ProncheryOSSL_CMP_ITAV_set0() sets the I<itav> with an infoType of I<type> and an 36*b077aed3SPierre ProncheryinfoValue of I<value>. This function uses the pointers I<type> and I<value> 37*b077aed3SPierre Proncheryinternally, so they must B<not> be freed up after the call. 38*b077aed3SPierre Pronchery 39*b077aed3SPierre ProncheryOSSL_CMP_ITAV_get0_type() returns a direct pointer to the infoType in the 40*b077aed3SPierre ProncheryI<itav>. 41*b077aed3SPierre Pronchery 42*b077aed3SPierre ProncheryOSSL_CMP_ITAV_get0_value() returns a direct pointer to the infoValue in 43*b077aed3SPierre Proncherythe I<itav> as generic B<ASN1_TYPE> pointer. 44*b077aed3SPierre Pronchery 45*b077aed3SPierre ProncheryOSSL_CMP_ITAV_push0_stack_item() pushes I<itav> to the stack pointed to 46*b077aed3SPierre Proncheryby I<*itav_sk_p>. It creates a new stack if I<*itav_sk_p> points to NULL. 47*b077aed3SPierre Pronchery 48*b077aed3SPierre Pronchery=head1 NOTES 49*b077aed3SPierre Pronchery 50*b077aed3SPierre ProncheryCMP is defined in RFC 4210 (and CRMF in RFC 4211). 51*b077aed3SPierre Pronchery 52*b077aed3SPierre Pronchery=head1 RETURN VALUES 53*b077aed3SPierre Pronchery 54*b077aed3SPierre ProncheryOSSL_CMP_ITAV_create() returns a pointer to the ITAV structure on success, 55*b077aed3SPierre Proncheryor NULL on error. 56*b077aed3SPierre Pronchery 57*b077aed3SPierre ProncheryOSSL_CMP_ITAV_set0() does not return a value. 58*b077aed3SPierre Pronchery 59*b077aed3SPierre ProncheryOSSL_CMP_ITAV_get0_type() and OSSL_CMP_ITAV_get0_value() 60*b077aed3SPierre Proncheryreturn the respective pointer or NULL if their input is NULL. 61*b077aed3SPierre Pronchery 62*b077aed3SPierre ProncheryOSSL_CMP_ITAV_push0_stack_item() returns 1 on success, 0 on error. 63*b077aed3SPierre Pronchery 64*b077aed3SPierre Pronchery=head1 EXAMPLES 65*b077aed3SPierre Pronchery 66*b077aed3SPierre ProncheryThe following code creates and sets a structure representing a generic 67*b077aed3SPierre ProncheryInfoTypeAndValue sequence, using an OID created from text as type, and an 68*b077aed3SPierre Proncheryinteger as value. Afterwards, it is pushed to the B<OSSL_CMP_CTX> to be later 69*b077aed3SPierre Proncheryincluded in the requests' PKIHeader's genInfo field. 70*b077aed3SPierre Pronchery 71*b077aed3SPierre Pronchery ASN1_OBJECT *type = OBJ_txt2obj("1.2.3.4.5", 1); 72*b077aed3SPierre Pronchery if (type == NULL) ... 73*b077aed3SPierre Pronchery 74*b077aed3SPierre Pronchery ASN1_INTEGER *asn1int = ASN1_INTEGER_new(); 75*b077aed3SPierre Pronchery if (asn1int == NULL || !ASN1_INTEGER_set(asn1int, 12345)) ... 76*b077aed3SPierre Pronchery 77*b077aed3SPierre Pronchery ASN1_TYPE *val = ASN1_TYPE_new(); 78*b077aed3SPierre Pronchery if (val == NULL) ... 79*b077aed3SPierre Pronchery ASN1_TYPE_set(val, V_ASN1_INTEGER, asn1int); 80*b077aed3SPierre Pronchery 81*b077aed3SPierre Pronchery OSSL_CMP_ITAV *itav = OSSL_CMP_ITAV_create(type, val); 82*b077aed3SPierre Pronchery if (itav == NULL) ... 83*b077aed3SPierre Pronchery 84*b077aed3SPierre Pronchery OSSL_CMP_CTX *ctx = OSSL_CMP_CTX_new(); 85*b077aed3SPierre Pronchery if (ctx == NULL || !OSSL_CMP_CTX_geninfo_push0_ITAV(ctx, itav)) { 86*b077aed3SPierre Pronchery OSSL_CMP_ITAV_free(itav); /* also frees type and val */ 87*b077aed3SPierre Pronchery goto err; 88*b077aed3SPierre Pronchery } 89*b077aed3SPierre Pronchery 90*b077aed3SPierre Pronchery ... 91*b077aed3SPierre Pronchery 92*b077aed3SPierre Pronchery OSSL_CMP_CTX_free(ctx); /* also frees itav */ 93*b077aed3SPierre Pronchery 94*b077aed3SPierre Pronchery=head1 SEE ALSO 95*b077aed3SPierre Pronchery 96*b077aed3SPierre ProncheryL<OSSL_CMP_CTX_new(3)>, L<OSSL_CMP_CTX_free(3)>, L<ASN1_TYPE_set(3)> 97*b077aed3SPierre Pronchery 98*b077aed3SPierre Pronchery=head1 HISTORY 99*b077aed3SPierre Pronchery 100*b077aed3SPierre ProncheryThe OpenSSL CMP support was added in OpenSSL 3.0. 101*b077aed3SPierre Pronchery 102*b077aed3SPierre Pronchery=head1 COPYRIGHT 103*b077aed3SPierre Pronchery 104*b077aed3SPierre ProncheryCopyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved. 105*b077aed3SPierre Pronchery 106*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 107*b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 108*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 109*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 110*b077aed3SPierre Pronchery 111*b077aed3SPierre Pronchery=cut 112