]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/EVP_PKEY_CTX_new.pod
Rename OPENSSL_CTX prefix to OSSL_LIB_CTX
[thirdparty/openssl.git] / doc / man3 / EVP_PKEY_CTX_new.pod
CommitLineData
5165148f
DSH
1=pod
2
3=head1 NAME
4
e683582b
SL
5EVP_PKEY_CTX_new, EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_new_from_name,
6EVP_PKEY_CTX_new_from_pkey, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free
a07c17ef 7- public key algorithm context functions
5165148f
DSH
8
9=head1 SYNOPSIS
10
11 #include <openssl/evp.h>
12
13 EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
14 EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
b4250010 15 EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx,
e683582b
SL
16 const char *name,
17 const char *propquery);
b4250010 18 EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx,
a64a143f
JB
19 EVP_PKEY *pkey,
20 const char *propquery);
9fdcc21f 21 EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx);
5165148f
DSH
22 void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
23
24=head1 DESCRIPTION
25
26The EVP_PKEY_CTX_new() function allocates public key algorithm context using
f23bc0b7 27the I<pkey> key type and ENGINE I<e>.
5165148f
DSH
28
29The EVP_PKEY_CTX_new_id() function allocates public key algorithm context
f23bc0b7 30using the key type specified by I<id> and ENGINE I<e>.
a07c17ef 31
e683582b 32The EVP_PKEY_CTX_new_from_name() function allocates a public key algorithm
b4250010 33context using the library context I<libctx> (see L<OSSL_LIB_CTX(3)>), the
f23bc0b7 34key type specified by I<name> and the property query I<propquery>. None
3ee348b0 35of the arguments are duplicated, so they must remain unchanged for the
ccb47dbf
RL
36lifetime of the returned B<EVP_PKEY_CTX> or of any of its duplicates. Read
37further about the possible names in L</NOTES> below.
a07c17ef 38
e683582b 39The EVP_PKEY_CTX_new_from_pkey() function allocates a public key algorithm
b4250010 40context using the library context I<libctx> (see L<OSSL_LIB_CTX(3)>) and the
2ee4a50a
MC
41algorithm specified by I<pkey> and the property query I<propquery>. None of the
42arguments are duplicated, so they must remain unchanged for the lifetime of the
43returned B<EVP_PKEY_CTX> or any of its duplicates.
e683582b
SL
44
45EVP_PKEY_CTX_new_id() and EVP_PKEY_CTX_new_from_name() are normally
a07c17ef
RL
46used when no B<EVP_PKEY> structure is associated with the operations,
47for example during parameter generation or key generation for some
48algorithms.
5165148f 49
028687c0 50EVP_PKEY_CTX_dup() duplicates the context I<ctx>.
5165148f 51
028687c0
RL
52EVP_PKEY_CTX_free() frees up the context I<ctx>.
53If I<ctx> is NULL, nothing is done.
5165148f
DSH
54
55=head1 NOTES
56
ccb47dbf 57=head2 On B<EVP_PKEY_CTX>
f23bc0b7 58
5165148f 59The B<EVP_PKEY_CTX> structure is an opaque public key algorithm context used
8c1cbc72 60by the OpenSSL high-level public key API. Contexts B<MUST NOT> be shared between
5165148f
DSH
61threads: that is it is not permissible to use the same context simultaneously
62in two threads.
63
ccb47dbf 64=head2 On Key Types
f23bc0b7
RL
65
66We mention "key type" in this manual, which is the same
67as "algorithm" in most cases, allowing either term to be used
68interchangeably. There are algorithms where the I<key type> and the
69I<algorithm> of the operations that use the keys are not the same,
70such as EC keys being used for ECDSA and ECDH operations.
71
ccb47dbf
RL
72Key types are given in two different manners:
73
74=over 4
75
76=item Legacy NID or EVP_PKEY type
77
78This is the I<id> used with EVP_PKEY_CTX_new_id().
79
80These are B<EVP_PKEY_RSA>, B<EVP_PKEY_RSA_PSS>, B<EVP_PKEY_DSA>,
81B<EVP_PKEY_DH>, B<EVP_PKEY_EC>, B<EVP_PKEY_SM2>, B<EVP_PKEY_X25519>,
82B<EVP_PKEY_X448>, and are used by legacy methods.
83
84=item Name strings
85
86This is the I<name> used with EVP_PKEY_CTX_new_from_name().
87
88These are names like "RSA", "DSA", and what's available depends on what
89providers are currently accessible.
90
91The OpenSSL providers offer a set of key types available this way, please
92see L<OSSL_PROVIDER-FIPS(7)> and L<OSSL_PROVIDER-default(7)> and related
93documentation for more information.
94
f23bc0b7
RL
95=back
96
5165148f
DSH
97=head1 RETURN VALUES
98
99EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id(), EVP_PKEY_CTX_dup() returns either
6926be0b 100the newly allocated B<EVP_PKEY_CTX> structure or B<NULL> if an error occurred.
5165148f
DSH
101
102EVP_PKEY_CTX_free() does not return a value.
103
104=head1 SEE ALSO
105
9b86974e 106L<EVP_PKEY_new(3)>
5165148f
DSH
107
108=head1 HISTORY
109
e683582b
SL
110The EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id(), EVP_PKEY_CTX_dup() and
111EVP_PKEY_CTX_free() functions were added in OpenSSL 1.0.0.
112
113The EVP_PKEY_CTX_new_from_name() and EVP_PKEY_CTX_new_from_pkey() functions were
114added in OpenSSL 3.0.
5165148f 115
e2f92610
RS
116=head1 COPYRIGHT
117
33388b44 118Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
e2f92610 119
4746f25a 120Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
121this file except in compliance with the License. You can obtain a copy
122in the file LICENSE in the source distribution or at
123L<https://www.openssl.org/source/license.html>.
124
125=cut