xref: /freebsd/crypto/openssl/doc/man3/OSSL_CALLBACK.pod (revision 9f23cbd6cae82fd77edfad7173432fa8dccd0a95)
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=begin comment RETURN VALUES doesn't make sense for a manual that only
51describes a type, but document checkers still want that section, and
52to have more than just the section title.
53
54=head1 RETURN VALUES
55
56txt
57
58=end comment
59
60=head1 SEE ALSO
61
62L<openssl-core.h(7)>
63
64=head1 HISTORY
65
66The types described here were added in OpenSSL 3.0.
67
68=head1 COPYRIGHT
69
70Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
71
72Licensed under the Apache License 2.0 (the "License").  You may not use
73this file except in compliance with the License.  You can obtain a copy
74in the file LICENSE in the source distribution or at
75L<https://www.openssl.org/source/license.html>.
76
77=cut
78