xref: /freebsd/crypto/openssl/doc/man3/EVP_PKEY_todata.pod (revision 24e4dcf4ba5e9dedcf89efd358ea3e1fe5867020)
1=pod
2
3=head1 NAME
4
5EVP_PKEY_todata, EVP_PKEY_export
6- functions to return keys as an array of key parameters
7
8=head1 SYNOPSIS
9
10 #include <openssl/evp.h>
11
12 int EVP_PKEY_todata(const EVP_PKEY *pkey, int selection, OSSL_PARAM **params);
13 int EVP_PKEY_export(const EVP_PKEY *pkey, int selection,
14                     OSSL_CALLBACK *export_cb, void *export_cbarg);
15
16=head1 DESCRIPTION
17
18The functions described here are used to extract B<EVP_PKEY> key values as an
19array of L<OSSL_PARAM(3)>.
20
21EVP_PKEY_todata() extracts values from a key I<pkey> using the I<selection>.
22I<selection> is described in L<EVP_PKEY_fromdata(3)/Selections>.
23L<OSSL_PARAM_free(3)> should be used to free the returned parameters in
24I<*params>.
25
26EVP_PKEY_export() is similar to EVP_PKEY_todata() but uses a callback
27I<export_cb> that gets passed the value of I<export_cbarg>.
28See L<openssl-core.h(7)> for more information about the callback. Note that the
29L<OSSL_PARAM(3)> array that is passed to the callback is not persistent after the
30callback returns. The user must preserve the items of interest, or use
31EVP_PKEY_todata() if persistence is required.
32
33=head1 NOTES
34
35These functions only work with key management methods coming from a provider.
36This is the mirror function to L<EVP_PKEY_fromdata(3)>.
37
38=head1 RETURN VALUES
39
40EVP_PKEY_todata() and EVP_PKEY_export() return 1 for success and 0 for failure.
41
42=head1 SEE ALSO
43
44L<OSSL_PARAM(3)>,
45L<openssl-core.h(7)>,
46L<EVP_PKEY_fromdata(3)>,
47L<EVP_PKEY-RSA(7)>,
48L<EVP_PKEY-EC(7)>,
49L<EVP_PKEY-DSA(7)>,
50L<EVP_PKEY-ED25519(7)>
51L<EVP_PKEY-ED448(7)>,
52L<EVP_PKEY-DH(7)>,
53L<EVP_PKEY-X25519(7)>,
54L<EVP_PKEY-X448(7)>,
55L<EVP_PKEY-ML-DSA(7)>,
56L<EVP_PKEY-ML-KEM(7)>,
57L<EVP_PKEY-SLH-DSA(7)>.
58
59=head1 HISTORY
60
61These functions were added in OpenSSL 3.0.
62
63Support for B<ML-DSA>, B<ML-KEM> and B<SLH-DSA> was added in OpenSSL 3.5.
64
65=head1 COPYRIGHT
66
67Copyright 2021-2025 The OpenSSL Project Authors. All Rights Reserved.
68
69Licensed under the Apache License 2.0 (the "License").  You may not use
70this file except in compliance with the License.  You can obtain a copy
71in the file LICENSE in the source distribution or at
72L<https://www.openssl.org/source/license.html>.
73
74=cut
75
76