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