xref: /freebsd/crypto/openssl/doc/man3/OSSL_CALLBACK.pod (revision 24e4dcf4ba5e9dedcf89efd358ea3e1fe5867020)
1=pod
2
3=head1 NAME
4
5OSSL_CALLBACK, OSSL_PASSPHRASE_CALLBACK - OpenSSL Core type to define callbacks
6
7=head1 SYNOPSIS
8
9 #include <openssl/core.h>
10 typedef int (OSSL_CALLBACK)(const OSSL_PARAM params[], void *arg);
11 typedef int (OSSL_PASSPHRASE_CALLBACK)(char *pass, size_t pass_size,
12                                        size_t *pass_len,
13                                        const OSSL_PARAM params[],
14                                        void *arg);
15
16=head1 DESCRIPTION
17
18For certain events or activities, provider functionality may need help from
19the application or the calling OpenSSL libraries themselves.  For example,
20user input or direct (possibly optional) user output could be implemented
21this way.
22
23Callback functions themselves are always provided by or through the calling
24OpenSSL libraries, along with a generic pointer to data I<arg>.  As far as
25the function receiving the pointer to the function pointer and I<arg> is
26concerned, the data that I<arg> points at is opaque, and the pointer should
27simply be passed back to the callback function when it's called.
28
29=over 4
30
31=item B<OSSL_CALLBACK>
32
33This is a generic callback function.  When calling this callback function,
34the caller is expected to build an L<OSSL_PARAM(3)> array of data it wants or
35is expected to pass back, and pass that as I<params>, as well as the opaque
36data pointer it received, as I<arg>.
37
38=item B<OSSL_PASSPHRASE_CALLBACK>
39
40This is a specialised callback function, used specifically to prompt the
41user for a passphrase.  When calling this callback function, a buffer to
42store the pass phrase needs to be given with I<pass>, and its size with
43I<pass_size>.  The length of the prompted pass phrase will be given back in
44I<*pass_len>.
45
46Additional parameters can be passed with the L<OSSL_PARAM(3)> array I<params>,
47
48=back
49
50=head1 RETURN VALUES
51
52Functions of type B<OSSL_CALLBACK> and B<OSSL_PASSPHRASE_CALLBACK>
53must return 1 on success and 0 on failure.
54
55=head1 SEE ALSO
56
57L<openssl-core.h(7)>
58
59=head1 HISTORY
60
61The types described here were added in OpenSSL 3.0.
62
63=head1 COPYRIGHT
64
65Copyright 2022-2025 The OpenSSL Project Authors. All Rights Reserved.
66
67Licensed under the Apache License 2.0 (the "License").  You may not use
68this file except in compliance with the License.  You can obtain a copy
69in the file LICENSE in the source distribution or at
70L<https://www.openssl.org/source/license.html>.
71
72=cut
73