OSSL_CMP_ITAV_SET0(3SSL)

πŸ’– OSSL_CMP_ITAV_SET0 β€” the ITAV bestie squad πŸ’–

omg hi. so this is a page from the OpenSSL manual, section 3SSL, and it's all about the OSSL_CMP_ITAV utility functions. yes we're doing CMP today, and yes we're gonna have fun with it. πŸ¦‹


✨ NAME ✨

the girlies in question: OSSL_CMP_ITAV_create, OSSL_CMP_ITAV_set0, OSSL_CMP_ITAV_get0_type, OSSL_CMP_ITAV_get0_value, OSSL_CMP_ITAV_push0_stack_item, OSSL_CMP_ITAV_new0_certProfile, OSSL_CMP_ITAV_get0_certProfile β€” collectively known as the OSSL_CMP_ITAV utility functions. πŸ’…


🌸 SYNOPSIS 🌸

okay so first you gotta pull in the header, obviously:

#include <openssl/cmp.h>

OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value);
void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
                        ASN1_TYPE *value);
ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav);
ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav);
int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p,
                                   OSSL_CMP_ITAV *itav);
OSSL_CMP_ITAV
*OSSL_CMP_ITAV_new0_certProfile(STACK_OF(ASN1_UTF8STRING) *certProfile);
int OSSL_CMP_ITAV_get0_certProfile(const OSSL_CMP_ITAV *itav,
                                   STACK_OF(ASN1_UTF8STRING) **out);

look at all those functions, we love a full roster. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

so bestie, ITAV is short for InfoTypeAndValue. iconic name, no notes. this type is defined in RFC 9810 section 5.3.19 and Appendix F (yes we cite our sources, we're not animals). it shows up in various places in CMP messages β€” for example in the generalInfo PKIHeader field β€” and its whole job is to hold a key-value pair. it's giving pair-bonded. it's giving dynamic duo. πŸ’ž

  • OSSL_CMP_ITAV_create() β€” makes a brand new OSSL_CMP_ITAV structure and fills it in. it's literally just OSSL_CMP_ITAV_new() and OSSL_CMP_ITAV_set0() combined into one little glow-up. two steps, one function, efficient queen. ✨
  • OSSL_CMP_ITAV_set0() β€” sets the itav with an infoType of type and an infoValue of value. important warning moment: this function uses the pointers type and value internally, so you must NOT free them up after the call. do not do it. put the free() down. πŸ™ˆ ownership has been transferred, it's not yours anymore, it's the itav's now.
  • OSSL_CMP_ITAV_get0_type() β€” hands you back a direct pointer to the infoType inside the itav. no copy, just vibes and addresses.
  • OSSL_CMP_ITAV_get0_value() β€” same deal but for the infoValue, returned as a generic ASN1_TYPE pointer. πŸ“Ž
  • OSSL_CMP_ITAV_push0_stack_item() β€” pushes itav onto the stack that *itav_sk_p points to. and if *itav_sk_p is pointing at NULL? it will just create a whole new stack for you. self-sufficient. main character energy fr. 🫢
  • OSSL_CMP_ITAV_new0_certProfile() β€” creates a fresh OSSL_CMP_ITAV structure of type certProfile that includes the optionally given list of profile names. and on success, ownership of the list belongs to the new OSSL_CMP_ITAV structure. she takes custody. periodt.
  • OSSL_CMP_ITAV_get0_certProfile() β€” on success, assigns to *out an internal pointer to the list of certificate profile names contained in the infoValue field of itav. heads up: that pointer may be NULL if no profile name is included. also, it is an error if the infoType of itav is not certProfile. like, wrong type? not today. πŸ’€

πŸ¦‹ NOTES πŸ¦‹

CMP is defined in RFC 9810. we said it once, we'll say it again, consistency is a love language. πŸ’–

OIDs to use as types in OSSL_CMP_ITAV can be found at <https://datatracker.ietf.org/doc/html/rfc9480#section-4.2.2>. bookmark it, bestie. πŸ”–

and the respective OpenSSL NIDs β€” such as NID_id_it_certProfile β€” are defined in the <openssl/obj_mac.h> header file. iykyk. 🌈


πŸ’… RETURN VALUES πŸ’…

  • OSSL_CMP_ITAV_create() and OSSL_CMP_ITAV_new0_certProfile() β€” return a pointer to an ITAV structure on success, or NULL on error. we love a pointer, we hate a NULL. 😭
  • OSSL_CMP_ITAV_set0() β€” does not return a value. she's a void girlie, she gives nothing back and that's fine.
  • OSSL_CMP_ITAV_get0_type() and OSSL_CMP_ITAV_get0_value() β€” return the respective pointer, or NULL if their input is NULL. garbage in, NULL out, fair.
  • OSSL_CMP_ITAV_push0_stack_item() and OSSL_CMP_ITAV_get0_certProfile() β€” return 1 on success, 0 on error. classic. binary baddies. πŸ”₯

⭐ EXAMPLES ⭐

okay so here's the whole scenario: this code creates and sets a structure representing a generic InfoTypeAndValue sequence, using an OID created from text as the type, and an integer as the value. and then afterwards, it's pushed to the OSSL_CMP_CTX so it can be included later in the requests' PKIHeader's genInfo field. full pipeline. ate. πŸ‘‘

ASN1_OBJECT *type = OBJ_txt2obj("1.2.3.4.5", 1);
if (type == NULL) ...

ASN1_INTEGER *asn1int = ASN1_INTEGER_new();
if (asn1int == NULL || !ASN1_INTEGER_set(asn1int, 12345)) ...

ASN1_TYPE *val = ASN1_TYPE_new();
if (val == NULL) ...
ASN1_TYPE_set(val, V_ASN1_INTEGER, asn1int);

OSSL_CMP_ITAV *itav = OSSL_CMP_ITAV_create(type, val);
if (itav == NULL) ...

if (!OSSL_CMP_CTX_push0_geninfo_ITAV(ctx, itav)) {
    OSSL_CMP_ITAV_free(itav); /* also frees type and val */
    ...
}

...

OSSL_CMP_CTX_free(ctx); /* also frees itav */

note the little comments in there bestie β€” those free() calls are doing double duty, OSSL_CMP_ITAV_free() also frees type and val, and OSSL_CMP_CTX_free() also frees itav. that's the ownership transfer in action, exactly like we said earlier. look at us connecting the dots. 🧚


🌈 SEE ALSO 🌈

go read these next, they're all in the same friend group: OSSL_CMP_CTX_new(3), OSSL_CMP_CTX_free(3), ASN1_TYPE_set(3). 🫢


πŸ’œ HISTORY πŸ’œ

  • the OpenSSL CMP support was added in OpenSSL 3.0.
  • OSSL_CMP_ITAV_new0_certProfile() and OSSL_CMP_ITAV_get0_certProfile() were added in OpenSSL 3.3.

so the certProfile girlies are the newer additions to the group chat. welcome, we're so glad you're here. 🌸


Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page bestie, no cap, every single detail preserved, nothing skipped, we did it. πŸŽ€

this was page 4.0.3, dated 2026-09-29, from the OpenSSL manual, section 3SSL. mwah. πŸ’‹
πŸ“¦ where this page comes from