5 EVP_PKEY_CTX_new, EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_new_from_name,
6 EVP_PKEY_CTX_new_from_pkey, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free
7 - public key algorithm context functions
11 #include <openssl/evp.h>
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);
15 EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OPENSSL_CTX *libctx,
17 const char *propquery);
18 EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OPENSSL_CTX *libctx,
20 const char *propquery);
21 EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx);
22 void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
26 The EVP_PKEY_CTX_new() function allocates public key algorithm context using
27 the I<pkey> key type and ENGINE I<e>.
29 The EVP_PKEY_CTX_new_id() function allocates public key algorithm context
30 using the key type specified by I<id> and ENGINE I<e>.
32 The EVP_PKEY_CTX_new_from_name() function allocates a public key algorithm
33 context using the library context I<libctx> (see L<OPENSSL_CTX(3)>), the
34 key type specified by I<name> and the property query I<propquery>. None
35 of the arguments are duplicated, so they must remain unchanged for the
36 lifetime of the returned B<EVP_PKEY_CTX> or of any of its duplicates. Read
37 further about the possible names in L</NOTES> below.
39 The EVP_PKEY_CTX_new_from_pkey() function allocates a public key algorithm
40 context using the library context I<libctx> (see L<OPENSSL_CTX(3)>) and the
41 algorithm specified by I<pkey> and the property query I<propquery>. None of the
42 arguments are duplicated, so they must remain unchanged for the lifetime of the
43 returned B<EVP_PKEY_CTX> or any of its duplicates.
45 EVP_PKEY_CTX_new_id() and EVP_PKEY_CTX_new_from_name() are normally
46 used when no B<EVP_PKEY> structure is associated with the operations,
47 for example during parameter generation or key generation for some
50 EVP_PKEY_CTX_dup() duplicates the context I<ctx>.
52 EVP_PKEY_CTX_free() frees up the context I<ctx>.
53 If I<ctx> is NULL, nothing is done.
57 =head2 On B<EVP_PKEY_CTX>
59 The B<EVP_PKEY_CTX> structure is an opaque public key algorithm context used
60 by the OpenSSL high-level public key API. Contexts B<MUST NOT> be shared between
61 threads: that is it is not permissible to use the same context simultaneously
66 We mention "key type" in this manual, which is the same
67 as "algorithm" in most cases, allowing either term to be used
68 interchangeably. There are algorithms where the I<key type> and the
69 I<algorithm> of the operations that use the keys are not the same,
70 such as EC keys being used for ECDSA and ECDH operations.
72 Key types are given in two different manners:
76 =item Legacy NID or EVP_PKEY type
78 This is the I<id> used with EVP_PKEY_CTX_new_id().
80 These are B<EVP_PKEY_RSA>, B<EVP_PKEY_RSA_PSS>, B<EVP_PKEY_DSA>,
81 B<EVP_PKEY_DH>, B<EVP_PKEY_EC>, B<EVP_PKEY_SM2>, B<EVP_PKEY_X25519>,
82 B<EVP_PKEY_X448>, and are used by legacy methods.
86 This is the I<name> used with EVP_PKEY_CTX_new_from_name().
88 These are names like "RSA", "DSA", and what's available depends on what
89 providers are currently accessible.
91 The OpenSSL providers offer a set of key types available this way, please
92 see L<OSSL_PROVIDER-FIPS(7)> and L<OSSL_PROVIDER-default(7)> and related
93 documentation for more information.
99 EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id(), EVP_PKEY_CTX_dup() returns either
100 the newly allocated B<EVP_PKEY_CTX> structure or B<NULL> if an error occurred.
102 EVP_PKEY_CTX_free() does not return a value.
110 The EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id(), EVP_PKEY_CTX_dup() and
111 EVP_PKEY_CTX_free() functions were added in OpenSSL 1.0.0.
113 The EVP_PKEY_CTX_new_from_name() and EVP_PKEY_CTX_new_from_pkey() functions were
114 added in OpenSSL 3.0.
118 Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
120 Licensed under the Apache License 2.0 (the "License"). You may not use
121 this file except in compliance with the License. You can obtain a copy
122 in the file LICENSE in the source distribution or at
123 L<https://www.openssl.org/source/license.html>.