openssl-kdf.1ossl 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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-KDF 1ossl"
  58. .TH OPENSSL-KDF 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\-kdf \- perform Key Derivation Function operations
  65. .SH SYNOPSIS
  66. .IX Header "SYNOPSIS"
  67. \&\fBopenssl kdf\fR
  68. [\fB\-help\fR]
  69. [\fB\-cipher\fR]
  70. [\fB\-digest\fR]
  71. [\fB\-mac\fR]
  72. [\fB\-kdfopt\fR \fInm\fR:\fIv\fR]
  73. [\fB\-keylen\fR \fInum\fR]
  74. [\fB\-out\fR \fIfilename\fR]
  75. [\fB\-binary\fR]
  76. [\fB\-provider\fR \fIname\fR]
  77. [\fB\-provider\-path\fR \fIpath\fR]
  78. [\fB\-propquery\fR \fIpropq\fR]
  79. \&\fIkdf_name\fR
  80. .SH DESCRIPTION
  81. .IX Header "DESCRIPTION"
  82. The key derivation functions generate a derived key from either a secret or
  83. password.
  84. .SH OPTIONS
  85. .IX Header "OPTIONS"
  86. .IP \fB\-help\fR 4
  87. .IX Item "-help"
  88. Print a usage message.
  89. .IP "\fB\-keylen\fR \fInum\fR" 4
  90. .IX Item "-keylen num"
  91. The output size of the derived key. This field is required.
  92. .IP "\fB\-out\fR \fIfilename\fR" 4
  93. .IX Item "-out filename"
  94. Filename to output to, or standard output by default.
  95. .IP \fB\-binary\fR 4
  96. .IX Item "-binary"
  97. Output the derived key in binary form. Uses hexadecimal text format if not specified.
  98. .IP "\fB\-cipher\fR \fIname\fR" 4
  99. .IX Item "-cipher name"
  100. Specify the cipher to be used by the KDF.
  101. Not all KDFs require a cipher and it is an error to use this option in such
  102. cases.
  103. .IP "\fB\-digest\fR \fIname\fR" 4
  104. .IX Item "-digest name"
  105. Specify the digest to be used by the KDF.
  106. Not all KDFs require a digest and it is an error to use this option in such
  107. cases.
  108. To see the list of supported digests, use \f(CW\*(C`openssl list \-digest\-commands\*(C'\fR.
  109. .IP "\fB\-mac\fR \fIname\fR" 4
  110. .IX Item "-mac name"
  111. Specify the MAC to be used by the KDF.
  112. Not all KDFs require a MAC and it is an error to use this option in such
  113. cases.
  114. .IP "\fB\-kdfopt\fR \fInm\fR:\fIv\fR" 4
  115. .IX Item "-kdfopt nm:v"
  116. Passes options to the KDF algorithm.
  117. A comprehensive list of parameters can be found in "PARAMETERS" in \fBEVP_KDF\fR\|(3).
  118. Common parameter names used by \fBEVP_KDF_CTX_set_params()\fR are:
  119. .RS 4
  120. .IP \fBkey:\fR\fIstring\fR 4
  121. .IX Item "key:string"
  122. Specifies the secret key as an alphanumeric string (use if the key contains
  123. printable characters only).
  124. The string length must conform to any restrictions of the KDF algorithm.
  125. A key must be specified for most KDF algorithms.
  126. .IP \fBhexkey:\fR\fIstring\fR 4
  127. .IX Item "hexkey:string"
  128. Alternative to the \fBkey:\fR option where
  129. the secret key is specified in hexadecimal form (two hex digits per byte).
  130. .IP \fBpass:\fR\fIstring\fR 4
  131. .IX Item "pass:string"
  132. Specifies the password as an alphanumeric string (use if the password contains
  133. printable characters only).
  134. The password must be specified for PBKDF2 and scrypt.
  135. .IP \fBhexpass:\fR\fIstring\fR 4
  136. .IX Item "hexpass:string"
  137. Alternative to the \fBpass:\fR option where
  138. the password is specified in hexadecimal form (two hex digits per byte).
  139. .IP \fBsalt:\fR\fIstring\fR 4
  140. .IX Item "salt:string"
  141. Specifies a non-secret unique cryptographic salt as an alphanumeric string
  142. (use if it contains printable characters only).
  143. The length must conform to any restrictions of the KDF algorithm.
  144. A salt parameter is required for several KDF algorithms,
  145. such as \fBEVP_KDF\-PBKDF2\fR\|(7).
  146. .IP \fBhexsalt:\fR\fIstring\fR 4
  147. .IX Item "hexsalt:string"
  148. Alternative to the \fBsalt:\fR option where
  149. the salt is specified in hexadecimal form (two hex digits per byte).
  150. .IP \fBinfo:\fR\fIstring\fR 4
  151. .IX Item "info:string"
  152. Some KDF implementations, such as \fBEVP_KDF\-HKDF\fR\|(7), take an 'info' parameter
  153. for binding the derived key material
  154. to application\- and context-specific information.
  155. Specifies the info, fixed info, other info or shared info argument
  156. as an alphanumeric string (use if it contains printable characters only).
  157. The length must conform to any restrictions of the KDF algorithm.
  158. .IP \fBhexinfo:\fR\fIstring\fR 4
  159. .IX Item "hexinfo:string"
  160. Alternative to the \fBinfo:\fR option where
  161. the info is specified in hexadecimal form (two hex digits per byte).
  162. .IP \fBdigest:\fR\fIstring\fR 4
  163. .IX Item "digest:string"
  164. This option is identical to the \fB\-digest\fR option.
  165. .IP \fBcipher:\fR\fIstring\fR 4
  166. .IX Item "cipher:string"
  167. This option is identical to the \fB\-cipher\fR option.
  168. .IP \fBmac:\fR\fIstring\fR 4
  169. .IX Item "mac:string"
  170. This option is identical to the \fB\-mac\fR option.
  171. .RE
  172. .RS 4
  173. .RE
  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\-propquery\fR \fIpropq\fR" 4
  180. .IX Item "-propquery propq"
  181. .PD
  182. See "Provider Options" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  183. .IP \fIkdf_name\fR 4
  184. .IX Item "kdf_name"
  185. Specifies the name of a supported KDF algorithm which will be used.
  186. The supported algorithms names include TLS1\-PRF, HKDF, SSKDF, PBKDF2,
  187. SSHKDF, X942KDF\-ASN1, X942KDF\-CONCAT, X963KDF and SCRYPT.
  188. .SH EXAMPLES
  189. .IX Header "EXAMPLES"
  190. Use TLS1\-PRF to create a hex-encoded derived key from a secret key and seed:
  191. .PP
  192. .Vb 2
  193. \& openssl kdf \-keylen 16 \-kdfopt digest:SHA2\-256 \-kdfopt key:secret \e
  194. \& \-kdfopt seed:seed TLS1\-PRF
  195. .Ve
  196. .PP
  197. Use HKDF to create a hex-encoded derived key from a secret key, salt and info:
  198. .PP
  199. .Vb 2
  200. \& openssl kdf \-keylen 10 \-kdfopt digest:SHA2\-256 \-kdfopt key:secret \e
  201. \& \-kdfopt salt:salt \-kdfopt info:label HKDF
  202. .Ve
  203. .PP
  204. Use SSKDF with KMAC to create a hex-encoded derived key from a secret key, salt and info:
  205. .PP
  206. .Vb 3
  207. \& openssl kdf \-keylen 64 \-kdfopt mac:KMAC\-128 \-kdfopt maclen:20 \e
  208. \& \-kdfopt hexkey:b74a149a161545 \-kdfopt hexinfo:348a37a2 \e
  209. \& \-kdfopt hexsalt:3638271ccd68a2 SSKDF
  210. .Ve
  211. .PP
  212. Use SSKDF with HMAC to create a hex-encoded derived key from a secret key, salt and info:
  213. .PP
  214. .Vb 3
  215. \& openssl kdf \-keylen 16 \-kdfopt mac:HMAC \-kdfopt digest:SHA2\-256 \e
  216. \& \-kdfopt hexkey:b74a149a \-kdfopt hexinfo:348a37a2 \e
  217. \& \-kdfopt hexsalt:3638271c SSKDF
  218. .Ve
  219. .PP
  220. Use SSKDF with Hash to create a hex-encoded derived key from a secret key, salt and info:
  221. .PP
  222. .Vb 3
  223. \& openssl kdf \-keylen 14 \-kdfopt digest:SHA2\-256 \e
  224. \& \-kdfopt hexkey:6dbdc23f045488 \e
  225. \& \-kdfopt hexinfo:a1b2c3d4 SSKDF
  226. .Ve
  227. .PP
  228. Use SSHKDF to create a hex-encoded derived key from a secret key, hash and session_id:
  229. .PP
  230. .Vb 5
  231. \& openssl kdf \-keylen 16 \-kdfopt digest:SHA2\-256 \e
  232. \& \-kdfopt hexkey:0102030405 \e
  233. \& \-kdfopt hexxcghash:06090A \e
  234. \& \-kdfopt hexsession_id:01020304 \e
  235. \& \-kdfopt type:A SSHKDF
  236. .Ve
  237. .PP
  238. Use PBKDF2 to create a hex-encoded derived key from a password and salt:
  239. .PP
  240. .Vb 2
  241. \& openssl kdf \-keylen 32 \-kdfopt digest:SHA256 \-kdfopt pass:password \e
  242. \& \-kdfopt salt:salt \-kdfopt iter:2 PBKDF2
  243. .Ve
  244. .PP
  245. Use scrypt to create a hex-encoded derived key from a password and salt:
  246. .PP
  247. .Vb 3
  248. \& openssl kdf \-keylen 64 \-kdfopt pass:password \-kdfopt salt:NaCl \e
  249. \& \-kdfopt n:1024 \-kdfopt r:8 \-kdfopt p:16 \e
  250. \& \-kdfopt maxmem_bytes:10485760 SCRYPT
  251. .Ve
  252. .SH NOTES
  253. .IX Header "NOTES"
  254. The KDF mechanisms that are available will depend on the options
  255. used when building OpenSSL.
  256. .SH "SEE ALSO"
  257. .IX Header "SEE ALSO"
  258. \&\fBopenssl\fR\|(1),
  259. \&\fBopenssl\-pkeyutl\fR\|(1),
  260. \&\fBEVP_KDF\fR\|(3),
  261. \&\fBEVP_KDF\-SCRYPT\fR\|(7),
  262. \&\fBEVP_KDF\-TLS1_PRF\fR\|(7),
  263. \&\fBEVP_KDF\-PBKDF2\fR\|(7),
  264. \&\fBEVP_KDF\-HKDF\fR\|(7),
  265. \&\fBEVP_KDF\-SS\fR\|(7),
  266. \&\fBEVP_KDF\-SSHKDF\fR\|(7),
  267. \&\fBEVP_KDF\-X942\-ASN1\fR\|(7),
  268. \&\fBEVP_KDF\-X942\-CONCAT\fR\|(7),
  269. \&\fBEVP_KDF\-X963\fR\|(7)
  270. .SH HISTORY
  271. .IX Header "HISTORY"
  272. Added in OpenSSL 3.0
  273. .SH COPYRIGHT
  274. .IX Header "COPYRIGHT"
  275. Copyright 2019\-2023 The OpenSSL Project Authors. All Rights Reserved.
  276. .PP
  277. Licensed under the Apache License 2.0 (the "License"). You may not use
  278. this file except in compliance with the License. You can obtain a copy
  279. in the file LICENSE in the source distribution or at
  280. <https://www.openssl.org/source/license.html>.