xref: /freebsd/crypto/openssl/doc/man3/EVP_KEM_free.pod (revision 9f23cbd6cae82fd77edfad7173432fa8dccd0a95)
1=pod
2
3=head1 NAME
4
5EVP_KEM_fetch, EVP_KEM_free, EVP_KEM_up_ref,
6EVP_KEM_get0_name, EVP_KEM_is_a, EVP_KEM_get0_provider,
7EVP_KEM_do_all_provided, EVP_KEM_names_do_all, EVP_KEM_get0_description,
8EVP_KEM_gettable_ctx_params, EVP_KEM_settable_ctx_params
9- Functions to manage EVP_KEM algorithm objects
10
11=head1 SYNOPSIS
12
13 #include <openssl/evp.h>
14
15 EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
16                        const char *properties);
17 void EVP_KEM_free(EVP_KEM *kem);
18 int EVP_KEM_up_ref(EVP_KEM *kem);
19 const char *EVP_KEM_get0_name(const EVP_KEM *kem);
20 int EVP_KEM_is_a(const EVP_KEM *kem, const char *name);
21 OSSL_PROVIDER *EVP_KEM_get0_provider(const EVP_KEM *kem);
22 void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx,
23                              void (*fn)(EVP_KEM *kem, void *arg), void *arg);
24 int EVP_KEM_names_do_all(const EVP_KEM *kem,
25                          void (*fn)(const char *name, void *data), void *data);
26 const char *EVP_KEM_get0_description(const EVP_KEM *kem);
27 const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem);
28 const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem);
29
30=head1 DESCRIPTION
31
32EVP_KEM_fetch() fetches the implementation for the given B<algorithm> from any
33provider offering it, within the criteria given by the B<properties> and in the
34scope of the given library context B<ctx> (see L<OSSL_LIB_CTX(3)>). The algorithm
35will be one offering functions for performing asymmetric kem related tasks such
36as key encapsulation and decapsulation.
37See L<crypto(7)/ALGORITHM FETCHING> for further information.
38
39The returned value must eventually be freed with EVP_KEM_free().
40
41EVP_KEM_free() decrements the reference count for the B<EVP_KEM> structure.
42Typically this structure will have been obtained from an earlier call to
43EVP_KEM_fetch(). If the reference count drops to 0 then the structure is freed.
44
45EVP_KEM_up_ref() increments the reference count for an B<EVP_KEM> structure.
46
47EVP_KEM_is_a() returns 1 if I<kem> is an implementation of an
48algorithm that's identifiable with I<name>, otherwise 0.
49
50EVP_KEM_get0_provider() returns the provider that I<kem> was fetched from.
51
52EVP_KEM_do_all_provided() traverses all EVP_KEMs implemented by all activated
53providers in the given library context I<libctx>, and for each of the
54implementations, calls the given function I<fn> with the implementation method
55and the given I<arg> as argument.
56
57EVP_KEM_get0_name() returns the algorithm name from the provided
58implementation for the given I<kem>. Note that the I<kem> may have
59multiple synonyms associated with it. In this case the first name from the
60algorithm definition is returned. Ownership of the returned string is retained
61by the I<kem> object and should not be freed by the caller.
62
63EVP_KEM_names_do_all() traverses all names for I<kem>, and calls I<fn> with
64each name and I<data>.
65
66EVP_KEM_get0_description() returns a description of the I<kem>, meant for
67display and human consumption.  The description is at the discretion of
68the I<kem> implementation.
69
70EVP_KEM_gettable_ctx_params() and EVP_KEM_settable_ctx_params() return
71a constant L<OSSL_PARAM(3)> array that describes the names and types of key
72parameters that can be retrieved or set by a key encapsulation algorithm using
73L<EVP_PKEY_CTX_get_params(3)> and L<EVP_PKEY_CTX_set_params(3)>.
74
75=head1 RETURN VALUES
76
77EVP_KEM_fetch() returns a pointer to an B<EVP_KEM> for success or B<NULL> for
78failure.
79
80EVP_KEM_up_ref() returns 1 for success or 0 otherwise.
81
82EVP_KEM_names_do_all() returns 1 if the callback was called for all names. A
83return value of 0 means that the callback was not called for any names.
84
85EVP_KEM_gettable_ctx_params() and EVP_KEM_settable_ctx_params() return
86a constant L<OSSL_PARAM(3)> array or NULL on error.
87
88=head1 SEE ALSO
89
90L<crypto(7)/ALGORITHM FETCHING>, L<OSSL_PROVIDER(3)>
91
92=head1 HISTORY
93
94The functions described here were added in OpenSSL 3.0.
95
96=head1 COPYRIGHT
97
98Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
99
100Licensed under the Apache License 2.0 (the "License").  You may not use
101this file except in compliance with the License.  You can obtain a copy
102in the file LICENSE in the source distribution or at
103L<https://www.openssl.org/source/license.html>.
104
105=cut
106