| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "EVP_PKEY_CTX_NEW 3SSL" |
| 58 |
.TH EVP_PKEY_CTX_NEW 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
EVP_PKEY_CTX_new, EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_new_from_name, |
| 65 |
EVP_PKEY_CTX_new_from_pkey, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free, |
| 66 |
EVP_PKEY_CTX_is_a |
| 67 |
\&\- public key algorithm context functions |
| 68 |
.SH SYNOPSIS |
| 69 |
.IX Header "SYNOPSIS" |
| 70 |
.Vb 1 |
| 71 |
\& #include <openssl/evp.h> |
| 72 |
\& |
| 73 |
\& EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); |
| 74 |
\& EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); |
| 75 |
\& EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx, |
| 76 |
\& const char *name, |
| 77 |
\& const char *propquery); |
| 78 |
\& EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx, |
| 79 |
\& EVP_PKEY *pkey, |
| 80 |
\& const char *propquery); |
| 81 |
\& EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx); |
| 82 |
\& void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx); |
| 83 |
\& int EVP_PKEY_CTX_is_a(EVP_PKEY_CTX *ctx, const char *keytype); |
| 84 |
.Ve |
| 85 |
.SH DESCRIPTION |
| 86 |
.IX Header "DESCRIPTION" |
| 87 |
The \fBEVP_PKEY_CTX_new()\fR function allocates public key algorithm context using |
| 88 |
the \fIpkey\fR key type and ENGINE \fIe\fR. |
| 89 |
.PP |
| 90 |
The \fBEVP_PKEY_CTX_new_id()\fR function allocates public key algorithm context |
| 91 |
using the key type specified by \fIid\fR and ENGINE \fIe\fR. |
| 92 |
.PP |
| 93 |
The \fBEVP_PKEY_CTX_new_from_name()\fR function allocates a public key algorithm |
| 94 |
context using the library context \fIlibctx\fR (see \fBOSSL_LIB_CTX\fR\|(3)), the |
| 95 |
key type specified by \fIname\fR and the property query \fIpropquery\fR. None |
| 96 |
of the arguments are duplicated, so they must remain unchanged for the |
| 97 |
lifetime of the returned \fBEVP_PKEY_CTX\fR or of any of its duplicates. Read |
| 98 |
further about the possible names in "NOTES" below. |
| 99 |
.PP |
| 100 |
The \fBEVP_PKEY_CTX_new_from_pkey()\fR function allocates a public key algorithm |
| 101 |
context using the library context \fIlibctx\fR (see \fBOSSL_LIB_CTX\fR\|(3)) and the |
| 102 |
algorithm specified by \fIpkey\fR and the property query \fIpropquery\fR. None of the |
| 103 |
arguments are duplicated, so they must remain unchanged for the lifetime of the |
| 104 |
returned \fBEVP_PKEY_CTX\fR or any of its duplicates. |
| 105 |
.PP |
| 106 |
\&\fBEVP_PKEY_CTX_new_id()\fR and \fBEVP_PKEY_CTX_new_from_name()\fR are normally |
| 107 |
used when no \fBEVP_PKEY\fR structure is associated with the operations, |
| 108 |
for example during parameter generation or key generation for some |
| 109 |
algorithms. |
| 110 |
.PP |
| 111 |
\&\fBEVP_PKEY_CTX_dup()\fR duplicates the context \fIctx\fR. |
| 112 |
It is not supported for a keygen operation. |
| 113 |
It is however possible to duplicate a context freshly created via any of the |
| 114 |
above \f(CW\*(C`new\*(C'\fR functions, provided \fBEVP_PKEY_keygen_init\fR\|(3) has not yet been |
| 115 |
called on the source context, and then use the copy for key generation. |
| 116 |
.PP |
| 117 |
\&\fBEVP_PKEY_CTX_free()\fR frees up the context \fIctx\fR. |
| 118 |
If \fIctx\fR is NULL, nothing is done. |
| 119 |
.PP |
| 120 |
\&\fBEVP_PKEY_is_a()\fR checks if the key type associated with \fIctx\fR is \fIkeytype\fR. |
| 121 |
.SH NOTES |
| 122 |
.IX Header "NOTES" |
| 123 |
.SS "On \fBEVP_PKEY_CTX\fP" |
| 124 |
.IX Subsection "On EVP_PKEY_CTX" |
| 125 |
The \fBEVP_PKEY_CTX\fR structure is an opaque public key algorithm context used |
| 126 |
by the OpenSSL high-level public key API. Contexts \fBMUST NOT\fR be shared between |
| 127 |
threads: that is it is not permissible to use the same context simultaneously |
| 128 |
in two threads. |
| 129 |
.SS "On Key Types" |
| 130 |
.IX Subsection "On Key Types" |
| 131 |
We mention "key type" in this manual, which is the same |
| 132 |
as "algorithm" in most cases, allowing either term to be used |
| 133 |
interchangeably. There are algorithms where the \fIkey type\fR and the |
| 134 |
\&\fIalgorithm\fR of the operations that use the keys are not the same, |
| 135 |
such as EC keys being used for ECDSA and ECDH operations. |
| 136 |
.PP |
| 137 |
Key types are given in two different manners: |
| 138 |
.IP "Legacy NID or EVP_PKEY type" 4 |
| 139 |
.IX Item "Legacy NID or EVP_PKEY type" |
| 140 |
This is the \fIid\fR used with \fBEVP_PKEY_CTX_new_id()\fR. |
| 141 |
.Sp |
| 142 |
These are \fBEVP_PKEY_RSA\fR, \fBEVP_PKEY_RSA_PSS\fR, \fBEVP_PKEY_DSA\fR, |
| 143 |
\&\fBEVP_PKEY_DH\fR, \fBEVP_PKEY_EC\fR, \fBEVP_PKEY_SM2\fR, \fBEVP_PKEY_X25519\fR, |
| 144 |
\&\fBEVP_PKEY_X448\fR, and are used by legacy methods. |
| 145 |
.IP "Name strings" 4 |
| 146 |
.IX Item "Name strings" |
| 147 |
This is the \fIname\fR used with \fBEVP_PKEY_CTX_new_from_name()\fR. |
| 148 |
.Sp |
| 149 |
These are names like "RSA", "DSA", and what's available depends on what |
| 150 |
providers are currently accessible. |
| 151 |
.Sp |
| 152 |
The OpenSSL providers offer a set of key types available this way, please |
| 153 |
see \fBOSSL_PROVIDER\-FIPS\fR\|(7) and \fBOSSL_PROVIDER\-default\fR\|(7) and related |
| 154 |
documentation for more information. |
| 155 |
.SH "RETURN VALUES" |
| 156 |
.IX Header "RETURN VALUES" |
| 157 |
\&\fBEVP_PKEY_CTX_new()\fR, \fBEVP_PKEY_CTX_new_id()\fR and \fBEVP_PKEY_CTX_dup()\fR return either |
| 158 |
the newly allocated \fBEVP_PKEY_CTX\fR structure or \fBNULL\fR if an error occurred. |
| 159 |
.PP |
| 160 |
\&\fBEVP_PKEY_CTX_free()\fR does not return a value. |
| 161 |
.PP |
| 162 |
\&\fBEVP_PKEY_CTX_is_a()\fR returns 1 for true and 0 for false. |
| 163 |
.SH "SEE ALSO" |
| 164 |
.IX Header "SEE ALSO" |
| 165 |
\&\fBEVP_PKEY_new\fR\|(3) |
| 166 |
.SH HISTORY |
| 167 |
.IX Header "HISTORY" |
| 168 |
The \fBEVP_PKEY_CTX_new()\fR, \fBEVP_PKEY_CTX_new_id()\fR, \fBEVP_PKEY_CTX_dup()\fR and |
| 169 |
\&\fBEVP_PKEY_CTX_free()\fR functions were added in OpenSSL 1.0.0. |
| 170 |
.PP |
| 171 |
The \fBEVP_PKEY_CTX_new_from_name()\fR and \fBEVP_PKEY_CTX_new_from_pkey()\fR functions were |
| 172 |
added in OpenSSL 3.0. |
| 173 |
.SH COPYRIGHT |
| 174 |
.IX Header "COPYRIGHT" |
| 175 |
Copyright 2006\-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 176 |
.PP |
| 177 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 178 |
this file except in compliance with the License. You can obtain a copy |
| 179 |
in the file LICENSE in the source distribution or at |
| 180 |
<https://www.openssl.org/source/license.html>. |