| 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 "OPENSSL-GENPKEY 1SSL" |
| 58 |
.TH OPENSSL-GENPKEY 1SSL 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 |
openssl\-genpkey \- generate a private key or key pair |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
\&\fBopenssl\fR \fBgenpkey\fR |
| 68 |
[\fB\-help\fR] |
| 69 |
[\fB\-out\fR \fIfilename\fR] |
| 70 |
[\fB\-outpubkey\fR \fIfilename\fR] |
| 71 |
[\fB\-outform\fR \fBDER\fR|\fBPEM\fR] |
| 72 |
[\fB\-verbose\fR] |
| 73 |
[\fB\-quiet\fR] |
| 74 |
[\fB\-pass\fR \fIarg\fR] |
| 75 |
[\fB\-\fR\f(BIcipher\fR] |
| 76 |
[\fB\-paramfile\fR \fIfile\fR] |
| 77 |
[\fB\-algorithm\fR \fIalg\fR] |
| 78 |
[\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR] |
| 79 |
[\fB\-genparam\fR] |
| 80 |
[\fB\-text\fR] |
| 81 |
[\fB\-rand\fR \fIfiles\fR] |
| 82 |
[\fB\-writerand\fR \fIfile\fR] |
| 83 |
[\fB\-engine\fR \fIid\fR] |
| 84 |
.PP |
| 85 |
[\fB\-provider\fR \fIname\fR] |
| 86 |
[\fB\-provider\-path\fR \fIpath\fR] |
| 87 |
[\fB\-provparam\fR \fI[name:]key=value\fR] |
| 88 |
[\fB\-propquery\fR \fIpropq\fR] |
| 89 |
[\fB\-config\fR \fIconfigfile\fR] |
| 90 |
.SH DESCRIPTION |
| 91 |
.IX Header "DESCRIPTION" |
| 92 |
This command generates a private key or key pair. |
| 93 |
.SH OPTIONS |
| 94 |
.IX Header "OPTIONS" |
| 95 |
.IP \fB\-help\fR 4 |
| 96 |
.IX Item "-help" |
| 97 |
Print out a usage message. |
| 98 |
.IP "\fB\-out\fR \fIfilename\fR" 4 |
| 99 |
.IX Item "-out filename" |
| 100 |
Output the private key to the specified file. If this argument is not |
| 101 |
specified then standard output is used. |
| 102 |
.IP "\fB\-outpubkey\fR \fIfilename\fR" 4 |
| 103 |
.IX Item "-outpubkey filename" |
| 104 |
Output the public key to the specified file. If this argument is not |
| 105 |
specified then the public key is not output. |
| 106 |
.IP "\fB\-outform\fR \fBDER\fR|\fBPEM\fR" 4 |
| 107 |
.IX Item "-outform DER|PEM" |
| 108 |
The output format, except when \fB\-genparam\fR is given; the default is \fBPEM\fR. |
| 109 |
See \fBopenssl\-format\-options\fR\|(1) for details. |
| 110 |
.Sp |
| 111 |
When \fB\-genparam\fR is given, \fB\-outform\fR is ignored. |
| 112 |
.IP \fB\-verbose\fR 4 |
| 113 |
.IX Item "-verbose" |
| 114 |
Output "status dots" while generating keys. |
| 115 |
.IP \fB\-quiet\fR 4 |
| 116 |
.IX Item "-quiet" |
| 117 |
Do not output "status dots" while generating keys. |
| 118 |
.IP "\fB\-pass\fR \fIarg\fR" 4 |
| 119 |
.IX Item "-pass arg" |
| 120 |
The output file password source. For more information about the format of \fIarg\fR |
| 121 |
see \fBopenssl\-passphrase\-options\fR\|(1). |
| 122 |
.IP \fB\-\fR\f(BIcipher\fR 4 |
| 123 |
.IX Item "-cipher" |
| 124 |
Encrypts the private key using the specified algorithm. The algorithm can be |
| 125 |
specified using a name that is accepted by the \fBEVP_get_cipherbyname()\fR function. |
| 126 |
For example, use the syntax \fB\-aes\-128\-cbc\fR to specify the AES encryption |
| 127 |
algorithm with a 128\-bit key in CBC mode. |
| 128 |
.IP "\fB\-algorithm\fR \fIalg\fR" 4 |
| 129 |
.IX Item "-algorithm alg" |
| 130 |
Public key algorithm to use such as RSA, DSA, DH or DHX. If used this option must |
| 131 |
precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR |
| 132 |
are mutually exclusive. Engines or providers may add algorithms in addition to |
| 133 |
the standard built-in ones. |
| 134 |
.Sp |
| 135 |
Valid built-in algorithm names for private key generation are RSA, RSA-PSS, EC, |
| 136 |
X25519, X448, ED25519, ED448, ML-DSA and ML-KEM. |
| 137 |
.Sp |
| 138 |
Valid built-in algorithm names for parameter generation (see the \fB\-genparam\fR |
| 139 |
option) are DH, DSA and EC. |
| 140 |
.Sp |
| 141 |
Note that the algorithm name X9.42 DH may be used as a synonym for DHX keys and |
| 142 |
PKCS#3 refers to DH Keys. Some options are not shared between DH and DHX keys. |
| 143 |
.IP "\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR" 4 |
| 144 |
.IX Item "-pkeyopt opt:value" |
| 145 |
Set the public key algorithm option \fIopt\fR to \fIvalue\fR. The precise set of |
| 146 |
options supported depends on the public key algorithm used and its |
| 147 |
implementation. See "KEY GENERATION OPTIONS" and |
| 148 |
"PARAMETER GENERATION OPTIONS" below for more details. |
| 149 |
.Sp |
| 150 |
To list the possible \fIopt\fR values for an algorithm use: |
| 151 |
\&\fBopenssl\fR \fBgenpkey\fR \-algorithm XXX \-help |
| 152 |
.IP \fB\-genparam\fR 4 |
| 153 |
.IX Item "-genparam" |
| 154 |
Generate a set of parameters instead of a private key. If used this option must |
| 155 |
precede any \fB\-algorithm\fR, \fB\-paramfile\fR or \fB\-pkeyopt\fR options. |
| 156 |
.IP "\fB\-paramfile\fR \fIfilename\fR" 4 |
| 157 |
.IX Item "-paramfile filename" |
| 158 |
Some public key algorithms generate a private key based on a set of parameters. |
| 159 |
They can be supplied using this option. If this option is used the public key |
| 160 |
algorithm used is determined by the parameters. If used this option must |
| 161 |
precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR |
| 162 |
are mutually exclusive. |
| 163 |
.IP \fB\-text\fR 4 |
| 164 |
.IX Item "-text" |
| 165 |
Print an (unencrypted) text representation of private and public keys and |
| 166 |
parameters along with the PEM or DER structure. |
| 167 |
.IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4 |
| 168 |
.IX Item "-rand files, -writerand file" |
| 169 |
See "Random State Options" in \fBopenssl\fR\|(1) for details. |
| 170 |
.IP "\fB\-engine\fR \fIid\fR" 4 |
| 171 |
.IX Item "-engine id" |
| 172 |
See "Engine Options" in \fBopenssl\fR\|(1). |
| 173 |
This option is deprecated. |
| 174 |
.IP "\fB\-provider\fR \fIname\fR" 4 |
| 175 |
.IX Item "-provider name" |
| 176 |
.PD 0 |
| 177 |
.IP "\fB\-provider\-path\fR \fIpath\fR" 4 |
| 178 |
.IX Item "-provider-path path" |
| 179 |
.IP "\fB\-provparam\fR \fI[name:]key=value\fR" 4 |
| 180 |
.IX Item "-provparam [name:]key=value" |
| 181 |
.IP "\fB\-propquery\fR \fIpropq\fR" 4 |
| 182 |
.IX Item "-propquery propq" |
| 183 |
.PD |
| 184 |
See "Provider Options" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7). |
| 185 |
.IP "\fB\-config\fR \fIconfigfile\fR" 4 |
| 186 |
.IX Item "-config configfile" |
| 187 |
See "Configuration Option" in \fBopenssl\fR\|(1). |
| 188 |
.SH "KEY GENERATION OPTIONS" |
| 189 |
.IX Header "KEY GENERATION OPTIONS" |
| 190 |
The options supported by each algorithm and indeed each implementation of an |
| 191 |
algorithm can vary. The options for the OpenSSL implementations are detailed |
| 192 |
below. There are no key generation options defined for the X25519, X448, ED25519 |
| 193 |
or ED448 algorithms. |
| 194 |
.SS "RSA Key Generation Options" |
| 195 |
.IX Subsection "RSA Key Generation Options" |
| 196 |
.IP \fBrsa_keygen_bits:numbits\fR 4 |
| 197 |
.IX Item "rsa_keygen_bits:numbits" |
| 198 |
The number of bits in the generated key. If not specified 2048 is used. |
| 199 |
.IP \fBrsa_keygen_primes:numprimes\fR 4 |
| 200 |
.IX Item "rsa_keygen_primes:numprimes" |
| 201 |
The number of primes in the generated key. If not specified 2 is used. |
| 202 |
.IP \fBrsa_keygen_pubexp:value\fR 4 |
| 203 |
.IX Item "rsa_keygen_pubexp:value" |
| 204 |
The RSA public exponent value. This can be a large decimal or |
| 205 |
hexadecimal value if preceded by \f(CW\*(C`0x\*(C'\fR. Default value is 65537. |
| 206 |
.SS "RSA-PSS Key Generation Options" |
| 207 |
.IX Subsection "RSA-PSS Key Generation Options" |
| 208 |
Note: by default an \fBRSA-PSS\fR key has no parameter restrictions. |
| 209 |
.IP "\fBrsa_keygen_bits\fR:\fInumbits\fR, \fBrsa_keygen_primes\fR:\fInumprimes\fR, \fBrsa_keygen_pubexp\fR:\fIvalue\fR" 4 |
| 210 |
.IX Item "rsa_keygen_bits:numbits, rsa_keygen_primes:numprimes, rsa_keygen_pubexp:value" |
| 211 |
These options have the same meaning as the \fBRSA\fR algorithm. |
| 212 |
.IP \fBrsa_pss_keygen_md\fR:\fIdigest\fR 4 |
| 213 |
.IX Item "rsa_pss_keygen_md:digest" |
| 214 |
If set the key is restricted and can only use \fIdigest\fR for signing. |
| 215 |
.IP \fBrsa_pss_keygen_mgf1_md\fR:\fIdigest\fR 4 |
| 216 |
.IX Item "rsa_pss_keygen_mgf1_md:digest" |
| 217 |
If set the key is restricted and can only use \fIdigest\fR as it's MGF1 |
| 218 |
parameter. |
| 219 |
.IP \fBrsa_pss_keygen_saltlen\fR:\fIlen\fR 4 |
| 220 |
.IX Item "rsa_pss_keygen_saltlen:len" |
| 221 |
If set the key is restricted and \fIlen\fR specifies the minimum salt length. |
| 222 |
.SS "EC Key Generation Options" |
| 223 |
.IX Subsection "EC Key Generation Options" |
| 224 |
The EC key generation options can also be used for parameter generation. |
| 225 |
.IP \fBec_paramgen_curve\fR:\fIcurve\fR 4 |
| 226 |
.IX Item "ec_paramgen_curve:curve" |
| 227 |
The EC curve to use. OpenSSL supports NIST curve names such as "P\-256". |
| 228 |
.IP \fBec_param_enc\fR:\fIencoding\fR 4 |
| 229 |
.IX Item "ec_param_enc:encoding" |
| 230 |
The encoding to use for parameters. The \fIencoding\fR parameter must be either |
| 231 |
\&\fBnamed_curve\fR or \fBexplicit\fR. The default value is \fBnamed_curve\fR. |
| 232 |
.SS "ML-DSA Key Generation Options" |
| 233 |
.IX Subsection "ML-DSA Key Generation Options" |
| 234 |
.IP \fBhexseed\fR:\fIseed\fR 4 |
| 235 |
.IX Item "hexseed:seed" |
| 236 |
This specifies the optional ML-DSA \fIseed\fR in hexadecimal form. The seed is 32 |
| 237 |
bytes, giving 64 hexadecimal digits. |
| 238 |
When generated from an explicit seed the key is completely determined by the |
| 239 |
seed value. |
| 240 |
If other users can see the command-line arguments of the running process, this |
| 241 |
option may compromise the secret key, it is best avoided, tests-aside. |
| 242 |
.Sp |
| 243 |
See \fBEVP_PKEY\-ML\-DSA\fR\|(7) for more detail. |
| 244 |
.SS "ML-KEM Key Generation Options" |
| 245 |
.IX Subsection "ML-KEM Key Generation Options" |
| 246 |
.IP \fBhexseed\fR:\fIseed\fR 4 |
| 247 |
.IX Item "hexseed:seed" |
| 248 |
This specifies the optional ML-KEM \fIseed\fR in hexadecimal form. The seed is 64 |
| 249 |
bytes, giving 128 hexadecimal digits. |
| 250 |
When generated from an explicit seed the key is completely determined by the |
| 251 |
seed value. |
| 252 |
If other users can see the command-line arguments of the running process, this |
| 253 |
option may compromise the secret key, it is best avoided, tests-aside. |
| 254 |
.Sp |
| 255 |
See \fBEVP_PKEY\-ML\-KEM\fR\|(7) for more detail. |
| 256 |
.SS "DH Key Generation Options" |
| 257 |
.IX Subsection "DH Key Generation Options" |
| 258 |
.IP \fBgroup\fR:\fIname\fR 4 |
| 259 |
.IX Item "group:name" |
| 260 |
The \fBparamfile\fR option is not required if a named group is used here. |
| 261 |
See the "DH Parameter Generation Options" section below. |
| 262 |
.SH "PARAMETER GENERATION OPTIONS" |
| 263 |
.IX Header "PARAMETER GENERATION OPTIONS" |
| 264 |
The options supported by each algorithm and indeed each implementation of an |
| 265 |
algorithm can vary. The options for the OpenSSL implementations are detailed |
| 266 |
below. |
| 267 |
.SS "DSA Parameter Generation Options" |
| 268 |
.IX Subsection "DSA Parameter Generation Options" |
| 269 |
.IP \fBdsa_paramgen_bits\fR:\fInumbits\fR 4 |
| 270 |
.IX Item "dsa_paramgen_bits:numbits" |
| 271 |
The number of bits in the generated prime. If not specified 2048 is used. |
| 272 |
.IP \fBdsa_paramgen_q_bits\fR:\fInumbits\fR 4 |
| 273 |
.IX Item "dsa_paramgen_q_bits:numbits" |
| 274 |
.PD 0 |
| 275 |
.IP \fBqbits\fR:\fInumbits\fR 4 |
| 276 |
.IX Item "qbits:numbits" |
| 277 |
.PD |
| 278 |
The number of bits in the q parameter. Must be one of 160, 224 or 256. If not |
| 279 |
specified 224 is used. |
| 280 |
.IP \fBdsa_paramgen_md\fR:\fIdigest\fR 4 |
| 281 |
.IX Item "dsa_paramgen_md:digest" |
| 282 |
.PD 0 |
| 283 |
.IP \fBdigest\fR:\fIdigest\fR 4 |
| 284 |
.IX Item "digest:digest" |
| 285 |
.PD |
| 286 |
The digest to use during parameter generation. Must be one of \fBsha1\fR, \fBsha224\fR |
| 287 |
or \fBsha256\fR. If set, then the number of bits in \fBq\fR will match the output size |
| 288 |
of the specified digest and the \fBdsa_paramgen_q_bits\fR parameter will be |
| 289 |
ignored. If not set, then a digest will be used that gives an output matching |
| 290 |
the number of bits in \fBq\fR, i.e. \fBsha1\fR if q length is 160, \fBsha224\fR if it 224 |
| 291 |
or \fBsha256\fR if it is 256. |
| 292 |
.IP \fBproperties\fR:\fIquery\fR 4 |
| 293 |
.IX Item "properties:query" |
| 294 |
The \fIdigest\fR property \fIquery\fR string to use when fetching a digest from a provider. |
| 295 |
.IP \fBtype\fR:\fItype\fR 4 |
| 296 |
.IX Item "type:type" |
| 297 |
The type of generation to use. Set this to 1 to use legacy FIPS186\-2 parameter |
| 298 |
generation. The default of 0 uses FIPS186\-4 parameter generation. |
| 299 |
.IP \fBgindex\fR:\fIindex\fR 4 |
| 300 |
.IX Item "gindex:index" |
| 301 |
The index to use for canonical generation and verification of the generator g. |
| 302 |
Set this to a positive value ranging from 0..255 to use this mode. Larger values |
| 303 |
will only use the bottom byte. |
| 304 |
This \fIindex\fR must then be reused during key validation to verify the value of g. |
| 305 |
If this value is not set then g is not verifiable. The default value is \-1. |
| 306 |
.IP \fBhexseed\fR:\fIseed\fR 4 |
| 307 |
.IX Item "hexseed:seed" |
| 308 |
The seed \fIseed\fR data to use instead of generating a random seed internally. |
| 309 |
This should be used for testing purposes only. This will either produced fixed |
| 310 |
values for the generated parameters OR it will fail if the seed did not |
| 311 |
generate valid primes. |
| 312 |
.SS "DH Parameter Generation Options" |
| 313 |
.IX Subsection "DH Parameter Generation Options" |
| 314 |
For most use cases it is recommended to use the \fBgroup\fR option rather than |
| 315 |
the \fBtype\fR options. Note that the \fBgroup\fR option is not used by default if |
| 316 |
no parameter generation options are specified. |
| 317 |
.IP \fBgroup\fR:\fIname\fR 4 |
| 318 |
.IX Item "group:name" |
| 319 |
.PD 0 |
| 320 |
.IP \fBdh_param\fR:\fIname\fR 4 |
| 321 |
.IX Item "dh_param:name" |
| 322 |
.PD |
| 323 |
Use a named DH group to select constant values for the DH parameters. |
| 324 |
All other options will be ignored if this value is set. |
| 325 |
.Sp |
| 326 |
Valid values that are associated with the \fBalgorithm\fR of \fB"DH"\fR are: |
| 327 |
"ffdhe2048", "ffdhe3072", "ffdhe4096", "ffdhe6144", "ffdhe8192", |
| 328 |
"modp_1536", "modp_2048", "modp_3072", "modp_4096", "modp_6144", "modp_8192". |
| 329 |
.Sp |
| 330 |
Valid values that are associated with the \fBalgorithm\fR of \fB"DHX"\fR are the |
| 331 |
RFC5114 names "dh_1024_160", "dh_2048_224", "dh_2048_256". |
| 332 |
.IP \fBdh_rfc5114\fR:\fInum\fR 4 |
| 333 |
.IX Item "dh_rfc5114:num" |
| 334 |
If this option is set, then the appropriate RFC5114 parameters are used |
| 335 |
instead of generating new parameters. The value \fInum\fR can be one of |
| 336 |
1, 2 or 3 that are equivalent to using the option \fBgroup\fR with one of |
| 337 |
"dh_1024_160", "dh_2048_224" or "dh_2048_256". |
| 338 |
All other options will be ignored if this value is set. |
| 339 |
.IP \fBpbits\fR:\fInumbits\fR 4 |
| 340 |
.IX Item "pbits:numbits" |
| 341 |
.PD 0 |
| 342 |
.IP \fBdh_paramgen_prime_len\fR:\fInumbits\fR 4 |
| 343 |
.IX Item "dh_paramgen_prime_len:numbits" |
| 344 |
.PD |
| 345 |
The number of bits in the prime parameter \fIp\fR. The default is 2048. |
| 346 |
.IP \fBqbits\fR:\fInumbits\fR 4 |
| 347 |
.IX Item "qbits:numbits" |
| 348 |
.PD 0 |
| 349 |
.IP \fBdh_paramgen_subprime_len\fR:\fInumbits\fR 4 |
| 350 |
.IX Item "dh_paramgen_subprime_len:numbits" |
| 351 |
.PD |
| 352 |
The number of bits in the sub prime parameter \fIq\fR. The default is 224. |
| 353 |
Only relevant if used in conjunction with the \fBdh_paramgen_type\fR option to |
| 354 |
generate DHX parameters. |
| 355 |
.IP \fBsafeprime-generator\fR:\fIvalue\fR 4 |
| 356 |
.IX Item "safeprime-generator:value" |
| 357 |
.PD 0 |
| 358 |
.IP \fBdh_paramgen_generator\fR:\fIvalue\fR 4 |
| 359 |
.IX Item "dh_paramgen_generator:value" |
| 360 |
.PD |
| 361 |
The value to use for the generator \fIg\fR. The default is 2. |
| 362 |
The \fBalgorithm\fR option must be \fB"DH"\fR for this parameter to be used. |
| 363 |
.IP \fBtype\fR:\fIstring\fR 4 |
| 364 |
.IX Item "type:string" |
| 365 |
The type name of DH parameters to generate. Valid values are: |
| 366 |
.RS 4 |
| 367 |
.IP """generator""" 4 |
| 368 |
.IX Item """generator""" |
| 369 |
Use a safe prime generator with the option \fBsafeprime_generator\fR |
| 370 |
The \fBalgorithm\fR option must be \fB"DH"\fR. |
| 371 |
.IP """fips186_4""" 4 |
| 372 |
.IX Item """fips186_4""" |
| 373 |
FIPS186\-4 parameter generation. |
| 374 |
The \fBalgorithm\fR option must be \fB"DHX"\fR. |
| 375 |
.IP """fips186_2""" 4 |
| 376 |
.IX Item """fips186_2""" |
| 377 |
FIPS186\-4 parameter generation. |
| 378 |
The \fBalgorithm\fR option must be \fB"DHX"\fR. |
| 379 |
.IP """group""" 4 |
| 380 |
.IX Item """group""" |
| 381 |
Can be used with the option \fBpbits\fR to select one of |
| 382 |
"ffdhe2048", "ffdhe3072", "ffdhe4096", "ffdhe6144" or "ffdhe8192". |
| 383 |
The \fBalgorithm\fR option must be \fB"DH"\fR. |
| 384 |
.IP """default""" 4 |
| 385 |
.IX Item """default""" |
| 386 |
Selects a default type based on the \fBalgorithm\fR. This is used by the |
| 387 |
OpenSSL default provider to set the type for backwards compatibility. |
| 388 |
If \fBalgorithm\fR is \fB"DH"\fR then \fB"generator"\fR is used. |
| 389 |
If \fBalgorithm\fR is \fB"DHX"\fR then \fB"fips186_2"\fR is used. |
| 390 |
.RE |
| 391 |
.RS 4 |
| 392 |
.RE |
| 393 |
.IP \fBdh_paramgen_type\fR:\fIvalue\fR 4 |
| 394 |
.IX Item "dh_paramgen_type:value" |
| 395 |
The type of DH parameters to generate. Valid values are 0, 1, 2 or 3 |
| 396 |
which correspond to setting the option \fBtype\fR to |
| 397 |
"generator", "fips186_2", "fips186_4" or "group". |
| 398 |
.IP \fBdigest\fR:\fIdigest\fR 4 |
| 399 |
.IX Item "digest:digest" |
| 400 |
The digest to use during parameter generation. Must be one of \fBsha1\fR, \fBsha224\fR |
| 401 |
or \fBsha256\fR. If set, then the number of bits in \fBqbits\fR will match the output |
| 402 |
size of the specified digest and the \fBqbits\fR parameter will be |
| 403 |
ignored. If not set, then a digest will be used that gives an output matching |
| 404 |
the number of bits in \fBq\fR, i.e. \fBsha1\fR if q length is 160, \fBsha224\fR if it is |
| 405 |
224 or \fBsha256\fR if it is 256. |
| 406 |
This is only used by "fips186_4" and "fips186_2" key generation. |
| 407 |
.IP \fBproperties\fR:\fIquery\fR 4 |
| 408 |
.IX Item "properties:query" |
| 409 |
The \fIdigest\fR property \fIquery\fR string to use when fetching a digest from a provider. |
| 410 |
This is only used by "fips186_4" and "fips186_2" key generation. |
| 411 |
.IP \fBgindex\fR:\fIindex\fR 4 |
| 412 |
.IX Item "gindex:index" |
| 413 |
The index to use for canonical generation and verification of the generator g. |
| 414 |
Set this to a positive value ranging from 0..255 to use this mode. Larger values |
| 415 |
will only use the bottom byte. |
| 416 |
This \fIindex\fR must then be reused during key validation to verify the value of g. |
| 417 |
If this value is not set then g is not verifiable. The default value is \-1. |
| 418 |
This is only used by "fips186_4" and "fips186_2" key generation. |
| 419 |
.IP \fBhexseed\fR:\fIseed\fR 4 |
| 420 |
.IX Item "hexseed:seed" |
| 421 |
The seed \fIseed\fR data to use instead of generating a random seed internally. |
| 422 |
This should be used for testing purposes only. This will either produced fixed |
| 423 |
values for the generated parameters OR it will fail if the seed did not |
| 424 |
generate valid primes. |
| 425 |
This is only used by "fips186_4" and "fips186_2" key generation. |
| 426 |
.SS "EC Parameter Generation Options" |
| 427 |
.IX Subsection "EC Parameter Generation Options" |
| 428 |
The EC parameter generation options are the same as for key generation. See |
| 429 |
"EC Key Generation Options" above. |
| 430 |
.SH NOTES |
| 431 |
.IX Header "NOTES" |
| 432 |
The use of the genpkey program is encouraged over the algorithm specific |
| 433 |
utilities because additional algorithm options and ENGINE provided algorithms |
| 434 |
can be used. |
| 435 |
.SH EXAMPLES |
| 436 |
.IX Header "EXAMPLES" |
| 437 |
Generate an RSA private key using default parameters: |
| 438 |
.PP |
| 439 |
.Vb 1 |
| 440 |
\& openssl genpkey \-algorithm RSA \-out key.pem |
| 441 |
.Ve |
| 442 |
.PP |
| 443 |
Encrypt output private key using 128 bit AES and the passphrase "hello": |
| 444 |
.PP |
| 445 |
.Vb 1 |
| 446 |
\& openssl genpkey \-algorithm RSA \-out key.pem \-aes\-128\-cbc \-pass pass:hello |
| 447 |
.Ve |
| 448 |
.PP |
| 449 |
Generate a 2048 bit RSA key using 3 as the public exponent: |
| 450 |
.PP |
| 451 |
.Vb 2 |
| 452 |
\& openssl genpkey \-algorithm RSA \-out key.pem \e |
| 453 |
\& \-pkeyopt rsa_keygen_bits:2048 \-pkeyopt rsa_keygen_pubexp:3 |
| 454 |
.Ve |
| 455 |
.PP |
| 456 |
Generate 2048 bit DSA parameters that can be validated: The output values for |
| 457 |
gindex and seed are required for key validation purposes and are not saved to |
| 458 |
the output pem file). |
| 459 |
.PP |
| 460 |
.Vb 2 |
| 461 |
\& openssl genpkey \-genparam \-algorithm DSA \-out dsap.pem \-pkeyopt pbits:2048 \e |
| 462 |
\& \-pkeyopt qbits:224 \-pkeyopt digest:SHA256 \-pkeyopt gindex:1 \-text |
| 463 |
.Ve |
| 464 |
.PP |
| 465 |
Generate DSA key from parameters: |
| 466 |
.PP |
| 467 |
.Vb 1 |
| 468 |
\& openssl genpkey \-paramfile dsap.pem \-out dsakey.pem |
| 469 |
.Ve |
| 470 |
.PP |
| 471 |
Generate 4096 bit DH Key using safe prime group ffdhe4096: |
| 472 |
.PP |
| 473 |
.Vb 1 |
| 474 |
\& openssl genpkey \-algorithm DH \-out dhkey.pem \-pkeyopt group:ffdhe4096 |
| 475 |
.Ve |
| 476 |
.PP |
| 477 |
Generate 2048 bit X9.42 DH key with 256 bit subgroup using RFC5114 group3: |
| 478 |
.PP |
| 479 |
.Vb 1 |
| 480 |
\& openssl genpkey \-algorithm DHX \-out dhkey.pem \-pkeyopt dh_rfc5114:3 |
| 481 |
.Ve |
| 482 |
.PP |
| 483 |
Generate a DH key using a DH parameters file: |
| 484 |
.PP |
| 485 |
.Vb 1 |
| 486 |
\& openssl genpkey \-paramfile dhp.pem \-out dhkey.pem |
| 487 |
.Ve |
| 488 |
.PP |
| 489 |
Output DH parameters for safe prime group ffdhe2048: |
| 490 |
.PP |
| 491 |
.Vb 1 |
| 492 |
\& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \-pkeyopt group:ffdhe2048 |
| 493 |
.Ve |
| 494 |
.PP |
| 495 |
Output 2048 bit X9.42 DH parameters with 224 bit subgroup using RFC5114 group2: |
| 496 |
.PP |
| 497 |
.Vb 1 |
| 498 |
\& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-pkeyopt dh_rfc5114:2 |
| 499 |
.Ve |
| 500 |
.PP |
| 501 |
Output 2048 bit X9.42 DH parameters with 224 bit subgroup using FIP186\-4 keygen: |
| 502 |
.PP |
| 503 |
.Vb 3 |
| 504 |
\& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-text \e |
| 505 |
\& \-pkeyopt pbits:2048 \-pkeyopt qbits:224 \-pkeyopt digest:SHA256 \e |
| 506 |
\& \-pkeyopt gindex:1 \-pkeyopt dh_paramgen_type:2 |
| 507 |
.Ve |
| 508 |
.PP |
| 509 |
Output 1024 bit X9.42 DH parameters with 160 bit subgroup using FIP186\-2 keygen: |
| 510 |
.PP |
| 511 |
.Vb 3 |
| 512 |
\& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-text \e |
| 513 |
\& \-pkeyopt pbits:1024 \-pkeyopt qbits:160 \-pkeyopt digest:SHA1 \e |
| 514 |
\& \-pkeyopt gindex:1 \-pkeyopt dh_paramgen_type:1 |
| 515 |
.Ve |
| 516 |
.PP |
| 517 |
Output 2048 bit DH parameters: |
| 518 |
.PP |
| 519 |
.Vb 2 |
| 520 |
\& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \e |
| 521 |
\& \-pkeyopt dh_paramgen_prime_len:2048 |
| 522 |
.Ve |
| 523 |
.PP |
| 524 |
Output 2048 bit DH parameters using a generator: |
| 525 |
.PP |
| 526 |
.Vb 3 |
| 527 |
\& openssl genpkey \-genparam \-algorithm DH \-out dhpx.pem \e |
| 528 |
\& \-pkeyopt dh_paramgen_prime_len:2048 \e |
| 529 |
\& \-pkeyopt dh_paramgen_type:1 |
| 530 |
.Ve |
| 531 |
.PP |
| 532 |
Generate EC parameters: |
| 533 |
.PP |
| 534 |
.Vb 3 |
| 535 |
\& openssl genpkey \-genparam \-algorithm EC \-out ecp.pem \e |
| 536 |
\& \-pkeyopt ec_paramgen_curve:secp384r1 \e |
| 537 |
\& \-pkeyopt ec_param_enc:named_curve |
| 538 |
.Ve |
| 539 |
.PP |
| 540 |
Generate EC key from parameters: |
| 541 |
.PP |
| 542 |
.Vb 1 |
| 543 |
\& openssl genpkey \-paramfile ecp.pem \-out eckey.pem |
| 544 |
.Ve |
| 545 |
.PP |
| 546 |
Generate EC key directly: |
| 547 |
.PP |
| 548 |
.Vb 3 |
| 549 |
\& openssl genpkey \-algorithm EC \-out eckey.pem \e |
| 550 |
\& \-pkeyopt ec_paramgen_curve:P\-384 \e |
| 551 |
\& \-pkeyopt ec_param_enc:named_curve |
| 552 |
.Ve |
| 553 |
.PP |
| 554 |
Generate an X25519 private key: |
| 555 |
.PP |
| 556 |
.Vb 1 |
| 557 |
\& openssl genpkey \-algorithm X25519 \-out xkey.pem |
| 558 |
.Ve |
| 559 |
.PP |
| 560 |
Generate an ED448 private key: |
| 561 |
.PP |
| 562 |
.Vb 1 |
| 563 |
\& openssl genpkey \-algorithm ED448 \-out xkey.pem |
| 564 |
.Ve |
| 565 |
.PP |
| 566 |
Generate an ML\-DSA\-65 private key: |
| 567 |
.PP |
| 568 |
.Vb 1 |
| 569 |
\& openssl genpkey \-algorithm ML\-DSA\-65 \-out ml\-dsa\-key.pem |
| 570 |
.Ve |
| 571 |
.PP |
| 572 |
Generate an ML\-KEM\-768 private key: |
| 573 |
.PP |
| 574 |
.Vb 1 |
| 575 |
\& openssl genpkey \-algorithm ML\-KEM\-768 \-out ml\-kem\-key.pem |
| 576 |
.Ve |
| 577 |
.SH HISTORY |
| 578 |
.IX Header "HISTORY" |
| 579 |
The ability to use NIST curve names, and to generate an EC key directly, |
| 580 |
were added in OpenSSL 1.0.2. |
| 581 |
The ability to generate X25519 keys was added in OpenSSL 1.1.0. |
| 582 |
The ability to generate X448, ED25519 and ED448 keys was added in OpenSSL 1.1.1. |
| 583 |
.PP |
| 584 |
The \fB\-engine\fR option was deprecated in OpenSSL 3.0. |
| 585 |
.PP |
| 586 |
Support for \fBML-DSA\fR and \fBML-KEM\fR was added in OpenSSL 3.5. |
| 587 |
.SH COPYRIGHT |
| 588 |
.IX Header "COPYRIGHT" |
| 589 |
Copyright 2006\-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 590 |
.PP |
| 591 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 592 |
this file except in compliance with the License. You can obtain a copy |
| 593 |
in the file LICENSE in the source distribution or at |
| 594 |
<https://www.openssl.org/source/license.html>. |