| 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_CTRL 3SSL" |
| 58 |
.TH EVP_PKEY_CTX_CTRL 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_ctrl, |
| 65 |
EVP_PKEY_CTX_ctrl_str, |
| 66 |
EVP_PKEY_CTX_ctrl_uint64, |
| 67 |
EVP_PKEY_CTX_md, |
| 68 |
EVP_PKEY_CTX_set_signature_md, |
| 69 |
EVP_PKEY_CTX_get_signature_md, |
| 70 |
EVP_PKEY_CTX_set_mac_key, |
| 71 |
EVP_PKEY_CTX_set_group_name, |
| 72 |
EVP_PKEY_CTX_get_group_name, |
| 73 |
EVP_PKEY_CTX_set_rsa_padding, |
| 74 |
EVP_PKEY_CTX_get_rsa_padding, |
| 75 |
EVP_PKEY_CTX_set_rsa_pss_saltlen, |
| 76 |
EVP_PKEY_CTX_get_rsa_pss_saltlen, |
| 77 |
EVP_PKEY_CTX_set_rsa_keygen_bits, |
| 78 |
EVP_PKEY_CTX_set_rsa_keygen_pubexp, |
| 79 |
EVP_PKEY_CTX_set1_rsa_keygen_pubexp, |
| 80 |
EVP_PKEY_CTX_set_rsa_keygen_primes, |
| 81 |
EVP_PKEY_CTX_set_rsa_mgf1_md_name, |
| 82 |
EVP_PKEY_CTX_set_rsa_mgf1_md, |
| 83 |
EVP_PKEY_CTX_get_rsa_mgf1_md, |
| 84 |
EVP_PKEY_CTX_get_rsa_mgf1_md_name, |
| 85 |
EVP_PKEY_CTX_set_rsa_oaep_md_name, |
| 86 |
EVP_PKEY_CTX_set_rsa_oaep_md, |
| 87 |
EVP_PKEY_CTX_get_rsa_oaep_md, |
| 88 |
EVP_PKEY_CTX_get_rsa_oaep_md_name, |
| 89 |
EVP_PKEY_CTX_set0_rsa_oaep_label, |
| 90 |
EVP_PKEY_CTX_get0_rsa_oaep_label, |
| 91 |
EVP_PKEY_CTX_set_dsa_paramgen_bits, |
| 92 |
EVP_PKEY_CTX_set_dsa_paramgen_q_bits, |
| 93 |
EVP_PKEY_CTX_set_dsa_paramgen_md, |
| 94 |
EVP_PKEY_CTX_set_dsa_paramgen_md_props, |
| 95 |
EVP_PKEY_CTX_set_dsa_paramgen_gindex, |
| 96 |
EVP_PKEY_CTX_set_dsa_paramgen_type, |
| 97 |
EVP_PKEY_CTX_set_dsa_paramgen_seed, |
| 98 |
EVP_PKEY_CTX_set_dh_paramgen_prime_len, |
| 99 |
EVP_PKEY_CTX_set_dh_paramgen_subprime_len, |
| 100 |
EVP_PKEY_CTX_set_dh_paramgen_generator, |
| 101 |
EVP_PKEY_CTX_set_dh_paramgen_type, |
| 102 |
EVP_PKEY_CTX_set_dh_paramgen_gindex, |
| 103 |
EVP_PKEY_CTX_set_dh_paramgen_seed, |
| 104 |
EVP_PKEY_CTX_set_dh_rfc5114, |
| 105 |
EVP_PKEY_CTX_set_dhx_rfc5114, |
| 106 |
EVP_PKEY_CTX_set_dh_pad, |
| 107 |
EVP_PKEY_CTX_set_dh_nid, |
| 108 |
EVP_PKEY_CTX_set_dh_kdf_type, |
| 109 |
EVP_PKEY_CTX_get_dh_kdf_type, |
| 110 |
EVP_PKEY_CTX_set0_dh_kdf_oid, |
| 111 |
EVP_PKEY_CTX_get0_dh_kdf_oid, |
| 112 |
EVP_PKEY_CTX_set_dh_kdf_md, |
| 113 |
EVP_PKEY_CTX_get_dh_kdf_md, |
| 114 |
EVP_PKEY_CTX_set_dh_kdf_outlen, |
| 115 |
EVP_PKEY_CTX_get_dh_kdf_outlen, |
| 116 |
EVP_PKEY_CTX_set0_dh_kdf_ukm, |
| 117 |
EVP_PKEY_CTX_get0_dh_kdf_ukm, |
| 118 |
EVP_PKEY_CTX_set_ec_paramgen_curve_nid, |
| 119 |
EVP_PKEY_CTX_set_ec_param_enc, |
| 120 |
EVP_PKEY_CTX_set_ecdh_cofactor_mode, |
| 121 |
EVP_PKEY_CTX_get_ecdh_cofactor_mode, |
| 122 |
EVP_PKEY_CTX_set_ecdh_kdf_type, |
| 123 |
EVP_PKEY_CTX_get_ecdh_kdf_type, |
| 124 |
EVP_PKEY_CTX_set_ecdh_kdf_md, |
| 125 |
EVP_PKEY_CTX_get_ecdh_kdf_md, |
| 126 |
EVP_PKEY_CTX_set_ecdh_kdf_outlen, |
| 127 |
EVP_PKEY_CTX_get_ecdh_kdf_outlen, |
| 128 |
EVP_PKEY_CTX_set0_ecdh_kdf_ukm, |
| 129 |
EVP_PKEY_CTX_get0_ecdh_kdf_ukm, |
| 130 |
EVP_PKEY_CTX_set1_id, EVP_PKEY_CTX_get1_id, EVP_PKEY_CTX_get1_id_len, |
| 131 |
EVP_PKEY_CTX_set_kem_op |
| 132 |
\&\- algorithm specific control operations |
| 133 |
.SH SYNOPSIS |
| 134 |
.IX Header "SYNOPSIS" |
| 135 |
.Vb 1 |
| 136 |
\& #include <openssl/evp.h> |
| 137 |
\& |
| 138 |
\& int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, |
| 139 |
\& int cmd, int p1, void *p2); |
| 140 |
\& int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype, |
| 141 |
\& int cmd, uint64_t value); |
| 142 |
\& int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, |
| 143 |
\& const char *value); |
| 144 |
\& |
| 145 |
\& int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md); |
| 146 |
\& |
| 147 |
\& int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); |
| 148 |
\& int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **pmd); |
| 149 |
\& |
| 150 |
\& int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key, |
| 151 |
\& int len); |
| 152 |
\& int EVP_PKEY_CTX_set_group_name(EVP_PKEY_CTX *ctx, const char *name); |
| 153 |
\& int EVP_PKEY_CTX_get_group_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen); |
| 154 |
\& |
| 155 |
\& int EVP_PKEY_CTX_set_kem_op(EVP_PKEY_CTX *ctx, const char *op); |
| 156 |
\& |
| 157 |
\& #include <openssl/rsa.h> |
| 158 |
\& |
| 159 |
\& int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad); |
| 160 |
\& int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx, int *pad); |
| 161 |
\& int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int saltlen); |
| 162 |
\& int EVP_PKEY_CTX_get_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int *saltlen); |
| 163 |
\& int EVP_PKEY_CTX_set_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int mbits); |
| 164 |
\& int EVP_PKEY_CTX_set1_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp); |
| 165 |
\& int EVP_PKEY_CTX_set_rsa_keygen_primes(EVP_PKEY_CTX *ctx, int primes); |
| 166 |
\& int EVP_PKEY_CTX_set_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, const char *mdname, |
| 167 |
\& const char *mdprops); |
| 168 |
\& int EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); |
| 169 |
\& int EVP_PKEY_CTX_get_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); |
| 170 |
\& int EVP_PKEY_CTX_get_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, char *name, |
| 171 |
\& size_t namelen); |
| 172 |
\& int EVP_PKEY_CTX_set_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, const char *mdname, |
| 173 |
\& const char *mdprops); |
| 174 |
\& int EVP_PKEY_CTX_set_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); |
| 175 |
\& int EVP_PKEY_CTX_get_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); |
| 176 |
\& int EVP_PKEY_CTX_get_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, char *name, |
| 177 |
\& size_t namelen); |
| 178 |
\& int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, |
| 179 |
\& int len); |
| 180 |
\& int EVP_PKEY_CTX_get0_rsa_oaep_label(EVP_PKEY_CTX *ctx, unsigned char **label); |
| 181 |
\& |
| 182 |
\& #include <openssl/dsa.h> |
| 183 |
\& |
| 184 |
\& int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits); |
| 185 |
\& int EVP_PKEY_CTX_set_dsa_paramgen_q_bits(EVP_PKEY_CTX *ctx, int qbits); |
| 186 |
\& int EVP_PKEY_CTX_set_dsa_paramgen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); |
| 187 |
\& int EVP_PKEY_CTX_set_dsa_paramgen_md_props(EVP_PKEY_CTX *ctx, |
| 188 |
\& const char *md_name, |
| 189 |
\& const char *md_properties); |
| 190 |
\& int EVP_PKEY_CTX_set_dsa_paramgen_type(EVP_PKEY_CTX *ctx, const char *name); |
| 191 |
\& int EVP_PKEY_CTX_set_dsa_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex); |
| 192 |
\& int EVP_PKEY_CTX_set_dsa_paramgen_seed(EVP_PKEY_CTX *ctx, |
| 193 |
\& const unsigned char *seed, |
| 194 |
\& size_t seedlen); |
| 195 |
\& |
| 196 |
\& #include <openssl/dh.h> |
| 197 |
\& |
| 198 |
\& int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int len); |
| 199 |
\& int EVP_PKEY_CTX_set_dh_paramgen_subprime_len(EVP_PKEY_CTX *ctx, int len); |
| 200 |
\& int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen); |
| 201 |
\& int EVP_PKEY_CTX_set_dh_paramgen_type(EVP_PKEY_CTX *ctx, int type); |
| 202 |
\& int EVP_PKEY_CTX_set_dh_pad(EVP_PKEY_CTX *ctx, int pad); |
| 203 |
\& int EVP_PKEY_CTX_set_dh_nid(EVP_PKEY_CTX *ctx, int nid); |
| 204 |
\& int EVP_PKEY_CTX_set_dh_rfc5114(EVP_PKEY_CTX *ctx, int rfc5114); |
| 205 |
\& int EVP_PKEY_CTX_set_dhx_rfc5114(EVP_PKEY_CTX *ctx, int rfc5114); |
| 206 |
\& int EVP_PKEY_CTX_set_dh_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex); |
| 207 |
\& int EVP_PKEY_CTX_set_dh_paramgen_seed(EVP_PKEY_CTX *ctx, |
| 208 |
\& const unsigned char *seed, |
| 209 |
\& size_t seedlen); |
| 210 |
\& int EVP_PKEY_CTX_set_dh_kdf_type(EVP_PKEY_CTX *ctx, int kdf); |
| 211 |
\& int EVP_PKEY_CTX_get_dh_kdf_type(EVP_PKEY_CTX *ctx); |
| 212 |
\& int EVP_PKEY_CTX_set0_dh_kdf_oid(EVP_PKEY_CTX *ctx, ASN1_OBJECT *oid); |
| 213 |
\& int EVP_PKEY_CTX_get0_dh_kdf_oid(EVP_PKEY_CTX *ctx, ASN1_OBJECT **oid); |
| 214 |
\& int EVP_PKEY_CTX_set_dh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); |
| 215 |
\& int EVP_PKEY_CTX_get_dh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); |
| 216 |
\& int EVP_PKEY_CTX_set_dh_kdf_outlen(EVP_PKEY_CTX *ctx, int len); |
| 217 |
\& int EVP_PKEY_CTX_get_dh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len); |
| 218 |
\& int EVP_PKEY_CTX_set0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, int len); |
| 219 |
\& |
| 220 |
\& #include <openssl/ec.h> |
| 221 |
\& |
| 222 |
\& int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); |
| 223 |
\& int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc); |
| 224 |
\& int EVP_PKEY_CTX_set_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx, int cofactor_mode); |
| 225 |
\& int EVP_PKEY_CTX_get_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx); |
| 226 |
\& int EVP_PKEY_CTX_set_ecdh_kdf_type(EVP_PKEY_CTX *ctx, int kdf); |
| 227 |
\& int EVP_PKEY_CTX_get_ecdh_kdf_type(EVP_PKEY_CTX *ctx); |
| 228 |
\& int EVP_PKEY_CTX_set_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); |
| 229 |
\& int EVP_PKEY_CTX_get_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); |
| 230 |
\& int EVP_PKEY_CTX_set_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int len); |
| 231 |
\& int EVP_PKEY_CTX_get_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len); |
| 232 |
\& int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, int len); |
| 233 |
\& |
| 234 |
\& int EVP_PKEY_CTX_set1_id(EVP_PKEY_CTX *ctx, void *id, size_t id_len); |
| 235 |
\& int EVP_PKEY_CTX_get1_id(EVP_PKEY_CTX *ctx, void *id); |
| 236 |
\& int EVP_PKEY_CTX_get1_id_len(EVP_PKEY_CTX *ctx, size_t *id_len); |
| 237 |
.Ve |
| 238 |
.PP |
| 239 |
The following functions have been deprecated since OpenSSL 3.0, and can be |
| 240 |
hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value, |
| 241 |
see \fBopenssl_user_macros\fR\|(7): |
| 242 |
.PP |
| 243 |
.Vb 1 |
| 244 |
\& #include <openssl/rsa.h> |
| 245 |
\& |
| 246 |
\& int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp); |
| 247 |
\& |
| 248 |
\& #include <openssl/dh.h> |
| 249 |
\& |
| 250 |
\& int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); |
| 251 |
\& |
| 252 |
\& #include <openssl/ec.h> |
| 253 |
\& |
| 254 |
\& int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); |
| 255 |
.Ve |
| 256 |
.SH DESCRIPTION |
| 257 |
.IX Header "DESCRIPTION" |
| 258 |
\&\fBEVP_PKEY_CTX_ctrl()\fR sends a control operation to the context \fIctx\fR. The key |
| 259 |
type used must match \fIkeytype\fR if it is not \-1. The parameter \fIoptype\fR is a |
| 260 |
mask indicating which operations the control can be applied to. |
| 261 |
The control command is indicated in \fIcmd\fR and any additional arguments in |
| 262 |
\&\fIp1\fR and \fIp2\fR. |
| 263 |
.PP |
| 264 |
For \fIcmd\fR = \fBEVP_PKEY_CTRL_SET_MAC_KEY\fR, \fIp1\fR is the length of the MAC key, |
| 265 |
and \fIp2\fR is the MAC key. This is used by Poly1305, SipHash, HMAC and CMAC. |
| 266 |
.PP |
| 267 |
Applications will not normally call \fBEVP_PKEY_CTX_ctrl()\fR directly but will |
| 268 |
instead call one of the algorithm specific functions below. |
| 269 |
.PP |
| 270 |
\&\fBEVP_PKEY_CTX_ctrl_uint64()\fR is a wrapper that directly passes a |
| 271 |
uint64 value as \fIp2\fR to \fBEVP_PKEY_CTX_ctrl()\fR. |
| 272 |
.PP |
| 273 |
\&\fBEVP_PKEY_CTX_ctrl_str()\fR allows an application to send an algorithm |
| 274 |
specific control operation to a context \fIctx\fR in string form. This is |
| 275 |
intended to be used for options specified on the command line or in text |
| 276 |
files. The commands supported are documented in the openssl utility |
| 277 |
command line pages for the option \fI\-pkeyopt\fR which is supported by the |
| 278 |
\&\fIpkeyutl\fR, \fIgenpkey\fR and \fIreq\fR commands. |
| 279 |
.PP |
| 280 |
\&\fBEVP_PKEY_CTX_md()\fR sends a message digest control operation to the context |
| 281 |
\&\fIctx\fR. The message digest is specified by its name \fImd\fR. |
| 282 |
.PP |
| 283 |
\&\fBEVP_PKEY_CTX_set_signature_md()\fR sets the message digest type used |
| 284 |
in a signature. It can be used in the RSA, DSA and ECDSA algorithms. |
| 285 |
.PP |
| 286 |
\&\fBEVP_PKEY_CTX_get_signature_md()\fRgets the message digest type used |
| 287 |
in a signature. It can be used in the RSA, DSA and ECDSA algorithms. |
| 288 |
.PP |
| 289 |
Key generation typically involves setting up parameters to be used and |
| 290 |
generating the private and public key data. Some algorithm implementations |
| 291 |
allow private key data to be set explicitly using \fBEVP_PKEY_CTX_set_mac_key()\fR. |
| 292 |
In this case key generation is simply the process of setting up the |
| 293 |
parameters for the key and then setting the raw key data to the value explicitly. |
| 294 |
Normally applications would call \fBEVP_PKEY_new_raw_private_key\fR\|(3) or similar |
| 295 |
functions instead. |
| 296 |
.PP |
| 297 |
\&\fBEVP_PKEY_CTX_set_mac_key()\fR can be used with any of the algorithms supported by |
| 298 |
the \fBEVP_PKEY_new_raw_private_key\fR\|(3) function. |
| 299 |
.PP |
| 300 |
\&\fBEVP_PKEY_CTX_set_group_name()\fR sets the group name to \fIname\fR for parameter and |
| 301 |
key generation. For example for EC keys this will set the curve name and for |
| 302 |
DH keys it will set the name of the finite field group. |
| 303 |
.PP |
| 304 |
\&\fBEVP_PKEY_CTX_get_group_name()\fR finds the group name that's currently |
| 305 |
set with \fIctx\fR, and writes it to the location that \fIname\fR points at, as long |
| 306 |
as its size \fInamelen\fR is large enough to store that name, including a |
| 307 |
terminating NUL byte. |
| 308 |
.SS "RSA parameters" |
| 309 |
.IX Subsection "RSA parameters" |
| 310 |
\&\fBEVP_PKEY_CTX_set_rsa_padding()\fR sets the RSA padding mode for \fIctx\fR. |
| 311 |
The \fIpad\fR parameter can take the value \fBRSA_PKCS1_PADDING\fR for PKCS#1 |
| 312 |
padding, \fBRSA_NO_PADDING\fR for |
| 313 |
no padding, \fBRSA_PKCS1_OAEP_PADDING\fR for OAEP padding (encrypt and |
| 314 |
decrypt only), \fBRSA_X931_PADDING\fR for X9.31 padding (signature operations |
| 315 |
only), \fBRSA_PKCS1_PSS_PADDING\fR (sign and verify only) and |
| 316 |
\&\fBRSA_PKCS1_WITH_TLS_PADDING\fR for TLS RSA ClientKeyExchange message padding |
| 317 |
(decryption only). |
| 318 |
.PP |
| 319 |
Two RSA padding modes behave differently if \fBEVP_PKEY_CTX_set_signature_md()\fR |
| 320 |
is used. If this function is called for PKCS#1 padding the plaintext buffer is |
| 321 |
an actual digest value and is encapsulated in a DigestInfo structure according |
| 322 |
to PKCS#1 when signing and this structure is expected (and stripped off) when |
| 323 |
verifying. If this control is not used with RSA and PKCS#1 padding then the |
| 324 |
supplied data is used directly and not encapsulated. In the case of X9.31 |
| 325 |
padding for RSA the algorithm identifier byte is added or checked and removed |
| 326 |
if this control is called. If it is not called then the first byte of the plaintext |
| 327 |
buffer is expected to be the algorithm identifier byte. |
| 328 |
.PP |
| 329 |
\&\fBEVP_PKEY_CTX_get_rsa_padding()\fR gets the RSA padding mode for \fIctx\fR. |
| 330 |
.PP |
| 331 |
\&\fBEVP_PKEY_CTX_set_rsa_pss_saltlen()\fR sets the RSA PSS salt length to \fIsaltlen\fR. |
| 332 |
As its name implies it is only supported for PSS padding. If this function is |
| 333 |
not called then the salt length is maximized up to the digest length when |
| 334 |
signing and auto detection when verifying. Four special values are supported: |
| 335 |
.IP \fBRSA_PSS_SALTLEN_DIGEST\fR 4 |
| 336 |
.IX Item "RSA_PSS_SALTLEN_DIGEST" |
| 337 |
sets the salt length to the digest length. |
| 338 |
.IP \fBRSA_PSS_SALTLEN_MAX\fR 4 |
| 339 |
.IX Item "RSA_PSS_SALTLEN_MAX" |
| 340 |
sets the salt length to the maximum permissible value. |
| 341 |
.IP \fBRSA_PSS_SALTLEN_AUTO\fR 4 |
| 342 |
.IX Item "RSA_PSS_SALTLEN_AUTO" |
| 343 |
causes the salt length to be automatically determined based on the |
| 344 |
\&\fBPSS\fR block structure when verifying. When signing, it has the same |
| 345 |
meaning as \fBRSA_PSS_SALTLEN_MAX\fR. |
| 346 |
.IP \fBRSA_PSS_SALTLEN_AUTO_DIGEST_MAX\fR 4 |
| 347 |
.IX Item "RSA_PSS_SALTLEN_AUTO_DIGEST_MAX" |
| 348 |
causes the salt length to be automatically determined based on the \fBPSS\fR block |
| 349 |
structure when verifying, like \fBRSA_PSS_SALTLEN_AUTO\fR. When signing, the salt |
| 350 |
length is maximized up to a maximum of the digest length to comply with FIPS |
| 351 |
186\-4 section 5.5. |
| 352 |
.PP |
| 353 |
\&\fBEVP_PKEY_CTX_get_rsa_pss_saltlen()\fR gets the RSA PSS salt length for \fIctx\fR. |
| 354 |
The padding mode must already have been set to \fBRSA_PKCS1_PSS_PADDING\fR. |
| 355 |
.PP |
| 356 |
\&\fBEVP_PKEY_CTX_set_rsa_keygen_bits()\fR sets the RSA key length for |
| 357 |
RSA key generation to \fIbits\fR. If not specified 2048 bits is used. |
| 358 |
.PP |
| 359 |
\&\fBEVP_PKEY_CTX_set1_rsa_keygen_pubexp()\fR sets the public exponent value for RSA key |
| 360 |
generation to the value stored in \fIpubexp\fR. Currently it should be an odd |
| 361 |
integer. In accordance with the OpenSSL naming convention, the \fIpubexp\fR pointer |
| 362 |
must be freed independently of the EVP_PKEY_CTX (ie, it is internally copied). |
| 363 |
If not specified 65537 is used. |
| 364 |
.PP |
| 365 |
\&\fBEVP_PKEY_CTX_set_rsa_keygen_pubexp()\fR does the same as |
| 366 |
\&\fBEVP_PKEY_CTX_set1_rsa_keygen_pubexp()\fR except that there is no internal copy and |
| 367 |
therefore \fIpubexp\fR should not be modified or freed after the call. |
| 368 |
.PP |
| 369 |
\&\fBEVP_PKEY_CTX_set_rsa_keygen_primes()\fR sets the number of primes for |
| 370 |
RSA key generation to \fIprimes\fR. If not specified 2 is used. |
| 371 |
.PP |
| 372 |
\&\fBEVP_PKEY_CTX_set_rsa_mgf1_md_name()\fR sets the MGF1 digest for RSA |
| 373 |
padding schemes to the digest named \fImdname\fR. If the RSA algorithm |
| 374 |
implementation for the selected provider supports it then the digest will be |
| 375 |
fetched using the properties \fImdprops\fR. If not explicitly set the signing |
| 376 |
digest is used. The padding mode must have been set to \fBRSA_PKCS1_OAEP_PADDING\fR |
| 377 |
or \fBRSA_PKCS1_PSS_PADDING\fR. |
| 378 |
.PP |
| 379 |
\&\fBEVP_PKEY_CTX_set_rsa_mgf1_md()\fR does the same as |
| 380 |
\&\fBEVP_PKEY_CTX_set_rsa_mgf1_md_name()\fR except that the name of the digest is |
| 381 |
inferred from the supplied \fImd\fR and it is not possible to specify any |
| 382 |
properties. |
| 383 |
.PP |
| 384 |
\&\fBEVP_PKEY_CTX_get_rsa_mgf1_md_name()\fR gets the name of the MGF1 |
| 385 |
digest algorithm for \fIctx\fR. If not explicitly set the signing digest is used. |
| 386 |
The padding mode must have been set to \fBRSA_PKCS1_OAEP_PADDING\fR or |
| 387 |
\&\fBRSA_PKCS1_PSS_PADDING\fR. |
| 388 |
.PP |
| 389 |
\&\fBEVP_PKEY_CTX_get_rsa_mgf1_md()\fR does the same as |
| 390 |
\&\fBEVP_PKEY_CTX_get_rsa_mgf1_md_name()\fR except that it returns a pointer to an |
| 391 |
EVP_MD object instead. Note that only known, built-in EVP_MD objects will be |
| 392 |
returned. The EVP_MD object may be NULL if the digest is not one of these (such |
| 393 |
as a digest only implemented in a third party provider). |
| 394 |
.PP |
| 395 |
\&\fBEVP_PKEY_CTX_set_rsa_oaep_md_name()\fR sets the message digest type |
| 396 |
used in RSA OAEP to the digest named \fImdname\fR. If the RSA algorithm |
| 397 |
implementation for the selected provider supports it then the digest will be |
| 398 |
fetched using the properties \fImdprops\fR. The padding mode must have been set to |
| 399 |
\&\fBRSA_PKCS1_OAEP_PADDING\fR. |
| 400 |
.PP |
| 401 |
\&\fBEVP_PKEY_CTX_set_rsa_oaep_md()\fR does the same as |
| 402 |
\&\fBEVP_PKEY_CTX_set_rsa_oaep_md_name()\fR except that the name of the digest is |
| 403 |
inferred from the supplied \fImd\fR and it is not possible to specify any |
| 404 |
properties. |
| 405 |
.PP |
| 406 |
\&\fBEVP_PKEY_CTX_get_rsa_oaep_md_name()\fR gets the message digest |
| 407 |
algorithm name used in RSA OAEP and stores it in the buffer \fIname\fR which is of |
| 408 |
size \fInamelen\fR. The padding mode must have been set to |
| 409 |
\&\fBRSA_PKCS1_OAEP_PADDING\fR. The buffer should be sufficiently large for any |
| 410 |
expected digest algorithm names or the function will fail. |
| 411 |
.PP |
| 412 |
\&\fBEVP_PKEY_CTX_get_rsa_oaep_md()\fR does the same as |
| 413 |
\&\fBEVP_PKEY_CTX_get_rsa_oaep_md_name()\fR except that it returns a pointer to an |
| 414 |
EVP_MD object instead. Note that only known, built-in EVP_MD objects will be |
| 415 |
returned. The EVP_MD object may be NULL if the digest is not one of these (such |
| 416 |
as a digest only implemented in a third party provider). |
| 417 |
.PP |
| 418 |
\&\fBEVP_PKEY_CTX_set0_rsa_oaep_label()\fR sets the RSA OAEP label to binary data |
| 419 |
\&\fIlabel\fR and its length in bytes to \fIlen\fR. If \fIlabel\fR is NULL or \fIlen\fR is 0, |
| 420 |
the label is cleared. The library takes ownership of the label so the |
| 421 |
caller should not free the original memory pointed to by \fIlabel\fR. |
| 422 |
The padding mode must have been set to \fBRSA_PKCS1_OAEP_PADDING\fR. |
| 423 |
.PP |
| 424 |
\&\fBEVP_PKEY_CTX_get0_rsa_oaep_label()\fR gets the RSA OAEP label to |
| 425 |
\&\fIlabel\fR. The return value is the label length. The padding mode |
| 426 |
must have been set to \fBRSA_PKCS1_OAEP_PADDING\fR. The resulting pointer is owned |
| 427 |
by the library and should not be freed by the caller. |
| 428 |
.PP |
| 429 |
\&\fBRSA_PKCS1_WITH_TLS_PADDING\fR is used when decrypting an RSA encrypted TLS |
| 430 |
pre-master secret in a TLS ClientKeyExchange message. It is the same as |
| 431 |
RSA_PKCS1_PADDING except that it additionally verifies that the result is the |
| 432 |
correct length and the first two bytes are the protocol version initially |
| 433 |
requested by the client. If the encrypted content is publicly invalid then the |
| 434 |
decryption will fail. However, if the padding checks fail then decryption will |
| 435 |
still appear to succeed but a random TLS premaster secret will be returned |
| 436 |
instead. This padding mode accepts two parameters which can be set using the |
| 437 |
\&\fBEVP_PKEY_CTX_set_params\fR\|(3) function. These are |
| 438 |
OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION and |
| 439 |
OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION, both of which are expected to be |
| 440 |
unsigned integers. Normally only the first of these will be set and represents |
| 441 |
the TLS protocol version that was first requested by the client (e.g. 0x0303 for |
| 442 |
TLSv1.2, 0x0302 for TLSv1.1 etc). Historically some buggy clients would use the |
| 443 |
negotiated protocol version instead of the protocol version first requested. If |
| 444 |
this behaviour should be tolerated then |
| 445 |
OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION should be set to the actual |
| 446 |
negotiated protocol version. Otherwise it should be left unset. |
| 447 |
.PP |
| 448 |
Similarly to the \fBRSA_PKCS1_WITH_TLS_PADDING\fR above, since OpenSSL version |
| 449 |
3.2.0, the use of \fBRSA_PKCS1_PADDING\fR will return a randomly generated message |
| 450 |
instead of padding errors in case padding checks fail. Applications that |
| 451 |
want to remain secure while using earlier versions of OpenSSL, or a provider |
| 452 |
that doesn't implement the implicit rejection mechanism, still need to |
| 453 |
handle both the error code from the RSA decryption operation and the |
| 454 |
returned message in a side channel secure manner. |
| 455 |
This protection against Bleichenbacher attacks can be disabled by setting |
| 456 |
\&\fBOSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION\fR (an unsigned integer) to 0. |
| 457 |
.SS "DSA parameters" |
| 458 |
.IX Subsection "DSA parameters" |
| 459 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_bits()\fR sets the number of bits used for DSA |
| 460 |
parameter generation to \fBnbits\fR. If not specified, 2048 is used. |
| 461 |
.PP |
| 462 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_q_bits()\fR sets the number of bits in the subprime |
| 463 |
parameter \fIq\fR for DSA parameter generation to \fIqbits\fR. If not specified, 224 |
| 464 |
is used. If a digest function is specified below, this parameter is ignored and |
| 465 |
instead, the number of bits in \fIq\fR matches the size of the digest. |
| 466 |
.PP |
| 467 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_md()\fR sets the digest function used for DSA |
| 468 |
parameter generation to \fImd\fR. If not specified, one of SHA\-1, SHA\-224, or |
| 469 |
SHA\-256 is selected to match the bit length of \fIq\fR above. |
| 470 |
.PP |
| 471 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_md_props()\fR sets the digest function used for DSA |
| 472 |
parameter generation using \fImd_name\fR and \fImd_properties\fR to retrieve the |
| 473 |
digest from a provider. |
| 474 |
If not specified, \fImd_name\fR will be set to one of SHA\-1, SHA\-224, or |
| 475 |
SHA\-256 depending on the bit length of \fIq\fR above. \fImd_properties\fR is a |
| 476 |
property query string that has a default value of '' if not specified. |
| 477 |
.PP |
| 478 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_gindex()\fR sets the \fIgindex\fR used by the generator |
| 479 |
G. The default value is \-1 which uses unverifiable g, otherwise a positive value |
| 480 |
uses verifiable g. This value must be saved if key validation of g is required, |
| 481 |
since it is not part of a persisted key. |
| 482 |
.PP |
| 483 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_seed()\fR sets the \fIseed\fR to use for generation |
| 484 |
rather than using a randomly generated value for the seed. This is useful for |
| 485 |
testing purposes only and can fail if the seed does not produce primes for both |
| 486 |
p & q on its first iteration. This value must be saved if key validation of |
| 487 |
p, q, and verifiable g are required, since it is not part of a persisted key. |
| 488 |
.PP |
| 489 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_type()\fR sets the generation type to use FIPS186\-4 |
| 490 |
generation if \fIname\fR is "fips186_4", or FIPS186\-2 generation if \fIname\fR is |
| 491 |
"fips186_2". The default value for the default provider is "fips186_2". The |
| 492 |
default value for the FIPS provider is "fips186_4". |
| 493 |
.SS "DH parameters" |
| 494 |
.IX Subsection "DH parameters" |
| 495 |
\&\fBEVP_PKEY_CTX_set_dh_paramgen_prime_len()\fR sets the length of the DH prime |
| 496 |
parameter \fIp\fR for DH parameter generation. If this function is not called then |
| 497 |
2048 is used. Only accepts lengths greater than or equal to 256. |
| 498 |
.PP |
| 499 |
\&\fBEVP_PKEY_CTX_set_dh_paramgen_subprime_len()\fR sets the length of the DH |
| 500 |
optional subprime parameter \fIq\fR for DH parameter generation. The default is |
| 501 |
256 if the prime is at least 2048 bits long or 160 otherwise. The DH paramgen |
| 502 |
type must have been set to "fips186_4". |
| 503 |
.PP |
| 504 |
\&\fBEVP_PKEY_CTX_set_dh_paramgen_generator()\fR sets DH generator to \fIgen\fR for DH |
| 505 |
parameter generation. If not specified 2 is used. |
| 506 |
.PP |
| 507 |
\&\fBEVP_PKEY_CTX_set_dh_paramgen_type()\fR sets the key type for DH parameter |
| 508 |
generation. The supported parameters are: |
| 509 |
.IP \fBDH_PARAMGEN_TYPE_GROUP\fR 4 |
| 510 |
.IX Item "DH_PARAMGEN_TYPE_GROUP" |
| 511 |
Use a named group. If only the safe prime parameter \fIp\fR is set this can be |
| 512 |
used to select a ffdhe safe prime group of the correct size. |
| 513 |
.IP \fBDH_PARAMGEN_TYPE_FIPS_186_4\fR 4 |
| 514 |
.IX Item "DH_PARAMGEN_TYPE_FIPS_186_4" |
| 515 |
FIPS186\-4 FFC parameter generator. |
| 516 |
.IP \fBDH_PARAMGEN_TYPE_FIPS_186_2\fR 4 |
| 517 |
.IX Item "DH_PARAMGEN_TYPE_FIPS_186_2" |
| 518 |
FIPS186\-2 FFC parameter generator (X9.42 DH). |
| 519 |
.IP \fBDH_PARAMGEN_TYPE_GENERATOR\fR 4 |
| 520 |
.IX Item "DH_PARAMGEN_TYPE_GENERATOR" |
| 521 |
Uses a safe prime generator g (PKCS#3 format). |
| 522 |
.PP |
| 523 |
The default in the default provider is \fBDH_PARAMGEN_TYPE_GENERATOR\fR for the |
| 524 |
"DH" keytype, and \fBDH_PARAMGEN_TYPE_FIPS_186_2\fR for the "DHX" keytype. In the |
| 525 |
FIPS provider the default value is \fBDH_PARAMGEN_TYPE_GROUP\fR for the "DH" |
| 526 |
keytype and <\fBDH_PARAMGEN_TYPE_FIPS_186_4\fR for the "DHX" keytype. |
| 527 |
.PP |
| 528 |
\&\fBEVP_PKEY_CTX_set_dh_paramgen_gindex()\fR sets the \fIgindex\fR used by the generator G. |
| 529 |
The default value is \-1 which uses unverifiable g, otherwise a positive value |
| 530 |
uses verifiable g. This value must be saved if key validation of g is required, |
| 531 |
since it is not part of a persisted key. |
| 532 |
.PP |
| 533 |
\&\fBEVP_PKEY_CTX_set_dh_paramgen_seed()\fR sets the \fIseed\fR to use for generation |
| 534 |
rather than using a randomly generated value for the seed. This is useful for |
| 535 |
testing purposes only and can fail if the seed does not produce primes for both |
| 536 |
p & q on its first iteration. This value must be saved if key validation of p, q, |
| 537 |
and verifiable g are required, since it is not part of a persisted key. |
| 538 |
.PP |
| 539 |
\&\fBEVP_PKEY_CTX_set_dh_pad()\fR sets the DH padding mode. |
| 540 |
If \fIpad\fR is 1 the shared secret is padded with zeros up to the size of the DH |
| 541 |
prime \fIp\fR. |
| 542 |
If \fIpad\fR is zero (the default) then no padding is performed. |
| 543 |
.PP |
| 544 |
\&\fBEVP_PKEY_CTX_set_dh_nid()\fR sets the DH parameters to values corresponding to |
| 545 |
\&\fInid\fR as defined in RFC7919 or RFC3526. The \fInid\fR parameter must be |
| 546 |
\&\fBNID_ffdhe2048\fR, \fBNID_ffdhe3072\fR, \fBNID_ffdhe4096\fR, \fBNID_ffdhe6144\fR, |
| 547 |
\&\fBNID_ffdhe8192\fR, \fBNID_modp_1536\fR, \fBNID_modp_2048\fR, \fBNID_modp_3072\fR, |
| 548 |
\&\fBNID_modp_4096\fR, \fBNID_modp_6144\fR, \fBNID_modp_8192\fR or \fBNID_undef\fR to clear |
| 549 |
the stored value. This function can be called during parameter or key generation. |
| 550 |
The nid parameter and the rfc5114 parameter are mutually exclusive. |
| 551 |
.PP |
| 552 |
\&\fBEVP_PKEY_CTX_set_dh_rfc5114()\fR and \fBEVP_PKEY_CTX_set_dhx_rfc5114()\fR both set the |
| 553 |
DH parameters to the values defined in RFC5114. The \fIrfc5114\fR parameter must |
| 554 |
be 1, 2 or 3 corresponding to RFC5114 sections 2.1, 2.2 and 2.3. or 0 to clear |
| 555 |
the stored value. This macro can be called during parameter generation. The |
| 556 |
\&\fIctx\fR must have a key type of \fBEVP_PKEY_DHX\fR. |
| 557 |
The rfc5114 parameter and the nid parameter are mutually exclusive. |
| 558 |
.SS "DH key derivation function parameters" |
| 559 |
.IX Subsection "DH key derivation function parameters" |
| 560 |
Note that all of the following functions require that the \fIctx\fR parameter has |
| 561 |
a private key type of \fBEVP_PKEY_DHX\fR. When using key derivation, the output of |
| 562 |
\&\fBEVP_PKEY_derive()\fR is the output of the KDF instead of the DH shared secret. |
| 563 |
The KDF output is typically used as a Key Encryption Key (KEK) that in turn |
| 564 |
encrypts a Content Encryption Key (CEK). |
| 565 |
.PP |
| 566 |
\&\fBEVP_PKEY_CTX_set_dh_kdf_type()\fR sets the key derivation function type to \fIkdf\fR |
| 567 |
for DH key derivation. Possible values are \fBEVP_PKEY_DH_KDF_NONE\fR and |
| 568 |
\&\fBEVP_PKEY_DH_KDF_X9_42\fR which uses the key derivation specified in RFC2631 |
| 569 |
(based on the keying algorithm described in X9.42). When using key derivation, |
| 570 |
the \fIkdf_oid\fR, \fIkdf_md\fR and \fIkdf_outlen\fR parameters must also be specified. |
| 571 |
.PP |
| 572 |
\&\fBEVP_PKEY_CTX_get_dh_kdf_type()\fR gets the key derivation function type for \fIctx\fR |
| 573 |
used for DH key derivation. Possible values are \fBEVP_PKEY_DH_KDF_NONE\fR and |
| 574 |
\&\fBEVP_PKEY_DH_KDF_X9_42\fR. |
| 575 |
.PP |
| 576 |
\&\fBEVP_PKEY_CTX_set0_dh_kdf_oid()\fR sets the key derivation function object |
| 577 |
identifier to \fIoid\fR for DH key derivation. This OID should identify the |
| 578 |
algorithm to be used with the Content Encryption Key. |
| 579 |
The library takes ownership of the object identifier so the caller should not |
| 580 |
free the original memory pointed to by \fIoid\fR. |
| 581 |
.PP |
| 582 |
\&\fBEVP_PKEY_CTX_get0_dh_kdf_oid()\fR gets the key derivation function oid for \fIctx\fR |
| 583 |
used for DH key derivation. The resulting pointer is owned by the library and |
| 584 |
should not be freed by the caller. |
| 585 |
.PP |
| 586 |
\&\fBEVP_PKEY_CTX_set_dh_kdf_md()\fR sets the key derivation function message digest to |
| 587 |
\&\fImd\fR for DH key derivation. Note that RFC2631 specifies that this digest should |
| 588 |
be SHA1 but OpenSSL tolerates other digests. |
| 589 |
.PP |
| 590 |
\&\fBEVP_PKEY_CTX_get_dh_kdf_md()\fR gets the key derivation function message digest for |
| 591 |
\&\fIctx\fR used for DH key derivation. |
| 592 |
.PP |
| 593 |
\&\fBEVP_PKEY_CTX_set_dh_kdf_outlen()\fR sets the key derivation function output length |
| 594 |
to \fIlen\fR for DH key derivation. |
| 595 |
.PP |
| 596 |
\&\fBEVP_PKEY_CTX_get_dh_kdf_outlen()\fR gets the key derivation function output length |
| 597 |
for \fIctx\fR used for DH key derivation. |
| 598 |
.PP |
| 599 |
\&\fBEVP_PKEY_CTX_set0_dh_kdf_ukm()\fR sets the user key material to \fIukm\fR and its |
| 600 |
length to \fIlen\fR for DH key derivation. This parameter is optional and |
| 601 |
corresponds to the partyAInfo field in RFC2631 terms. The specification |
| 602 |
requires that it is 512 bits long but this is not enforced by OpenSSL. |
| 603 |
The library takes ownership of the user key material so the caller should not |
| 604 |
free the original memory pointed to by \fIukm\fR. |
| 605 |
.PP |
| 606 |
\&\fBEVP_PKEY_CTX_get0_dh_kdf_ukm()\fR gets the user key material for \fIctx\fR. |
| 607 |
The return value is the user key material length. The resulting pointer is owned |
| 608 |
by the library and should not be freed by the caller. |
| 609 |
.SS "EC parameters" |
| 610 |
.IX Subsection "EC parameters" |
| 611 |
Use \fBEVP_PKEY_CTX_set_group_name()\fR (described above) to set the curve name to |
| 612 |
\&\fIname\fR for parameter and key generation. |
| 613 |
.PP |
| 614 |
\&\fBEVP_PKEY_CTX_set_ec_paramgen_curve_nid()\fR does the same as |
| 615 |
\&\fBEVP_PKEY_CTX_set_group_name()\fR, but is specific to EC and uses a \fInid\fR rather |
| 616 |
than a name string. |
| 617 |
.PP |
| 618 |
For EC parameter generation, one of \fBEVP_PKEY_CTX_set_group_name()\fR |
| 619 |
or \fBEVP_PKEY_CTX_set_ec_paramgen_curve_nid()\fR must be called or an error occurs |
| 620 |
because there is no default curve. |
| 621 |
These function can also be called to set the curve explicitly when |
| 622 |
generating an EC key. |
| 623 |
.PP |
| 624 |
\&\fBEVP_PKEY_CTX_get_group_name()\fR (described above) can be used to obtain the curve |
| 625 |
name that's currently set with \fIctx\fR. |
| 626 |
.PP |
| 627 |
\&\fBEVP_PKEY_CTX_set_ec_param_enc()\fR sets the EC parameter encoding to \fIparam_enc\fR |
| 628 |
when generating EC parameters or an EC key. The encoding can be |
| 629 |
\&\fBOPENSSL_EC_EXPLICIT_CURVE\fR for explicit parameters (the default in versions |
| 630 |
of OpenSSL before 1.1.0) or \fBOPENSSL_EC_NAMED_CURVE\fR to use named curve form. |
| 631 |
For maximum compatibility the named curve form should be used. Note: the |
| 632 |
\&\fBOPENSSL_EC_NAMED_CURVE\fR value was added in OpenSSL 1.1.0; previous |
| 633 |
versions should use 0 instead. |
| 634 |
.SS "ECDH parameters" |
| 635 |
.IX Subsection "ECDH parameters" |
| 636 |
\&\fBEVP_PKEY_CTX_set_ecdh_cofactor_mode()\fR sets the cofactor mode to \fIcofactor_mode\fR |
| 637 |
for ECDH key derivation. Possible values are 1 to enable cofactor |
| 638 |
key derivation, 0 to disable it and \-1 to clear the stored cofactor mode and |
| 639 |
fallback to the private key cofactor mode. |
| 640 |
.PP |
| 641 |
\&\fBEVP_PKEY_CTX_get_ecdh_cofactor_mode()\fR returns the cofactor mode for \fIctx\fR used |
| 642 |
for ECDH key derivation. Possible values are 1 when cofactor key derivation is |
| 643 |
enabled and 0 otherwise. |
| 644 |
.SS "ECDH key derivation function parameters" |
| 645 |
.IX Subsection "ECDH key derivation function parameters" |
| 646 |
\&\fBEVP_PKEY_CTX_set_ecdh_kdf_type()\fR sets the key derivation function type to |
| 647 |
\&\fIkdf\fR for ECDH key derivation. Possible values are \fBEVP_PKEY_ECDH_KDF_NONE\fR |
| 648 |
and \fBEVP_PKEY_ECDH_KDF_X9_63\fR which uses the key derivation specified in X9.63. |
| 649 |
When using key derivation, the \fIkdf_md\fR and \fIkdf_outlen\fR parameters must |
| 650 |
also be specified. |
| 651 |
.PP |
| 652 |
\&\fBEVP_PKEY_CTX_get_ecdh_kdf_type()\fR returns the key derivation function type for |
| 653 |
\&\fIctx\fR used for ECDH key derivation. Possible values are |
| 654 |
\&\fBEVP_PKEY_ECDH_KDF_NONE\fR and \fBEVP_PKEY_ECDH_KDF_X9_63\fR. |
| 655 |
.PP |
| 656 |
\&\fBEVP_PKEY_CTX_set_ecdh_kdf_md()\fR sets the key derivation function message digest |
| 657 |
to \fImd\fR for ECDH key derivation. Note that X9.63 specifies that this digest |
| 658 |
should be SHA1 but OpenSSL tolerates other digests. |
| 659 |
.PP |
| 660 |
\&\fBEVP_PKEY_CTX_get_ecdh_kdf_md()\fR gets the key derivation function message digest |
| 661 |
for \fIctx\fR used for ECDH key derivation. |
| 662 |
.PP |
| 663 |
\&\fBEVP_PKEY_CTX_set_ecdh_kdf_outlen()\fR sets the key derivation function output |
| 664 |
length to \fIlen\fR for ECDH key derivation. |
| 665 |
.PP |
| 666 |
\&\fBEVP_PKEY_CTX_get_ecdh_kdf_outlen()\fR gets the key derivation function output |
| 667 |
length for \fIctx\fR used for ECDH key derivation. |
| 668 |
.PP |
| 669 |
\&\fBEVP_PKEY_CTX_set0_ecdh_kdf_ukm()\fR sets the user key material to \fIukm\fR for ECDH |
| 670 |
key derivation. This parameter is optional and corresponds to the shared info in |
| 671 |
X9.63 terms. The library takes ownership of the user key material so the caller |
| 672 |
should not free the original memory pointed to by \fIukm\fR. |
| 673 |
.PP |
| 674 |
\&\fBEVP_PKEY_CTX_get0_ecdh_kdf_ukm()\fR gets the user key material for \fIctx\fR. |
| 675 |
The return value is the user key material length. The resulting pointer is owned |
| 676 |
by the library and should not be freed by the caller. |
| 677 |
.SS "Other parameters" |
| 678 |
.IX Subsection "Other parameters" |
| 679 |
\&\fBEVP_PKEY_CTX_set1_id()\fR, \fBEVP_PKEY_CTX_get1_id()\fR and \fBEVP_PKEY_CTX_get1_id_len()\fR |
| 680 |
are used to manipulate the special identifier field for specific signature |
| 681 |
algorithms such as SM2. The \fBEVP_PKEY_CTX_set1_id()\fR sets an ID pointed by \fIid\fR with |
| 682 |
the length \fIid_len\fR to the library. The library takes a copy of the id so that |
| 683 |
the caller can safely free the original memory pointed to by \fIid\fR. |
| 684 |
\&\fBEVP_PKEY_CTX_get1_id_len()\fR returns the length of the ID set via a previous call |
| 685 |
to \fBEVP_PKEY_CTX_set1_id()\fR. The length is usually used to allocate adequate |
| 686 |
memory for further calls to \fBEVP_PKEY_CTX_get1_id()\fR. \fBEVP_PKEY_CTX_get1_id()\fR |
| 687 |
returns the previously set ID value to caller in \fIid\fR. The caller should |
| 688 |
allocate adequate memory space for the \fIid\fR before calling \fBEVP_PKEY_CTX_get1_id()\fR. |
| 689 |
.PP |
| 690 |
\&\fBEVP_PKEY_CTX_set_kem_op()\fR sets the KEM operation to run. This can be set after |
| 691 |
\&\fBEVP_PKEY_encapsulate_init()\fR or \fBEVP_PKEY_decapsulate_init()\fR to select the kem |
| 692 |
operation. For the key types that support encapsulation and don't have the |
| 693 |
default operation, e.g. RSA, this function must be called before |
| 694 |
\&\fBEVP_PKEY_encapsulate()\fR or \fBEVP_PKEY_decapsulate()\fR. |
| 695 |
.PP |
| 696 |
The supported parameters for the built-in algorithms are documented in |
| 697 |
\&\fBEVP_KEM\-RSA\fR\|(7), \fBEVP_KEM\-EC\fR\|(7), \fBEVP_KEM\-X25519\fR\|(7), |
| 698 |
\&\fBEVP_KEM\-X448\fR\|(7), and \fBEVP_KEM\-ML\-KEM\fR\|(7). |
| 699 |
.SH "RETURN VALUES" |
| 700 |
.IX Header "RETURN VALUES" |
| 701 |
All other functions described on this page return a positive value for success |
| 702 |
and 0 or a negative value for failure. In particular a return value of \-2 |
| 703 |
indicates the operation is not supported by the public key algorithm. |
| 704 |
.SH "SEE ALSO" |
| 705 |
.IX Header "SEE ALSO" |
| 706 |
\&\fBEVP_PKEY_CTX_set_params\fR\|(3), |
| 707 |
\&\fBEVP_PKEY_CTX_new\fR\|(3), |
| 708 |
\&\fBEVP_PKEY_encrypt\fR\|(3), |
| 709 |
\&\fBEVP_PKEY_decrypt\fR\|(3), |
| 710 |
\&\fBEVP_PKEY_sign\fR\|(3), |
| 711 |
\&\fBEVP_PKEY_verify\fR\|(3), |
| 712 |
\&\fBEVP_PKEY_verify_recover\fR\|(3), |
| 713 |
\&\fBEVP_PKEY_derive\fR\|(3), |
| 714 |
\&\fBEVP_PKEY_keygen\fR\|(3) |
| 715 |
\&\fBEVP_PKEY_encapsulate\fR\|(3) |
| 716 |
\&\fBEVP_PKEY_decapsulate\fR\|(3) |
| 717 |
.SH HISTORY |
| 718 |
.IX Header "HISTORY" |
| 719 |
\&\fBEVP_PKEY_CTX_get_rsa_oaep_md_name()\fR, \fBEVP_PKEY_CTX_get_rsa_mgf1_md_name()\fR, |
| 720 |
\&\fBEVP_PKEY_CTX_set_rsa_mgf1_md_name()\fR, \fBEVP_PKEY_CTX_set_rsa_oaep_md_name()\fR, |
| 721 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_md_props()\fR, \fBEVP_PKEY_CTX_set_dsa_paramgen_gindex()\fR, |
| 722 |
\&\fBEVP_PKEY_CTX_set_dsa_paramgen_type()\fR, \fBEVP_PKEY_CTX_set_dsa_paramgen_seed()\fR, |
| 723 |
\&\fBEVP_PKEY_CTX_set_group_name()\fR and \fBEVP_PKEY_CTX_get_group_name()\fR |
| 724 |
were added in OpenSSL 3.0. |
| 725 |
.PP |
| 726 |
The \fBEVP_PKEY_CTX_set1_id()\fR, \fBEVP_PKEY_CTX_get1_id()\fR and |
| 727 |
\&\fBEVP_PKEY_CTX_get1_id_len()\fR macros were added in 1.1.1, other functions were |
| 728 |
added in OpenSSL 1.0.0. |
| 729 |
.PP |
| 730 |
In OpenSSL 1.1.1 and below the functions were mostly macros. |
| 731 |
From OpenSSL 3.0 they are all functions. |
| 732 |
.PP |
| 733 |
\&\fBEVP_PKEY_CTX_set_rsa_keygen_pubexp()\fR, \fBEVP_PKEY_CTX_get0_dh_kdf_ukm()\fR, |
| 734 |
and \fBEVP_PKEY_CTX_get0_ecdh_kdf_ukm()\fR were deprecated in OpenSSL 3.0. |
| 735 |
.SH COPYRIGHT |
| 736 |
.IX Header "COPYRIGHT" |
| 737 |
Copyright 2006\-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 738 |
.PP |
| 739 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 740 |
this file except in compliance with the License. You can obtain a copy |
| 741 |
in the file LICENSE in the source distribution or at |
| 742 |
<https://www.openssl.org/source/license.html>. |