OSSL_CALLBACK(3ossl)

✨ OSSL_CALLBACK ✨

okay so bestie, welcome to the 3ossl manual page for OSSL_CALLBACK πŸ’– this is your little guide to the two callback types that live in OpenSSL's core headers, and yes, they're lowkey iconic.


🌸 SYNOPSIS 🌸

no cap, here's the exact shape of it:

#include <openssl/core.h>
typedef int (OSSL_CALLBACK)(const OSSL_PARAM params[], void *arg);
typedef int (OSSL_PASSPHRASE_CALLBACK)(char *pass, size_t pass_size,
                                       size_t *pass_len,
                                       const OSSL_PARAM params[],
                                       void *arg);

πŸ’… DESCRIPTION πŸ’…

so here's the vibe: for certain events or activities, provider functionality might need a lil assist from the application β€” or from the calling OpenSSL libraries themselves. like, user input? direct (possibly optional) user output? yeah, that kind of thing can be implemented this way. it's giving "hey bestie, can you handle this for me" 🫢

the callback functions themselves are always provided by or through the calling OpenSSL libraries, along with a generic pointer to data called arg. and here's the thing: as far as the function receiving the pointer to the function pointer and arg is concerned, the data that arg points at is opaque. so don't go poking around in there πŸ’€ just pass that pointer right back to the callback function when it gets called. periodt.

πŸ‘‘ OSSL_CALLBACK

this one is the generic callback function. when you call it, the caller is expected to build an OSSL_PARAM(3) array of data it wants or is expected to pass back, and pass that as params β€” plus the opaque data pointer it received, as arg. slay.

πŸ”₯ OSSL_PASSPHRASE_CALLBACK

this one's the specialised callback function, used specifically to prompt the user for a passphrase. when you call it, a buffer to store the pass phrase needs to be given with pass, and its size with pass_size. the length of the prompted pass phrase will be given back in *pass_len.

additional parameters can be passed with the OSSL_PARAM(3) array params.


⭐ RETURN VALUES ⭐

functions of type OSSL_CALLBACK and OSSL_PASSPHRASE_CALLBACK must return 1 on success and 0 on failure. that's it, that's the rule, no in-between 🌈


πŸ¦‹ SEE ALSO πŸ¦‹


πŸŽ€ HISTORY πŸŽ€

the types described here were added in OpenSSL 3.0. so they're not ancient, they're just well-established πŸ’œ


Copyright 2022-2025 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>.

ok so real talk β€” the license stuff is not optional, bestie. read it, respect it, don't be weird about it πŸ™ˆ

and that's the whole page! this was OpenSSL 3.5.9, dated 2026-09-29, and honestly? she ate. go forth and callback responsibly πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from