openssl-pkeyutl.1ossl 20 KB

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