openssl-kdf.1ossl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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-KDF 1ossl"
  136. .TH OPENSSL-KDF 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\-kdf \- perform Key Derivation Function operations
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. \&\fBopenssl kdf\fR
  146. [\fB\-help\fR]
  147. [\fB\-cipher\fR]
  148. [\fB\-digest\fR]
  149. [\fB\-mac\fR]
  150. [\fB\-kdfopt\fR \fInm\fR:\fIv\fR]
  151. [\fB\-keylen\fR \fInum\fR]
  152. [\fB\-out\fR \fIfilename\fR]
  153. [\fB\-binary\fR]
  154. [\fB\-provider\fR \fIname\fR]
  155. [\fB\-provider\-path\fR \fIpath\fR]
  156. [\fB\-propquery\fR \fIpropq\fR]
  157. \&\fIkdf_name\fR
  158. .SH "DESCRIPTION"
  159. .IX Header "DESCRIPTION"
  160. The key derivation functions generate a derived key from either a secret or
  161. password.
  162. .SH "OPTIONS"
  163. .IX Header "OPTIONS"
  164. .IP "\fB\-help\fR" 4
  165. .IX Item "-help"
  166. Print a usage message.
  167. .IP "\fB\-keylen\fR \fInum\fR" 4
  168. .IX Item "-keylen num"
  169. The output size of the derived key. This field is required.
  170. .IP "\fB\-out\fR \fIfilename\fR" 4
  171. .IX Item "-out filename"
  172. Filename to output to, or standard output by default.
  173. .IP "\fB\-binary\fR" 4
  174. .IX Item "-binary"
  175. Output the derived key in binary form. Uses hexadecimal text format if not specified.
  176. .IP "\fB\-cipher\fR \fIname\fR" 4
  177. .IX Item "-cipher name"
  178. Specify the cipher to be used by the \s-1KDF.\s0
  179. Not all KDFs require a cipher and it is an error to use this option in such
  180. cases.
  181. .IP "\fB\-digest\fR \fIname\fR" 4
  182. .IX Item "-digest name"
  183. Specify the digest to be used by the \s-1KDF.\s0
  184. Not all KDFs require a digest and it is an error to use this option in such
  185. cases.
  186. To see the list of supported digests, use \f(CW\*(C`openssl list \-digest\-commands\*(C'\fR.
  187. .IP "\fB\-mac\fR \fIname\fR" 4
  188. .IX Item "-mac name"
  189. Specify the \s-1MAC\s0 to be used by the \s-1KDF.\s0
  190. Not all KDFs require a \s-1MAC\s0 and it is an error to use this option in such
  191. cases.
  192. .IP "\fB\-kdfopt\fR \fInm\fR:\fIv\fR" 4
  193. .IX Item "-kdfopt nm:v"
  194. Passes options to the \s-1KDF\s0 algorithm.
  195. A comprehensive list of parameters can be found in \*(L"\s-1PARAMETERS\*(R"\s0 in \s-1\fBEVP_KDF\s0\fR\|(3).
  196. Common parameter names used by \fBEVP_KDF_CTX_set_params()\fR are:
  197. .RS 4
  198. .IP "\fBkey:\fR\fIstring\fR" 4
  199. .IX Item "key:string"
  200. Specifies the secret key as an alphanumeric string (use if the key contains
  201. printable characters only).
  202. The string length must conform to any restrictions of the \s-1KDF\s0 algorithm.
  203. A key must be specified for most \s-1KDF\s0 algorithms.
  204. .IP "\fBhexkey:\fR\fIstring\fR" 4
  205. .IX Item "hexkey:string"
  206. Alternative to the \fBkey:\fR option where
  207. the secret key is specified in hexadecimal form (two hex digits per byte).
  208. .IP "\fBpass:\fR\fIstring\fR" 4
  209. .IX Item "pass:string"
  210. Specifies the password as an alphanumeric string (use if the password contains
  211. printable characters only).
  212. The password must be specified for \s-1PBKDF2\s0 and scrypt.
  213. .IP "\fBhexpass:\fR\fIstring\fR" 4
  214. .IX Item "hexpass:string"
  215. Alternative to the \fBpass:\fR option where
  216. the password is specified in hexadecimal form (two hex digits per byte).
  217. .IP "\fBsalt:\fR\fIstring\fR" 4
  218. .IX Item "salt:string"
  219. Specifies a non-secret unique cryptographic salt as an alphanumeric string
  220. (use if it contains printable characters only).
  221. The length must conform to any restrictions of the \s-1KDF\s0 algorithm.
  222. A salt parameter is required for several \s-1KDF\s0 algorithms,
  223. such as \s-1\fBEVP_KDF\-PBKDF2\s0\fR\|(7).
  224. .IP "\fBhexsalt:\fR\fIstring\fR" 4
  225. .IX Item "hexsalt:string"
  226. Alternative to the \fBsalt:\fR option where
  227. the salt is specified in hexadecimal form (two hex digits per byte).
  228. .IP "\fBinfo:\fR\fIstring\fR" 4
  229. .IX Item "info:string"
  230. Some \s-1KDF\s0 implementations, such as \s-1\fBEVP_KDF\-HKDF\s0\fR\|(7), take an 'info' parameter
  231. for binding the derived key material
  232. to application\- and context-specific information.
  233. Specifies the info, fixed info, other info or shared info argument
  234. as an alphanumeric string (use if it contains printable characters only).
  235. The length must conform to any restrictions of the \s-1KDF\s0 algorithm.
  236. .IP "\fBhexinfo:\fR\fIstring\fR" 4
  237. .IX Item "hexinfo:string"
  238. Alternative to the \fBinfo:\fR option where
  239. the info is specified in hexadecimal form (two hex digits per byte).
  240. .IP "\fBdigest:\fR\fIstring\fR" 4
  241. .IX Item "digest:string"
  242. This option is identical to the \fB\-digest\fR option.
  243. .IP "\fBcipher:\fR\fIstring\fR" 4
  244. .IX Item "cipher:string"
  245. This option is identical to the \fB\-cipher\fR option.
  246. .IP "\fBmac:\fR\fIstring\fR" 4
  247. .IX Item "mac:string"
  248. This option is identical to the \fB\-mac\fR option.
  249. .RE
  250. .RS 4
  251. .RE
  252. .IP "\fB\-provider\fR \fIname\fR" 4
  253. .IX Item "-provider name"
  254. .PD 0
  255. .IP "\fB\-provider\-path\fR \fIpath\fR" 4
  256. .IX Item "-provider-path path"
  257. .IP "\fB\-propquery\fR \fIpropq\fR" 4
  258. .IX Item "-propquery propq"
  259. .PD
  260. See \*(L"Provider Options\*(R" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  261. .IP "\fIkdf_name\fR" 4
  262. .IX Item "kdf_name"
  263. Specifies the name of a supported \s-1KDF\s0 algorithm which will be used.
  264. The supported algorithms names include \s-1TLS1\-PRF, HKDF, SSKDF, PBKDF2,
  265. SSHKDF, X942KDF\-ASN1, X942KDF\-CONCAT, X963KDF\s0 and \s-1SCRYPT.\s0
  266. .SH "EXAMPLES"
  267. .IX Header "EXAMPLES"
  268. Use \s-1TLS1\-PRF\s0 to create a hex-encoded derived key from a secret key and seed:
  269. .PP
  270. .Vb 2
  271. \& openssl kdf \-keylen 16 \-kdfopt digest:SHA2\-256 \-kdfopt key:secret \e
  272. \& \-kdfopt seed:seed TLS1\-PRF
  273. .Ve
  274. .PP
  275. Use \s-1HKDF\s0 to create a hex-encoded derived key from a secret key, salt and info:
  276. .PP
  277. .Vb 2
  278. \& openssl kdf \-keylen 10 \-kdfopt digest:SHA2\-256 \-kdfopt key:secret \e
  279. \& \-kdfopt salt:salt \-kdfopt info:label HKDF
  280. .Ve
  281. .PP
  282. Use \s-1SSKDF\s0 with \s-1KMAC\s0 to create a hex-encoded derived key from a secret key, salt and info:
  283. .PP
  284. .Vb 3
  285. \& openssl kdf \-keylen 64 \-kdfopt mac:KMAC\-128 \-kdfopt maclen:20 \e
  286. \& \-kdfopt hexkey:b74a149a161545 \-kdfopt hexinfo:348a37a2 \e
  287. \& \-kdfopt hexsalt:3638271ccd68a2 SSKDF
  288. .Ve
  289. .PP
  290. Use \s-1SSKDF\s0 with \s-1HMAC\s0 to create a hex-encoded derived key from a secret key, salt and info:
  291. .PP
  292. .Vb 3
  293. \& openssl kdf \-keylen 16 \-kdfopt mac:HMAC \-kdfopt digest:SHA2\-256 \e
  294. \& \-kdfopt hexkey:b74a149a \-kdfopt hexinfo:348a37a2 \e
  295. \& \-kdfopt hexsalt:3638271c SSKDF
  296. .Ve
  297. .PP
  298. Use \s-1SSKDF\s0 with Hash to create a hex-encoded derived key from a secret key, salt and info:
  299. .PP
  300. .Vb 3
  301. \& openssl kdf \-keylen 14 \-kdfopt digest:SHA2\-256 \e
  302. \& \-kdfopt hexkey:6dbdc23f045488 \e
  303. \& \-kdfopt hexinfo:a1b2c3d4 SSKDF
  304. .Ve
  305. .PP
  306. Use \s-1SSHKDF\s0 to create a hex-encoded derived key from a secret key, hash and session_id:
  307. .PP
  308. .Vb 5
  309. \& openssl kdf \-keylen 16 \-kdfopt digest:SHA2\-256 \e
  310. \& \-kdfopt hexkey:0102030405 \e
  311. \& \-kdfopt hexxcghash:06090A \e
  312. \& \-kdfopt hexsession_id:01020304 \e
  313. \& \-kdfopt type:A SSHKDF
  314. .Ve
  315. .PP
  316. Use \s-1PBKDF2\s0 to create a hex-encoded derived key from a password and salt:
  317. .PP
  318. .Vb 2
  319. \& openssl kdf \-keylen 32 \-kdfopt digest:SHA256 \-kdfopt pass:password \e
  320. \& \-kdfopt salt:salt \-kdfopt iter:2 PBKDF2
  321. .Ve
  322. .PP
  323. Use scrypt to create a hex-encoded derived key from a password and salt:
  324. .PP
  325. .Vb 3
  326. \& openssl kdf \-keylen 64 \-kdfopt pass:password \-kdfopt salt:NaCl \e
  327. \& \-kdfopt n:1024 \-kdfopt r:8 \-kdfopt p:16 \e
  328. \& \-kdfopt maxmem_bytes:10485760 SCRYPT
  329. .Ve
  330. .SH "NOTES"
  331. .IX Header "NOTES"
  332. The \s-1KDF\s0 mechanisms that are available will depend on the options
  333. used when building OpenSSL.
  334. .SH "SEE ALSO"
  335. .IX Header "SEE ALSO"
  336. \&\fBopenssl\fR\|(1),
  337. \&\fBopenssl\-pkeyutl\fR\|(1),
  338. \&\s-1\fBEVP_KDF\s0\fR\|(3),
  339. \&\s-1\fBEVP_KDF\-SCRYPT\s0\fR\|(7),
  340. \&\s-1\fBEVP_KDF\-TLS1_PRF\s0\fR\|(7),
  341. \&\s-1\fBEVP_KDF\-PBKDF2\s0\fR\|(7),
  342. \&\s-1\fBEVP_KDF\-HKDF\s0\fR\|(7),
  343. \&\s-1\fBEVP_KDF\-SS\s0\fR\|(7),
  344. \&\s-1\fBEVP_KDF\-SSHKDF\s0\fR\|(7),
  345. \&\s-1\fBEVP_KDF\-X942\-ASN1\s0\fR\|(7),
  346. \&\s-1\fBEVP_KDF\-X942\-CONCAT\s0\fR\|(7),
  347. \&\s-1\fBEVP_KDF\-X963\s0\fR\|(7)
  348. .SH "HISTORY"
  349. .IX Header "HISTORY"
  350. Added in OpenSSL 3.0
  351. .SH "COPYRIGHT"
  352. .IX Header "COPYRIGHT"
  353. Copyright 2019\-2023 The OpenSSL Project Authors. All Rights Reserved.
  354. .PP
  355. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  356. this file except in compliance with the License. You can obtain a copy
  357. in the file \s-1LICENSE\s0 in the source distribution or at
  358. <https://www.openssl.org/source/license.html>.