openssl-genpkey.1ossl 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "OPENSSL-GENPKEY 1ossl"
  136. .TH OPENSSL-GENPKEY 1ossl "2025-06-29" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. openssl\-genpkey \- generate a private key or key pair
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. \&\fBopenssl\fR \fBgenpkey\fR
  146. [\fB\-help\fR]
  147. [\fB\-out\fR \fIfilename\fR]
  148. [\fB\-outpubkey\fR \fIfilename\fR]
  149. [\fB\-outform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR]
  150. [\fB\-verbose\fR]
  151. [\fB\-quiet\fR]
  152. [\fB\-pass\fR \fIarg\fR]
  153. [\fB\-\f(BIcipher\fB\fR]
  154. [\fB\-paramfile\fR \fIfile\fR]
  155. [\fB\-algorithm\fR \fIalg\fR]
  156. [\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR]
  157. [\fB\-genparam\fR]
  158. [\fB\-text\fR]
  159. [\fB\-rand\fR \fIfiles\fR]
  160. [\fB\-writerand\fR \fIfile\fR]
  161. [\fB\-engine\fR \fIid\fR]
  162. .PP
  163. [\fB\-provider\fR \fIname\fR]
  164. [\fB\-provider\-path\fR \fIpath\fR]
  165. [\fB\-propquery\fR \fIpropq\fR]
  166. [\fB\-config\fR \fIconfigfile\fR]
  167. .SH "DESCRIPTION"
  168. .IX Header "DESCRIPTION"
  169. This command generates a private key or key pair.
  170. .SH "OPTIONS"
  171. .IX Header "OPTIONS"
  172. .IP "\fB\-help\fR" 4
  173. .IX Item "-help"
  174. Print out a usage message.
  175. .IP "\fB\-out\fR \fIfilename\fR" 4
  176. .IX Item "-out filename"
  177. Output the private key to the specified file. If this argument is not
  178. specified then standard output is used.
  179. .IP "\fB\-outpubkey\fR \fIfilename\fR" 4
  180. .IX Item "-outpubkey filename"
  181. Output the public key to the specified file. If this argument is not
  182. specified then the public key is not output.
  183. .IP "\fB\-outform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR" 4
  184. .IX Item "-outform DER|PEM"
  185. The output format, except when \fB\-genparam\fR is given; the default is \fB\s-1PEM\s0\fR.
  186. See \fBopenssl\-format\-options\fR\|(1) for details.
  187. .Sp
  188. When \fB\-genparam\fR is given, \fB\-outform\fR is ignored.
  189. .IP "\fB\-verbose\fR" 4
  190. .IX Item "-verbose"
  191. Output \*(L"status dots\*(R" while generating keys.
  192. .IP "\fB\-quiet\fR" 4
  193. .IX Item "-quiet"
  194. Do not output \*(L"status dots\*(R" while generating keys.
  195. .IP "\fB\-pass\fR \fIarg\fR" 4
  196. .IX Item "-pass arg"
  197. The output file password source. For more information about the format of \fIarg\fR
  198. see \fBopenssl\-passphrase\-options\fR\|(1).
  199. .IP "\fB\-\f(BIcipher\fB\fR" 4
  200. .IX Item "-cipher"
  201. This option encrypts the private key with the supplied cipher. Any algorithm
  202. name accepted by \fBEVP_get_cipherbyname()\fR is acceptable such as \fBdes3\fR.
  203. .IP "\fB\-algorithm\fR \fIalg\fR" 4
  204. .IX Item "-algorithm alg"
  205. Public key algorithm to use such as \s-1RSA, DSA, DH\s0 or \s-1DHX.\s0 If used this option must
  206. precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR
  207. are mutually exclusive. Engines or providers may add algorithms in addition to
  208. the standard built-in ones.
  209. .Sp
  210. Valid built-in algorithm names for private key generation are \s-1RSA,\s0 RSA-PSS, \s-1EC,
  211. X25519, X448, ED25519\s0 and \s-1ED448.\s0
  212. .Sp
  213. Valid built-in algorithm names for parameter generation (see the \fB\-genparam\fR
  214. option) are \s-1DH, DSA\s0 and \s-1EC.\s0
  215. .Sp
  216. Note that the algorithm name X9.42 \s-1DH\s0 may be used as a synonym for \s-1DHX\s0 keys and
  217. PKCS#3 refers to \s-1DH\s0 Keys. Some options are not shared between \s-1DH\s0 and \s-1DHX\s0 keys.
  218. .IP "\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR" 4
  219. .IX Item "-pkeyopt opt:value"
  220. Set the public key algorithm option \fIopt\fR to \fIvalue\fR. The precise set of
  221. options supported depends on the public key algorithm used and its
  222. implementation. See \*(L"\s-1KEY GENERATION OPTIONS\*(R"\s0 and
  223. \&\*(L"\s-1PARAMETER GENERATION OPTIONS\*(R"\s0 below for more details.
  224. .Sp
  225. To list the possible \fIopt\fR values for an algorithm use:
  226. \&\fBopenssl\fR \fBgenpkey\fR \-algorithm \s-1XXX\s0 \-help
  227. .IP "\fB\-genparam\fR" 4
  228. .IX Item "-genparam"
  229. Generate a set of parameters instead of a private key. If used this option must
  230. precede any \fB\-algorithm\fR, \fB\-paramfile\fR or \fB\-pkeyopt\fR options.
  231. .IP "\fB\-paramfile\fR \fIfilename\fR" 4
  232. .IX Item "-paramfile filename"
  233. Some public key algorithms generate a private key based on a set of parameters.
  234. They can be supplied using this option. If this option is used the public key
  235. algorithm used is determined by the parameters. If used this option must
  236. precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR
  237. are mutually exclusive.
  238. .IP "\fB\-text\fR" 4
  239. .IX Item "-text"
  240. Print an (unencrypted) text representation of private and public keys and
  241. parameters along with the \s-1PEM\s0 or \s-1DER\s0 structure.
  242. .IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
  243. .IX Item "-rand files, -writerand file"
  244. See \*(L"Random State Options\*(R" in \fBopenssl\fR\|(1) for details.
  245. .IP "\fB\-engine\fR \fIid\fR" 4
  246. .IX Item "-engine id"
  247. See \*(L"Engine Options\*(R" in \fBopenssl\fR\|(1).
  248. This option is deprecated.
  249. .IP "\fB\-provider\fR \fIname\fR" 4
  250. .IX Item "-provider name"
  251. .PD 0
  252. .IP "\fB\-provider\-path\fR \fIpath\fR" 4
  253. .IX Item "-provider-path path"
  254. .IP "\fB\-propquery\fR \fIpropq\fR" 4
  255. .IX Item "-propquery propq"
  256. .PD
  257. See \*(L"Provider Options\*(R" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  258. .IP "\fB\-config\fR \fIconfigfile\fR" 4
  259. .IX Item "-config configfile"
  260. See \*(L"Configuration Option\*(R" in \fBopenssl\fR\|(1).
  261. .SH "KEY GENERATION OPTIONS"
  262. .IX Header "KEY GENERATION OPTIONS"
  263. The options supported by each algorithm and indeed each implementation of an
  264. algorithm can vary. The options for the OpenSSL implementations are detailed
  265. below. There are no key generation options defined for the X25519, X448, \s-1ED25519\s0
  266. or \s-1ED448\s0 algorithms.
  267. .SS "\s-1RSA\s0 Key Generation Options"
  268. .IX Subsection "RSA Key Generation Options"
  269. .IP "\fBrsa_keygen_bits:numbits\fR" 4
  270. .IX Item "rsa_keygen_bits:numbits"
  271. The number of bits in the generated key. If not specified 2048 is used.
  272. .IP "\fBrsa_keygen_primes:numprimes\fR" 4
  273. .IX Item "rsa_keygen_primes:numprimes"
  274. The number of primes in the generated key. If not specified 2 is used.
  275. .IP "\fBrsa_keygen_pubexp:value\fR" 4
  276. .IX Item "rsa_keygen_pubexp:value"
  277. The \s-1RSA\s0 public exponent value. This can be a large decimal or
  278. hexadecimal value if preceded by \f(CW\*(C`0x\*(C'\fR. Default value is 65537.
  279. .SS "RSA-PSS Key Generation Options"
  280. .IX Subsection "RSA-PSS Key Generation Options"
  281. Note: by default an \fBRSA-PSS\fR key has no parameter restrictions.
  282. .IP "\fBrsa_keygen_bits\fR:\fInumbits\fR, \fBrsa_keygen_primes\fR:\fInumprimes\fR, \fBrsa_keygen_pubexp\fR:\fIvalue\fR" 4
  283. .IX Item "rsa_keygen_bits:numbits, rsa_keygen_primes:numprimes, rsa_keygen_pubexp:value"
  284. These options have the same meaning as the \fB\s-1RSA\s0\fR algorithm.
  285. .IP "\fBrsa_pss_keygen_md\fR:\fIdigest\fR" 4
  286. .IX Item "rsa_pss_keygen_md:digest"
  287. If set the key is restricted and can only use \fIdigest\fR for signing.
  288. .IP "\fBrsa_pss_keygen_mgf1_md\fR:\fIdigest\fR" 4
  289. .IX Item "rsa_pss_keygen_mgf1_md:digest"
  290. If set the key is restricted and can only use \fIdigest\fR as it's \s-1MGF1\s0
  291. parameter.
  292. .IP "\fBrsa_pss_keygen_saltlen\fR:\fIlen\fR" 4
  293. .IX Item "rsa_pss_keygen_saltlen:len"
  294. If set the key is restricted and \fIlen\fR specifies the minimum salt length.
  295. .SS "\s-1EC\s0 Key Generation Options"
  296. .IX Subsection "EC Key Generation Options"
  297. The \s-1EC\s0 key generation options can also be used for parameter generation.
  298. .IP "\fBec_paramgen_curve\fR:\fIcurve\fR" 4
  299. .IX Item "ec_paramgen_curve:curve"
  300. The \s-1EC\s0 curve to use. OpenSSL supports \s-1NIST\s0 curve names such as \*(L"P\-256\*(R".
  301. .IP "\fBec_param_enc\fR:\fIencoding\fR" 4
  302. .IX Item "ec_param_enc:encoding"
  303. The encoding to use for parameters. The \fIencoding\fR parameter must be either
  304. \&\fBnamed_curve\fR or \fBexplicit\fR. The default value is \fBnamed_curve\fR.
  305. .SS "\s-1DH\s0 Key Generation Options"
  306. .IX Subsection "DH Key Generation Options"
  307. .IP "\fBgroup\fR:\fIname\fR" 4
  308. .IX Item "group:name"
  309. The \fBparamfile\fR option is not required if a named group is used here.
  310. See the \*(L"\s-1DH\s0 Parameter Generation Options\*(R" section below.
  311. .SH "PARAMETER GENERATION OPTIONS"
  312. .IX Header "PARAMETER GENERATION OPTIONS"
  313. The options supported by each algorithm and indeed each implementation of an
  314. algorithm can vary. The options for the OpenSSL implementations are detailed
  315. below.
  316. .SS "\s-1DSA\s0 Parameter Generation Options"
  317. .IX Subsection "DSA Parameter Generation Options"
  318. .IP "\fBdsa_paramgen_bits\fR:\fInumbits\fR" 4
  319. .IX Item "dsa_paramgen_bits:numbits"
  320. The number of bits in the generated prime. If not specified 2048 is used.
  321. .IP "\fBdsa_paramgen_q_bits\fR:\fInumbits\fR" 4
  322. .IX Item "dsa_paramgen_q_bits:numbits"
  323. .PD 0
  324. .IP "\fBqbits\fR:\fInumbits\fR" 4
  325. .IX Item "qbits:numbits"
  326. .PD
  327. The number of bits in the q parameter. Must be one of 160, 224 or 256. If not
  328. specified 224 is used.
  329. .IP "\fBdsa_paramgen_md\fR:\fIdigest\fR" 4
  330. .IX Item "dsa_paramgen_md:digest"
  331. .PD 0
  332. .IP "\fBdigest\fR:\fIdigest\fR" 4
  333. .IX Item "digest:digest"
  334. .PD
  335. The digest to use during parameter generation. Must be one of \fBsha1\fR, \fBsha224\fR
  336. or \fBsha256\fR. If set, then the number of bits in \fBq\fR will match the output size
  337. of the specified digest and the \fBdsa_paramgen_q_bits\fR parameter will be
  338. ignored. If not set, then a digest will be used that gives an output matching
  339. the number of bits in \fBq\fR, i.e. \fBsha1\fR if q length is 160, \fBsha224\fR if it 224
  340. or \fBsha256\fR if it is 256.
  341. .IP "\fBproperties\fR:\fIquery\fR" 4
  342. .IX Item "properties:query"
  343. The \fIdigest\fR property \fIquery\fR string to use when fetching a digest from a provider.
  344. .IP "\fBtype\fR:\fItype\fR" 4
  345. .IX Item "type:type"
  346. The type of generation to use. Set this to 1 to use legacy \s-1FIPS186\-2\s0 parameter
  347. generation. The default of 0 uses \s-1FIPS186\-4\s0 parameter generation.
  348. .IP "\fBgindex\fR:\fIindex\fR" 4
  349. .IX Item "gindex:index"
  350. The index to use for canonical generation and verification of the generator g.
  351. Set this to a positive value ranging from 0..255 to use this mode. Larger values
  352. will only use the bottom byte.
  353. This \fIindex\fR must then be reused during key validation to verify the value of g.
  354. If this value is not set then g is not verifiable. The default value is \-1.
  355. .IP "\fBhexseed\fR:\fIseed\fR" 4
  356. .IX Item "hexseed:seed"
  357. The seed \fIseed\fR data to use instead of generating a random seed internally.
  358. This should be used for testing purposes only. This will either produced fixed
  359. values for the generated parameters \s-1OR\s0 it will fail if the seed did not
  360. generate valid primes.
  361. .SS "\s-1DH\s0 Parameter Generation Options"
  362. .IX Subsection "DH Parameter Generation Options"
  363. For most use cases it is recommended to use the \fBgroup\fR option rather than
  364. the \fBtype\fR options. Note that the \fBgroup\fR option is not used by default if
  365. no parameter generation options are specified.
  366. .IP "\fBgroup\fR:\fIname\fR" 4
  367. .IX Item "group:name"
  368. .PD 0
  369. .IP "\fBdh_param\fR:\fIname\fR" 4
  370. .IX Item "dh_param:name"
  371. .PD
  372. Use a named \s-1DH\s0 group to select constant values for the \s-1DH\s0 parameters.
  373. All other options will be ignored if this value is set.
  374. .Sp
  375. Valid values that are associated with the \fBalgorithm\fR of \fB\*(L"\s-1DH\*(R"\s0\fR are:
  376. \&\*(L"ffdhe2048\*(R", \*(L"ffdhe3072\*(R", \*(L"ffdhe4096\*(R", \*(L"ffdhe6144\*(R", \*(L"ffdhe8192\*(R",
  377. \&\*(L"modp_1536\*(R", \*(L"modp_2048\*(R", \*(L"modp_3072\*(R", \*(L"modp_4096\*(R", \*(L"modp_6144\*(R", \*(L"modp_8192\*(R".
  378. .Sp
  379. Valid values that are associated with the \fBalgorithm\fR of \fB\*(L"\s-1DHX\*(R"\s0\fR are the
  380. \&\s-1RFC5114\s0 names \*(L"dh_1024_160\*(R", \*(L"dh_2048_224\*(R", \*(L"dh_2048_256\*(R".
  381. .IP "\fBdh_rfc5114\fR:\fInum\fR" 4
  382. .IX Item "dh_rfc5114:num"
  383. If this option is set, then the appropriate \s-1RFC5114\s0 parameters are used
  384. instead of generating new parameters. The value \fInum\fR can be one of
  385. 1, 2 or 3 that are equivalent to using the option \fBgroup\fR with one of
  386. \&\*(L"dh_1024_160\*(R", \*(L"dh_2048_224\*(R" or \*(L"dh_2048_256\*(R".
  387. All other options will be ignored if this value is set.
  388. .IP "\fBpbits\fR:\fInumbits\fR" 4
  389. .IX Item "pbits:numbits"
  390. .PD 0
  391. .IP "\fBdh_paramgen_prime_len\fR:\fInumbits\fR" 4
  392. .IX Item "dh_paramgen_prime_len:numbits"
  393. .PD
  394. The number of bits in the prime parameter \fIp\fR. The default is 2048.
  395. .IP "\fBqbits\fR:\fInumbits\fR" 4
  396. .IX Item "qbits:numbits"
  397. .PD 0
  398. .IP "\fBdh_paramgen_subprime_len\fR:\fInumbits\fR" 4
  399. .IX Item "dh_paramgen_subprime_len:numbits"
  400. .PD
  401. The number of bits in the sub prime parameter \fIq\fR. The default is 224.
  402. Only relevant if used in conjunction with the \fBdh_paramgen_type\fR option to
  403. generate \s-1DHX\s0 parameters.
  404. .IP "\fBsafeprime-generator\fR:\fIvalue\fR" 4
  405. .IX Item "safeprime-generator:value"
  406. .PD 0
  407. .IP "\fBdh_paramgen_generator\fR:\fIvalue\fR" 4
  408. .IX Item "dh_paramgen_generator:value"
  409. .PD
  410. The value to use for the generator \fIg\fR. The default is 2.
  411. The \fBalgorithm\fR option must be \fB\*(L"\s-1DH\*(R"\s0\fR for this parameter to be used.
  412. .IP "\fBtype\fR:\fIstring\fR" 4
  413. .IX Item "type:string"
  414. The type name of \s-1DH\s0 parameters to generate. Valid values are:
  415. .RS 4
  416. .ie n .IP """generator""" 4
  417. .el .IP "``generator''" 4
  418. .IX Item "generator"
  419. Use a safe prime generator with the option \fBsafeprime_generator\fR
  420. The \fBalgorithm\fR option must be \fB\*(L"\s-1DH\*(R"\s0\fR.
  421. .ie n .IP """fips186_4""" 4
  422. .el .IP "``fips186_4''" 4
  423. .IX Item "fips186_4"
  424. \&\s-1FIPS186\-4\s0 parameter generation.
  425. The \fBalgorithm\fR option must be \fB\*(L"\s-1DHX\*(R"\s0\fR.
  426. .ie n .IP """fips186_2""" 4
  427. .el .IP "``fips186_2''" 4
  428. .IX Item "fips186_2"
  429. \&\s-1FIPS186\-4\s0 parameter generation.
  430. The \fBalgorithm\fR option must be \fB\*(L"\s-1DHX\*(R"\s0\fR.
  431. .ie n .IP """group""" 4
  432. .el .IP "``group''" 4
  433. .IX Item "group"
  434. Can be used with the option \fBpbits\fR to select one of
  435. \&\*(L"ffdhe2048\*(R", \*(L"ffdhe3072\*(R", \*(L"ffdhe4096\*(R", \*(L"ffdhe6144\*(R" or \*(L"ffdhe8192\*(R".
  436. The \fBalgorithm\fR option must be \fB\*(L"\s-1DH\*(R"\s0\fR.
  437. .ie n .IP """default""" 4
  438. .el .IP "``default''" 4
  439. .IX Item "default"
  440. Selects a default type based on the \fBalgorithm\fR. This is used by the
  441. OpenSSL default provider to set the type for backwards compatibility.
  442. If \fBalgorithm\fR is \fB\*(L"\s-1DH\*(R"\s0\fR then \fB\*(L"generator\*(R"\fR is used.
  443. If \fBalgorithm\fR is \fB\*(L"\s-1DHX\*(R"\s0\fR then \fB\*(L"fips186_2\*(R"\fR is used.
  444. .RE
  445. .RS 4
  446. .RE
  447. .IP "\fBdh_paramgen_type\fR:\fIvalue\fR" 4
  448. .IX Item "dh_paramgen_type:value"
  449. The type of \s-1DH\s0 parameters to generate. Valid values are 0, 1, 2 or 3
  450. which correspond to setting the option \fBtype\fR to
  451. \&\*(L"generator\*(R", \*(L"fips186_2\*(R", \*(L"fips186_4\*(R" or \*(L"group\*(R".
  452. .IP "\fBdigest\fR:\fIdigest\fR" 4
  453. .IX Item "digest:digest"
  454. The digest to use during parameter generation. Must be one of \fBsha1\fR, \fBsha224\fR
  455. or \fBsha256\fR. If set, then the number of bits in \fBqbits\fR will match the output
  456. size of the specified digest and the \fBqbits\fR parameter will be
  457. ignored. If not set, then a digest will be used that gives an output matching
  458. the number of bits in \fBq\fR, i.e. \fBsha1\fR if q length is 160, \fBsha224\fR if it is
  459. 224 or \fBsha256\fR if it is 256.
  460. This is only used by \*(L"fips186_4\*(R" and \*(L"fips186_2\*(R" key generation.
  461. .IP "\fBproperties\fR:\fIquery\fR" 4
  462. .IX Item "properties:query"
  463. The \fIdigest\fR property \fIquery\fR string to use when fetching a digest from a provider.
  464. This is only used by \*(L"fips186_4\*(R" and \*(L"fips186_2\*(R" key generation.
  465. .IP "\fBgindex\fR:\fIindex\fR" 4
  466. .IX Item "gindex:index"
  467. The index to use for canonical generation and verification of the generator g.
  468. Set this to a positive value ranging from 0..255 to use this mode. Larger values
  469. will only use the bottom byte.
  470. This \fIindex\fR must then be reused during key validation to verify the value of g.
  471. If this value is not set then g is not verifiable. The default value is \-1.
  472. This is only used by \*(L"fips186_4\*(R" and \*(L"fips186_2\*(R" key generation.
  473. .IP "\fBhexseed\fR:\fIseed\fR" 4
  474. .IX Item "hexseed:seed"
  475. The seed \fIseed\fR data to use instead of generating a random seed internally.
  476. This should be used for testing purposes only. This will either produced fixed
  477. values for the generated parameters \s-1OR\s0 it will fail if the seed did not
  478. generate valid primes.
  479. This is only used by \*(L"fips186_4\*(R" and \*(L"fips186_2\*(R" key generation.
  480. .SS "\s-1EC\s0 Parameter Generation Options"
  481. .IX Subsection "EC Parameter Generation Options"
  482. The \s-1EC\s0 parameter generation options are the same as for key generation. See
  483. \&\*(L"\s-1EC\s0 Key Generation Options\*(R" above.
  484. .SH "NOTES"
  485. .IX Header "NOTES"
  486. The use of the genpkey program is encouraged over the algorithm specific
  487. utilities because additional algorithm options and \s-1ENGINE\s0 provided algorithms
  488. can be used.
  489. .SH "EXAMPLES"
  490. .IX Header "EXAMPLES"
  491. Generate an \s-1RSA\s0 private key using default parameters:
  492. .PP
  493. .Vb 1
  494. \& openssl genpkey \-algorithm RSA \-out key.pem
  495. .Ve
  496. .PP
  497. Encrypt output private key using 128 bit \s-1AES\s0 and the passphrase \*(L"hello\*(R":
  498. .PP
  499. .Vb 1
  500. \& openssl genpkey \-algorithm RSA \-out key.pem \-aes\-128\-cbc \-pass pass:hello
  501. .Ve
  502. .PP
  503. Generate a 2048 bit \s-1RSA\s0 key using 3 as the public exponent:
  504. .PP
  505. .Vb 2
  506. \& openssl genpkey \-algorithm RSA \-out key.pem \e
  507. \& \-pkeyopt rsa_keygen_bits:2048 \-pkeyopt rsa_keygen_pubexp:3
  508. .Ve
  509. .PP
  510. Generate 2048 bit \s-1DSA\s0 parameters that can be validated: The output values for
  511. gindex and seed are required for key validation purposes and are not saved to
  512. the output pem file).
  513. .PP
  514. .Vb 2
  515. \& openssl genpkey \-genparam \-algorithm DSA \-out dsap.pem \-pkeyopt pbits:2048 \e
  516. \& \-pkeyopt qbits:224 \-pkeyopt digest:SHA256 \-pkeyopt gindex:1 \-text
  517. .Ve
  518. .PP
  519. Generate \s-1DSA\s0 key from parameters:
  520. .PP
  521. .Vb 1
  522. \& openssl genpkey \-paramfile dsap.pem \-out dsakey.pem
  523. .Ve
  524. .PP
  525. Generate 4096 bit \s-1DH\s0 Key using safe prime group ffdhe4096:
  526. .PP
  527. .Vb 1
  528. \& openssl genpkey \-algorithm DH \-out dhkey.pem \-pkeyopt group:ffdhe4096
  529. .Ve
  530. .PP
  531. Generate 2048 bit X9.42 \s-1DH\s0 key with 256 bit subgroup using \s-1RFC5114\s0 group3:
  532. .PP
  533. .Vb 1
  534. \& openssl genpkey \-algorithm DHX \-out dhkey.pem \-pkeyopt dh_rfc5114:3
  535. .Ve
  536. .PP
  537. Generate a \s-1DH\s0 key using a \s-1DH\s0 parameters file:
  538. .PP
  539. .Vb 1
  540. \& openssl genpkey \-paramfile dhp.pem \-out dhkey.pem
  541. .Ve
  542. .PP
  543. Output \s-1DH\s0 parameters for safe prime group ffdhe2048:
  544. .PP
  545. .Vb 1
  546. \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \-pkeyopt group:ffdhe2048
  547. .Ve
  548. .PP
  549. Output 2048 bit X9.42 \s-1DH\s0 parameters with 224 bit subgroup using \s-1RFC5114\s0 group2:
  550. .PP
  551. .Vb 1
  552. \& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-pkeyopt dh_rfc5114:2
  553. .Ve
  554. .PP
  555. Output 2048 bit X9.42 \s-1DH\s0 parameters with 224 bit subgroup using \s-1FIP186\-4\s0 keygen:
  556. .PP
  557. .Vb 3
  558. \& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-text \e
  559. \& \-pkeyopt pbits:2048 \-pkeyopt qbits:224 \-pkeyopt digest:SHA256 \e
  560. \& \-pkeyopt gindex:1 \-pkeyopt dh_paramgen_type:2
  561. .Ve
  562. .PP
  563. Output 1024 bit X9.42 \s-1DH\s0 parameters with 160 bit subgroup using \s-1FIP186\-2\s0 keygen:
  564. .PP
  565. .Vb 3
  566. \& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-text \e
  567. \& \-pkeyopt pbits:1024 \-pkeyopt qbits:160 \-pkeyopt digest:SHA1 \e
  568. \& \-pkeyopt gindex:1 \-pkeyopt dh_paramgen_type:1
  569. .Ve
  570. .PP
  571. Output 2048 bit \s-1DH\s0 parameters:
  572. .PP
  573. .Vb 2
  574. \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \e
  575. \& \-pkeyopt dh_paramgen_prime_len:2048
  576. .Ve
  577. .PP
  578. Output 2048 bit \s-1DH\s0 parameters using a generator:
  579. .PP
  580. .Vb 3
  581. \& openssl genpkey \-genparam \-algorithm DH \-out dhpx.pem \e
  582. \& \-pkeyopt dh_paramgen_prime_len:2048 \e
  583. \& \-pkeyopt dh_paramgen_type:1
  584. .Ve
  585. .PP
  586. Generate \s-1EC\s0 parameters:
  587. .PP
  588. .Vb 3
  589. \& openssl genpkey \-genparam \-algorithm EC \-out ecp.pem \e
  590. \& \-pkeyopt ec_paramgen_curve:secp384r1 \e
  591. \& \-pkeyopt ec_param_enc:named_curve
  592. .Ve
  593. .PP
  594. Generate \s-1EC\s0 key from parameters:
  595. .PP
  596. .Vb 1
  597. \& openssl genpkey \-paramfile ecp.pem \-out eckey.pem
  598. .Ve
  599. .PP
  600. Generate \s-1EC\s0 key directly:
  601. .PP
  602. .Vb 3
  603. \& openssl genpkey \-algorithm EC \-out eckey.pem \e
  604. \& \-pkeyopt ec_paramgen_curve:P\-384 \e
  605. \& \-pkeyopt ec_param_enc:named_curve
  606. .Ve
  607. .PP
  608. Generate an X25519 private key:
  609. .PP
  610. .Vb 1
  611. \& openssl genpkey \-algorithm X25519 \-out xkey.pem
  612. .Ve
  613. .PP
  614. Generate an \s-1ED448\s0 private key:
  615. .PP
  616. .Vb 1
  617. \& openssl genpkey \-algorithm ED448 \-out xkey.pem
  618. .Ve
  619. .SH "HISTORY"
  620. .IX Header "HISTORY"
  621. The ability to use \s-1NIST\s0 curve names, and to generate an \s-1EC\s0 key directly,
  622. were added in OpenSSL 1.0.2.
  623. The ability to generate X25519 keys was added in OpenSSL 1.1.0.
  624. The ability to generate X448, \s-1ED25519\s0 and \s-1ED448\s0 keys was added in OpenSSL 1.1.1.
  625. .PP
  626. The \fB\-engine\fR option was deprecated in OpenSSL 3.0.
  627. .SH "COPYRIGHT"
  628. .IX Header "COPYRIGHT"
  629. Copyright 2006\-2024 The OpenSSL Project Authors. All Rights Reserved.
  630. .PP
  631. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  632. this file except in compliance with the License. You can obtain a copy
  633. in the file \s-1LICENSE\s0 in the source distribution or at
  634. <https://www.openssl.org/source/license.html>.