openssl-pkeyutl.1ossl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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-PKEYUTL 1ossl"
  136. .TH OPENSSL-PKEYUTL 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\-pkeyutl \- public key algorithm command
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. \&\fBopenssl\fR \fBpkeyutl\fR
  146. [\fB\-help\fR]
  147. [\fB\-in\fR \fIfile\fR]
  148. [\fB\-rawin\fR]
  149. [\fB\-digest\fR \fIalgorithm\fR]
  150. [\fB\-out\fR \fIfile\fR]
  151. [\fB\-sigfile\fR \fIfile\fR]
  152. [\fB\-inkey\fR \fIfilename\fR|\fIuri\fR]
  153. [\fB\-keyform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR]
  154. [\fB\-passin\fR \fIarg\fR]
  155. [\fB\-peerkey\fR \fIfile\fR]
  156. [\fB\-peerform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR]
  157. [\fB\-pubin\fR]
  158. [\fB\-certin\fR]
  159. [\fB\-rev\fR]
  160. [\fB\-sign\fR]
  161. [\fB\-verify\fR]
  162. [\fB\-verifyrecover\fR]
  163. [\fB\-encrypt\fR]
  164. [\fB\-decrypt\fR]
  165. [\fB\-derive\fR]
  166. [\fB\-kdf\fR \fIalgorithm\fR]
  167. [\fB\-kdflen\fR \fIlength\fR]
  168. [\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR]
  169. [\fB\-pkeyopt_passin\fR \fIopt\fR[:\fIpassarg\fR]]
  170. [\fB\-hexdump\fR]
  171. [\fB\-asn1parse\fR]
  172. [\fB\-engine\fR \fIid\fR]
  173. [\fB\-engine_impl\fR]
  174. [\fB\-rand\fR \fIfiles\fR]
  175. [\fB\-writerand\fR \fIfile\fR]
  176. [\fB\-provider\fR \fIname\fR]
  177. [\fB\-provider\-path\fR \fIpath\fR]
  178. [\fB\-propquery\fR \fIpropq\fR]
  179. [\fB\-config\fR \fIconfigfile\fR]
  180. .SH "DESCRIPTION"
  181. .IX Header "DESCRIPTION"
  182. This command can be used to perform low-level public key
  183. operations using any supported algorithm.
  184. .SH "OPTIONS"
  185. .IX Header "OPTIONS"
  186. .IP "\fB\-help\fR" 4
  187. .IX Item "-help"
  188. Print out a usage message.
  189. .IP "\fB\-in\fR \fIfilename\fR" 4
  190. .IX Item "-in filename"
  191. This specifies the input filename to read data from or standard input
  192. if this option is not specified.
  193. .IP "\fB\-rawin\fR" 4
  194. .IX Item "-rawin"
  195. This indicates that the input data is raw data, which is not hashed by any
  196. message digest algorithm. The user can specify a digest algorithm by using
  197. the \fB\-digest\fR option. This option can only be used with \fB\-sign\fR and
  198. \&\fB\-verify\fR and must be used with the Ed25519 and Ed448 algorithms.
  199. .IP "\fB\-digest\fR \fIalgorithm\fR" 4
  200. .IX Item "-digest algorithm"
  201. This specifies the digest algorithm which is used to hash the input data before
  202. signing or verifying it with the input key. This option could be omitted if the
  203. signature algorithm does not require one (for instance, EdDSA). If this option
  204. is omitted but the signature algorithm requires one, a default value will be
  205. used. For signature algorithms like \s-1RSA, DSA\s0 and \s-1ECDSA, SHA\-256\s0 will be the
  206. default digest algorithm. For \s-1SM2,\s0 it will be \s-1SM3.\s0 If this option is present,
  207. then the \fB\-rawin\fR option must be also specified.
  208. .IP "\fB\-out\fR \fIfilename\fR" 4
  209. .IX Item "-out filename"
  210. Specifies the output filename to write to or standard output by
  211. default.
  212. .IP "\fB\-sigfile\fR \fIfile\fR" 4
  213. .IX Item "-sigfile file"
  214. Signature file, required for \fB\-verify\fR operations only
  215. .IP "\fB\-inkey\fR \fIfilename\fR|\fIuri\fR" 4
  216. .IX Item "-inkey filename|uri"
  217. The input key, by default it should be a private key.
  218. .IP "\fB\-keyform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR" 4
  219. .IX Item "-keyform DER|PEM|P12|ENGINE"
  220. The key format; unspecified by default.
  221. See \fBopenssl\-format\-options\fR\|(1) for details.
  222. .IP "\fB\-passin\fR \fIarg\fR" 4
  223. .IX Item "-passin arg"
  224. The input key password source. For more information about the format of \fIarg\fR
  225. see \fBopenssl\-passphrase\-options\fR\|(1).
  226. .IP "\fB\-peerkey\fR \fIfile\fR" 4
  227. .IX Item "-peerkey file"
  228. The peer key file, used by key derivation (agreement) operations.
  229. .IP "\fB\-peerform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR" 4
  230. .IX Item "-peerform DER|PEM|P12|ENGINE"
  231. The peer key format; unspecified by default.
  232. See \fBopenssl\-format\-options\fR\|(1) for details.
  233. .IP "\fB\-pubin\fR" 4
  234. .IX Item "-pubin"
  235. By default a private key is read from the key input.
  236. With this option a public key is read instead.
  237. If the input contains no public key but a private key, its public part is used.
  238. .IP "\fB\-certin\fR" 4
  239. .IX Item "-certin"
  240. The input is a certificate containing a public key.
  241. .IP "\fB\-rev\fR" 4
  242. .IX Item "-rev"
  243. Reverse the order of the input buffer. This is useful for some libraries
  244. (such as CryptoAPI) which represent the buffer in little endian format.
  245. .IP "\fB\-sign\fR" 4
  246. .IX Item "-sign"
  247. Sign the input data (which must be a hash) and output the signed result. This
  248. requires a private key.
  249. .IP "\fB\-verify\fR" 4
  250. .IX Item "-verify"
  251. Verify the input data (which must be a hash) against the signature file and
  252. indicate if the verification succeeded or failed.
  253. .IP "\fB\-verifyrecover\fR" 4
  254. .IX Item "-verifyrecover"
  255. Verify the input data (which must be a hash) and output the recovered data.
  256. .IP "\fB\-encrypt\fR" 4
  257. .IX Item "-encrypt"
  258. Encrypt the input data using a public key.
  259. .IP "\fB\-decrypt\fR" 4
  260. .IX Item "-decrypt"
  261. Decrypt the input data using a private key.
  262. .IP "\fB\-derive\fR" 4
  263. .IX Item "-derive"
  264. Derive a shared secret using the peer key.
  265. .IP "\fB\-kdf\fR \fIalgorithm\fR" 4
  266. .IX Item "-kdf algorithm"
  267. Use key derivation function \fIalgorithm\fR. The supported algorithms are
  268. at present \fB\s-1TLS1\-PRF\s0\fR and \fB\s-1HKDF\s0\fR.
  269. Note: additional parameters and the \s-1KDF\s0 output length will normally have to be
  270. set for this to work.
  271. See \fBEVP_PKEY_CTX_set_hkdf_md\fR\|(3) and \fBEVP_PKEY_CTX_set_tls1_prf_md\fR\|(3)
  272. for the supported string parameters of each algorithm.
  273. .IP "\fB\-kdflen\fR \fIlength\fR" 4
  274. .IX Item "-kdflen length"
  275. Set the output length for \s-1KDF.\s0
  276. .IP "\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR" 4
  277. .IX Item "-pkeyopt opt:value"
  278. Public key options specified as opt:value. See \s-1NOTES\s0 below for more details.
  279. .IP "\fB\-pkeyopt_passin\fR \fIopt\fR[:\fIpassarg\fR]" 4
  280. .IX Item "-pkeyopt_passin opt[:passarg]"
  281. Allows reading a public key option \fIopt\fR from stdin or a password source.
  282. If only \fIopt\fR is specified, the user will be prompted to enter a password on
  283. stdin. Alternatively, \fIpassarg\fR can be specified which can be any value
  284. supported by \fBopenssl\-passphrase\-options\fR\|(1).
  285. .IP "\fB\-hexdump\fR" 4
  286. .IX Item "-hexdump"
  287. hex dump the output data.
  288. .IP "\fB\-asn1parse\fR" 4
  289. .IX Item "-asn1parse"
  290. Parse the \s-1ASN.1\s0 output data, this is useful when combined with the
  291. \&\fB\-verifyrecover\fR option when an \s-1ASN1\s0 structure is signed.
  292. .IP "\fB\-engine\fR \fIid\fR" 4
  293. .IX Item "-engine id"
  294. See \*(L"Engine Options\*(R" in \fBopenssl\fR\|(1).
  295. This option is deprecated.
  296. .IP "\fB\-engine_impl\fR" 4
  297. .IX Item "-engine_impl"
  298. When used with the \fB\-engine\fR option, it specifies to also use
  299. engine \fIid\fR for crypto operations.
  300. .IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
  301. .IX Item "-rand files, -writerand file"
  302. See \*(L"Random State Options\*(R" in \fBopenssl\fR\|(1) for details.
  303. .IP "\fB\-provider\fR \fIname\fR" 4
  304. .IX Item "-provider name"
  305. .PD 0
  306. .IP "\fB\-provider\-path\fR \fIpath\fR" 4
  307. .IX Item "-provider-path path"
  308. .IP "\fB\-propquery\fR \fIpropq\fR" 4
  309. .IX Item "-propquery propq"
  310. .PD
  311. See \*(L"Provider Options\*(R" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  312. .IP "\fB\-config\fR \fIconfigfile\fR" 4
  313. .IX Item "-config configfile"
  314. See \*(L"Configuration Option\*(R" in \fBopenssl\fR\|(1).
  315. .SH "NOTES"
  316. .IX Header "NOTES"
  317. The operations and options supported vary according to the key algorithm
  318. and its implementation. The OpenSSL operations and options are indicated below.
  319. .PP
  320. Unless otherwise mentioned all algorithms support the \fBdigest:\fR\fIalg\fR option
  321. which specifies the digest in use for sign, verify and verifyrecover operations.
  322. The value \fIalg\fR should represent a digest name as used in the
  323. \&\fBEVP_get_digestbyname()\fR function for example \fBsha1\fR. This value is not used to
  324. hash the input data. It is used (by some algorithms) for sanity-checking the
  325. lengths of data passed in and for creating the structures that make up the
  326. signature (e.g. \fBDigestInfo\fR in \s-1RSASSA\s0 PKCS#1 v1.5 signatures).
  327. .PP
  328. This command does not hash the input data (except where \-rawin is used) but
  329. rather it will use the data directly as input to the signature algorithm.
  330. Depending on the key type, signature type, and mode of padding, the maximum
  331. acceptable lengths of input data differ. The signed data can't be longer than
  332. the key modulus with \s-1RSA.\s0 In case of \s-1ECDSA\s0 and \s-1DSA\s0 the data shouldn't be longer
  333. than the field size, otherwise it will be silently truncated to the field size.
  334. In any event the input size must not be larger than the largest supported digest
  335. size.
  336. .PP
  337. In other words, if the value of digest is \fBsha1\fR the input should be the 20
  338. bytes long binary encoding of the \s-1SHA\-1\s0 hash function output.
  339. .SH "RSA ALGORITHM"
  340. .IX Header "RSA ALGORITHM"
  341. The \s-1RSA\s0 algorithm generally supports the encrypt, decrypt, sign,
  342. verify and verifyrecover operations. However, some padding modes
  343. support only a subset of these operations. The following additional
  344. \&\fBpkeyopt\fR values are supported:
  345. .IP "\fBrsa_padding_mode:\fR\fImode\fR" 4
  346. .IX Item "rsa_padding_mode:mode"
  347. This sets the \s-1RSA\s0 padding mode. Acceptable values for \fImode\fR are \fBpkcs1\fR for
  348. PKCS#1 padding, \fBnone\fR for no padding, \fBoaep\fR
  349. for \fB\s-1OAEP\s0\fR mode, \fBx931\fR for X9.31 mode and \fBpss\fR for \s-1PSS.\s0
  350. .Sp
  351. In PKCS#1 padding, if the message digest is not set, then the supplied data is
  352. signed or verified directly instead of using a \fBDigestInfo\fR structure. If a
  353. digest is set, then the \fBDigestInfo\fR structure is used and its length
  354. must correspond to the digest type.
  355. .Sp
  356. Note, for \fBpkcs1\fR padding, as a protection against the Bleichenbacher attack,
  357. the decryption will not fail in case of padding check failures. Use \fBnone\fR
  358. and manual inspection of the decrypted message to verify if the decrypted
  359. value has correct PKCS#1 v1.5 padding.
  360. .Sp
  361. For \fBoaep\fR mode only encryption and decryption is supported.
  362. .Sp
  363. For \fBx931\fR if the digest type is set it is used to format the block data
  364. otherwise the first byte is used to specify the X9.31 digest \s-1ID.\s0 Sign,
  365. verify and verifyrecover are can be performed in this mode.
  366. .Sp
  367. For \fBpss\fR mode only sign and verify are supported and the digest type must be
  368. specified.
  369. .IP "\fBrsa_pss_saltlen:\fR\fIlen\fR" 4
  370. .IX Item "rsa_pss_saltlen:len"
  371. For \fBpss\fR mode only this option specifies the salt length. Three special
  372. values are supported: \fBdigest\fR sets the salt length to the digest length,
  373. \&\fBmax\fR sets the salt length to the maximum permissible value. When verifying
  374. \&\fBauto\fR causes the salt length to be automatically determined based on the
  375. \&\fB\s-1PSS\s0\fR block structure.
  376. .IP "\fBrsa_mgf1_md:\fR\fIdigest\fR" 4
  377. .IX Item "rsa_mgf1_md:digest"
  378. For \s-1PSS\s0 and \s-1OAEP\s0 padding sets the \s-1MGF1\s0 digest. If the \s-1MGF1\s0 digest is not
  379. explicitly set in \s-1PSS\s0 mode then the signing digest is used.
  380. .IP "\fBrsa_oaep_md:\fR\fIdigest\fR" 4
  381. .IX Item "rsa_oaep_md:digest"
  382. Sets the digest used for the \s-1OAEP\s0 hash function. If not explicitly set then
  383. \&\s-1SHA1\s0 is used.
  384. .IP "\fBrsa_pkcs1_implicit_rejection:\fR\fIflag\fR" 4
  385. .IX Item "rsa_pkcs1_implicit_rejection:flag"
  386. Disables (when set to 0) or enables (when set to 1) the use of implicit
  387. rejection with PKCS#1 v1.5 decryption. When enabled (the default), as a
  388. protection against Bleichenbacher attack, the library will generate a
  389. deterministic random plaintext that it will return to the caller in case
  390. of padding check failure.
  391. When disabled, it's the callers' responsibility to handle the returned
  392. errors in a side-channel free manner.
  393. .SH "RSA-PSS ALGORITHM"
  394. .IX Header "RSA-PSS ALGORITHM"
  395. The RSA-PSS algorithm is a restricted version of the \s-1RSA\s0 algorithm which only
  396. supports the sign and verify operations with \s-1PSS\s0 padding. The following
  397. additional \fB\-pkeyopt\fR values are supported:
  398. .IP "\fBrsa_padding_mode:\fR\fImode\fR, \fBrsa_pss_saltlen:\fR\fIlen\fR, \fBrsa_mgf1_md:\fR\fIdigest\fR" 4
  399. .IX Item "rsa_padding_mode:mode, rsa_pss_saltlen:len, rsa_mgf1_md:digest"
  400. These have the same meaning as the \fB\s-1RSA\s0\fR algorithm with some additional
  401. restrictions. The padding mode can only be set to \fBpss\fR which is the
  402. default value.
  403. .Sp
  404. If the key has parameter restrictions then the digest, \s-1MGF1\s0
  405. digest and salt length are set to the values specified in the parameters.
  406. The digest and \s-1MG\s0 cannot be changed and the salt length cannot be set to a
  407. value less than the minimum restriction.
  408. .SH "DSA ALGORITHM"
  409. .IX Header "DSA ALGORITHM"
  410. The \s-1DSA\s0 algorithm supports signing and verification operations only. Currently
  411. there are no additional \fB\-pkeyopt\fR options other than \fBdigest\fR. The \s-1SHA1\s0
  412. digest is assumed by default.
  413. .SH "DH ALGORITHM"
  414. .IX Header "DH ALGORITHM"
  415. The \s-1DH\s0 algorithm only supports the derivation operation and no additional
  416. \&\fB\-pkeyopt\fR options.
  417. .SH "EC ALGORITHM"
  418. .IX Header "EC ALGORITHM"
  419. The \s-1EC\s0 algorithm supports sign, verify and derive operations. The sign and
  420. verify operations use \s-1ECDSA\s0 and derive uses \s-1ECDH. SHA1\s0 is assumed by default for
  421. the \fB\-pkeyopt\fR \fBdigest\fR option.
  422. .SH "X25519 AND X448 ALGORITHMS"
  423. .IX Header "X25519 AND X448 ALGORITHMS"
  424. The X25519 and X448 algorithms support key derivation only. Currently there are
  425. no additional options.
  426. .SH "ED25519 AND ED448 ALGORITHMS"
  427. .IX Header "ED25519 AND ED448 ALGORITHMS"
  428. These algorithms only support signing and verifying. OpenSSL only implements the
  429. \&\*(L"pure\*(R" variants of these algorithms so raw data can be passed directly to them
  430. without hashing them first. The option \fB\-rawin\fR must be used with these
  431. algorithms with no \fB\-digest\fR specified. Additionally OpenSSL only supports
  432. \&\*(L"oneshot\*(R" operation with these algorithms. This means that the entire file to
  433. be signed/verified must be read into memory before processing it. Signing or
  434. Verifying very large files should be avoided. Additionally the size of the file
  435. must be known for this to work. If the size of the file cannot be determined
  436. (for example if the input is stdin) then the sign or verify operation will fail.
  437. .SH "SM2"
  438. .IX Header "SM2"
  439. The \s-1SM2\s0 algorithm supports sign, verify, encrypt and decrypt operations. For
  440. the sign and verify operations, \s-1SM2\s0 requires an Distinguishing \s-1ID\s0 string to
  441. be passed in. The following \fB\-pkeyopt\fR value is supported:
  442. .IP "\fBdistid:\fR\fIstring\fR" 4
  443. .IX Item "distid:string"
  444. This sets the \s-1ID\s0 string used in \s-1SM2\s0 sign or verify operations. While verifying
  445. an \s-1SM2\s0 signature, the \s-1ID\s0 string must be the same one used when signing the data.
  446. Otherwise the verification will fail.
  447. .IP "\fBhexdistid:\fR\fIhex_string\fR" 4
  448. .IX Item "hexdistid:hex_string"
  449. This sets the \s-1ID\s0 string used in \s-1SM2\s0 sign or verify operations. While verifying
  450. an \s-1SM2\s0 signature, the \s-1ID\s0 string must be the same one used when signing the data.
  451. Otherwise the verification will fail. The \s-1ID\s0 string provided with this option
  452. should be a valid hexadecimal value.
  453. .SH "EXAMPLES"
  454. .IX Header "EXAMPLES"
  455. Sign some data using a private key:
  456. .PP
  457. .Vb 1
  458. \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig
  459. .Ve
  460. .PP
  461. Recover the signed data (e.g. if an \s-1RSA\s0 key is used):
  462. .PP
  463. .Vb 1
  464. \& openssl pkeyutl \-verifyrecover \-in sig \-inkey key.pem
  465. .Ve
  466. .PP
  467. Verify the signature (e.g. a \s-1DSA\s0 key):
  468. .PP
  469. .Vb 1
  470. \& openssl pkeyutl \-verify \-in file \-sigfile sig \-inkey key.pem
  471. .Ve
  472. .PP
  473. Sign data using a message digest value (this is currently only valid for \s-1RSA\s0):
  474. .PP
  475. .Vb 1
  476. \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig \-pkeyopt digest:sha256
  477. .Ve
  478. .PP
  479. Derive a shared secret value:
  480. .PP
  481. .Vb 1
  482. \& openssl pkeyutl \-derive \-inkey key.pem \-peerkey pubkey.pem \-out secret
  483. .Ve
  484. .PP
  485. Hexdump 48 bytes of \s-1TLS1 PRF\s0 using digest \fB\s-1SHA256\s0\fR and shared secret and
  486. seed consisting of the single byte 0xFF:
  487. .PP
  488. .Vb 2
  489. \& openssl pkeyutl \-kdf TLS1\-PRF \-kdflen 48 \-pkeyopt md:SHA256 \e
  490. \& \-pkeyopt hexsecret:ff \-pkeyopt hexseed:ff \-hexdump
  491. .Ve
  492. .PP
  493. Derive a key using \fBscrypt\fR where the password is read from command line:
  494. .PP
  495. .Vb 2
  496. \& openssl pkeyutl \-kdf scrypt \-kdflen 16 \-pkeyopt_passin pass \e
  497. \& \-pkeyopt hexsalt:aabbcc \-pkeyopt N:16384 \-pkeyopt r:8 \-pkeyopt p:1
  498. .Ve
  499. .PP
  500. Derive using the same algorithm, but read key from environment variable \s-1MYPASS:\s0
  501. .PP
  502. .Vb 2
  503. \& openssl pkeyutl \-kdf scrypt \-kdflen 16 \-pkeyopt_passin pass:env:MYPASS \e
  504. \& \-pkeyopt hexsalt:aabbcc \-pkeyopt N:16384 \-pkeyopt r:8 \-pkeyopt p:1
  505. .Ve
  506. .PP
  507. Sign some data using an \s-1\fBSM2\s0\fR\|(7) private key and a specific \s-1ID:\s0
  508. .PP
  509. .Vb 2
  510. \& openssl pkeyutl \-sign \-in file \-inkey sm2.key \-out sig \-rawin \-digest sm3 \e
  511. \& \-pkeyopt distid:someid
  512. .Ve
  513. .PP
  514. Verify some data using an \s-1\fBSM2\s0\fR\|(7) certificate and a specific \s-1ID:\s0
  515. .PP
  516. .Vb 2
  517. \& openssl pkeyutl \-verify \-certin \-in file \-inkey sm2.cert \-sigfile sig \e
  518. \& \-rawin \-digest sm3 \-pkeyopt distid:someid
  519. .Ve
  520. .PP
  521. Decrypt some data using a private key with \s-1OAEP\s0 padding using \s-1SHA256:\s0
  522. .PP
  523. .Vb 2
  524. \& openssl pkeyutl \-decrypt \-in file \-inkey key.pem \-out secret \e
  525. \& \-pkeyopt rsa_padding_mode:oaep \-pkeyopt rsa_oaep_md:sha256
  526. .Ve
  527. .SH "SEE ALSO"
  528. .IX Header "SEE ALSO"
  529. \&\fBopenssl\fR\|(1),
  530. \&\fBopenssl\-genpkey\fR\|(1),
  531. \&\fBopenssl\-pkey\fR\|(1),
  532. \&\fBopenssl\-rsautl\fR\|(1)
  533. \&\fBopenssl\-dgst\fR\|(1),
  534. \&\fBopenssl\-rsa\fR\|(1),
  535. \&\fBopenssl\-genrsa\fR\|(1),
  536. \&\fBopenssl\-kdf\fR\|(1)
  537. \&\fBEVP_PKEY_CTX_set_hkdf_md\fR\|(3),
  538. \&\fBEVP_PKEY_CTX_set_tls1_prf_md\fR\|(3),
  539. .SH "HISTORY"
  540. .IX Header "HISTORY"
  541. The \fB\-engine\fR option was deprecated in OpenSSL 3.0.
  542. .SH "COPYRIGHT"
  543. .IX Header "COPYRIGHT"
  544. Copyright 2006\-2023 The OpenSSL Project Authors. All Rights Reserved.
  545. .PP
  546. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  547. this file except in compliance with the License. You can obtain a copy
  548. in the file \s-1LICENSE\s0 in the source distribution or at
  549. <https://www.openssl.org/source/license.html>.