OSSL_CALLBACK(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’… OSSL_CALLBACK β€” the OpenSSL core types that define callbacks (yes bestie, this is 3ossl, the OpenSSL manual) πŸŽ€

🌸 NAME 🌸

okay so <pink>OSSL_CALLBACK</pink> and <pink>OSSL_PASSPHRASE_CALLBACK</pink> β€” these are the OpenSSL Core type definitions for callbacks. That's the whole vibe. πŸ’–


✨ SYNOPSIS ✨

#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 tea β˜• β€” sometimes, for certain events or activities, provider functionality lowkey needs a little help from the application, or from the calling OpenSSL libraries themselves. Like, for example, user input or direct (possibly optional) user output could be implemented this way. It's giving collaboration. 🫢

The callback functions themselves are always provided by or through the calling OpenSSL libraries, along with a generic pointer to data β€” that's arg. And here's the important part, bestie: 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 just pass that pointer right back to the callback function when it gets called. No peeking. No cap.

πŸ’œ OSSL_CALLBACK

This one is the generic callback function, the main character of the two. ✨ When you call it, the caller is expected to build an OSSL_PARAM(3) array of the data it wants or is expected to pass back, and pass that as params β€” plus the opaque data pointer it received, as arg. That's it, that's the whole assignment. πŸŽ€

🌈 OSSL_PASSPHRASE_CALLBACK

This one is the specialised callback function, used specifically to prompt the user for a passphrase πŸ”. When you call it, you gotta hand over a buffer to store the pass phrase with pass, and its size with pass_size. Then the length of the prompted pass phrase gets given back to you in *pass_len. Iconic. πŸ’…

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 the vibe check β€” 1 slays, 0 does not. βœ…πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

go read it, iykyk πŸ“–βœ¨


⭐ HISTORY ⭐

The types described here were added in OpenSSL 3.0. A little throwback moment for the timeline πŸ•°οΈπŸ’–


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>.

fr fr read the license before you go wild with it πŸ™

okay bye bestie, this page was brought to you by version 3.5.6, dated 2026-04-07 β€” OSSL_CALLBACK(3ossl), that's a wrap, mwah πŸ’‹πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from