BIO_GET_EX_NEW_INDEX(3ossl)
πΈ BIO_GET_EX_NEW_INDEX β the OpenSSL 3ossl glow-up πΈ
okay so bestie, you know how basically every big OpenSSL struct has a little secret pocket where you can stash your own stuff? yeah. this whole page is about that pocket. it's from the 3ossl manual, it's iconic, and by the end you're gonna know it by heart. let's go π
β¨ NAME β¨
application-specific data β that's the whole vibe. and here's every single function that lives on this page, grouped by the datatype they belong to so your brain doesn't explode:
BIO_get_ex_new_index,BIO_set_ex_data,BIO_get_ex_data,BIO_set_app_data,BIO_get_app_dataDH_get_ex_new_index,DH_set_ex_data,DH_get_ex_dataDSA_get_ex_new_index,DSA_set_ex_data,DSA_get_ex_dataEC_KEY_get_ex_new_index,EC_KEY_set_ex_data,EC_KEY_get_ex_dataENGINE_get_ex_new_index,ENGINE_set_ex_data,ENGINE_get_ex_dataEVP_PKEY_get_ex_new_index,EVP_PKEY_set_ex_data,EVP_PKEY_get_ex_dataRSA_get_ex_new_index,RSA_set_ex_data,RSA_get_ex_data,RSA_set_app_data,RSA_get_app_dataSSL_get_ex_new_index,SSL_set_ex_data,SSL_get_ex_data,SSL_set_app_data,SSL_get_app_dataSSL_CTX_get_ex_new_index,SSL_CTX_set_ex_data,SSL_CTX_get_ex_data,SSL_CTX_set_app_data,SSL_CTX_get_app_dataSSL_SESSION_get_ex_new_index,SSL_SESSION_set_ex_data,SSL_SESSION_get_ex_data,SSL_SESSION_set_app_data,SSL_SESSION_get_app_dataUI_get_ex_new_index,UI_set_ex_data,UI_get_ex_data,UI_set_app_data,UI_get_app_dataX509_STORE_CTX_get_ex_new_index,X509_STORE_CTX_set_ex_data,X509_STORE_CTX_get_ex_data,X509_STORE_CTX_set_app_data,X509_STORE_CTX_get_app_dataX509_STORE_get_ex_new_index,X509_STORE_set_ex_data,X509_STORE_get_ex_dataX509_get_ex_new_index,X509_set_ex_data,X509_get_ex_data
okay yes that was a lot. drink some water. you ate that. π«Ά
π¦ SYNOPSIS π¦
so the header you gotta pull in is this one, bestie:
#include <openssl/x509.h>
and here's the generic shape β TYPE is a placeholder, obviously, not a real type, do not come for me:
int TYPE_get_ex_new_index(long argl, void *argp,
CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func,
CRYPTO_EX_free *free_func);
int TYPE_set_ex_data(TYPE *d, int idx, void *arg);
void *TYPE_get_ex_data(const TYPE *d, int idx);
#define TYPE_set_app_data(TYPE *d, void *arg)
#define TYPE_get_app_data(TYPE *d)
β οΈ heads up: the following functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by definingOPENSSL_API_COMPATwith a suitable version value, seeopenssl_user_macros(7):
int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int DH_set_ex_data(DH *type, int idx, void *arg);
void *DH_get_ex_data(DH *type, int idx);
int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int DSA_set_ex_data(DSA *type, int idx, void *arg);
void *DSA_get_ex_data(DSA *type, int idx);
int EC_KEY_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int EC_KEY_set_ex_data(EC_KEY *type, int idx, void *arg);
void *EC_KEY_get_ex_data(EC_KEY *type, int idx);
int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int RSA_set_ex_data(RSA *type, int idx, void *arg);
void *RSA_get_ex_data(RSA *type, int idx);
int RSA_set_app_data(RSA *type, void *arg);
void *RSA_get_app_data(RSA *type);
int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int ENGINE_set_ex_data(ENGINE *type, int idx, void *arg);
void *ENGINE_get_ex_data(ENGINE *type, int idx);
π DESCRIPTION π
okay so throughout this whole page, TYPE is a placeholder for any of the OpenSSL datatypes listed in CRYPTO_get_ex_new_index(3). it's giving "insert your fave type here." π
the deprecated girlies, part one: all functions with a TYPE of DH, DSA, RSA and EC_KEY are deprecated. like, retired. applications should instead use EVP_PKEY_set_ex_data(), EVP_PKEY_get_ex_data() and EVP_PKEY_get_ex_new_index(). that's the upgrade path, no cap.
the deprecated girlies, part two: all functions with a TYPE of ENGINE are deprecated too. applications using engines should be replaced by providers. not me telling you your whole architecture needs a glow-up π but like... it does.
so what do these functions actually do? they handle application-specific data for OpenSSL data structures. your stuff, in their struct. matching outfits but separate closets. β¨
TYPE_get_ex_new_index()β this is a macro that callsCRYPTO_get_ex_new_index()with the correct index value. it's the bouncer handing out your very own index number.TYPE_set_ex_data()β this is a function that callsCRYPTO_set_ex_data()with an offset into the opaque exdata part of theTYPEobject. and listen:dMUST NOT beNULL. i'm serious. do not do that.TYPE_get_ex_data()β this is a function that callsCRYPTO_get_ex_data()with an offset into the opaque exdata part of theTYPEobject. and again,dMUST NOT beNULL. same rule, same energy, do not test it. π
the app data shortcut β for compatibility with previous releases, the exdata index of zero is reserved for "application data." there are two convenience functions for this, and honestly they're the ones you'll actually use:
TYPE_set_app_data()β a macro that invokesTYPE_set_ex_data()withidxset to zero. so you don't gotta remember the zero. she remembers for you. πTYPE_get_app_data()β a macro that invokesTYPE_get_ex_data()withidxset to zero. same deal, other direction.
π RETURN VALUES π
TYPE_get_ex_new_index()β returns a new index on success, or-1on error. bestie got a whole new index, slay. if it's-1, something went wrong.TYPE_set_ex_data()β returns1on success or0on error.TYPE_get_ex_data()β returns the application data, orNULLif an error occurred.
π«Ά psst:NULLback fromTYPE_get_ex_data()means an error happened β don't just assume the data was empty, okay? read the room.
π SEE ALSO π
CRYPTO_get_ex_new_index(3)β the parent function, the main character. go read it next, iykyk.
π¦ HISTORY π¦
the following functions were deprecated in OpenSSL 3.0, and yes i'm listing every single one because i don't skip:
DH_get_ex_new_index(), DH_set_ex_data(), DH_get_ex_data(), DSA_get_ex_new_index(), DSA_set_ex_data(), DSA_get_ex_data(), EC_KEY_get_ex_new_index(), EC_KEY_set_ex_data(), EC_KEY_get_ex_data(), ENGINE_get_ex_new_index(), ENGINE_set_ex_data(), ENGINE_get_ex_data(), RSA_get_ex_new_index(), RSA_set_ex_data(), RSA_get_ex_data(), RSA_set_app_data() and RSA_get_app_data().
rest in peace to those, they served their time. ποΈ
π COPYRIGHT π
Copyright 2015-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 page, bestie!! π this was version 3.5.0, dated 2026-09-25, and it's the BIO_GET_EX_NEW_INDEX(3ossl) page β go forth and stash your app data responsibly. mwah. π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms