EVP_KDF-KB.7ossl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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 "EVP_KDF-KB 7ossl"
  136. .TH EVP_KDF-KB 7ossl "2024-09-03" "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. EVP_KDF\-KB \- The Key\-Based EVP_KDF implementation
  143. .SH "DESCRIPTION"
  144. .IX Header "DESCRIPTION"
  145. The \s-1EVP_KDF\-KB\s0 algorithm implements the Key-Based key derivation function
  146. (\s-1KBKDF\s0). \s-1KBKDF\s0 derives a key from repeated application of a keyed \s-1MAC\s0 to an
  147. input secret (and other optional values).
  148. .SS "Identity"
  149. .IX Subsection "Identity"
  150. \&\*(L"\s-1KBKDF\*(R"\s0 is the name for this implementation; it can be used with the
  151. \&\fBEVP_KDF_fetch()\fR function.
  152. .SS "Supported parameters"
  153. .IX Subsection "Supported parameters"
  154. The supported parameters are:
  155. .ie n .IP """mode"" (\fB\s-1OSSL_KDF_PARAM_MODE\s0\fR) <\s-1UTF8\s0 string>" 4
  156. .el .IP "``mode'' (\fB\s-1OSSL_KDF_PARAM_MODE\s0\fR) <\s-1UTF8\s0 string>" 4
  157. .IX Item "mode (OSSL_KDF_PARAM_MODE) <UTF8 string>"
  158. The mode parameter determines which flavor of \s-1KBKDF\s0 to use \- currently the
  159. choices are \*(L"counter\*(R" and \*(L"feedback\*(R". \*(L"counter\*(R" is the default, and will be
  160. used if unspecified.
  161. .ie n .IP """mac"" (\fB\s-1OSSL_KDF_PARAM_MAC\s0\fR) <\s-1UTF8\s0 string>" 4
  162. .el .IP "``mac'' (\fB\s-1OSSL_KDF_PARAM_MAC\s0\fR) <\s-1UTF8\s0 string>" 4
  163. .IX Item "mac (OSSL_KDF_PARAM_MAC) <UTF8 string>"
  164. The value is either \s-1CMAC, HMAC, KMAC128\s0 or \s-1KMAC256.\s0
  165. .ie n .IP """digest"" (\fB\s-1OSSL_KDF_PARAM_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
  166. .el .IP "``digest'' (\fB\s-1OSSL_KDF_PARAM_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
  167. .IX Item "digest (OSSL_KDF_PARAM_DIGEST) <UTF8 string>"
  168. .PD 0
  169. .ie n .IP """cipher"" (\fB\s-1OSSL_KDF_PARAM_CIPHER\s0\fR) <\s-1UTF8\s0 string>" 4
  170. .el .IP "``cipher'' (\fB\s-1OSSL_KDF_PARAM_CIPHER\s0\fR) <\s-1UTF8\s0 string>" 4
  171. .IX Item "cipher (OSSL_KDF_PARAM_CIPHER) <UTF8 string>"
  172. .ie n .IP """properties"" (\fB\s-1OSSL_KDF_PARAM_PROPERTIES\s0\fR) <\s-1UTF8\s0 string>" 4
  173. .el .IP "``properties'' (\fB\s-1OSSL_KDF_PARAM_PROPERTIES\s0\fR) <\s-1UTF8\s0 string>" 4
  174. .IX Item "properties (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>"
  175. .ie n .IP """key"" (\fB\s-1OSSL_KDF_PARAM_KEY\s0\fR) <octet string>" 4
  176. .el .IP "``key'' (\fB\s-1OSSL_KDF_PARAM_KEY\s0\fR) <octet string>" 4
  177. .IX Item "key (OSSL_KDF_PARAM_KEY) <octet string>"
  178. .ie n .IP """salt"" (\fB\s-1OSSL_KDF_PARAM_SALT\s0\fR) <octet string>" 4
  179. .el .IP "``salt'' (\fB\s-1OSSL_KDF_PARAM_SALT\s0\fR) <octet string>" 4
  180. .IX Item "salt (OSSL_KDF_PARAM_SALT) <octet string>"
  181. .IP """info (\fB\s-1OSSL_KDF_PARAM_INFO\s0\fR) <octet string>" 4
  182. .IX Item """info (OSSL_KDF_PARAM_INFO) <octet string>"
  183. .ie n .IP """seed"" (\fB\s-1OSSL_KDF_PARAM_SEED\s0\fR) <octet string>" 4
  184. .el .IP "``seed'' (\fB\s-1OSSL_KDF_PARAM_SEED\s0\fR) <octet string>" 4
  185. .IX Item "seed (OSSL_KDF_PARAM_SEED) <octet string>"
  186. .PD
  187. The seed parameter is unused in counter mode.
  188. .ie n .IP """use-l"" (\fB\s-1OSSL_KDF_PARAM_KBKDF_USE_L\s0\fR) <integer>" 4
  189. .el .IP "``use-l'' (\fB\s-1OSSL_KDF_PARAM_KBKDF_USE_L\s0\fR) <integer>" 4
  190. .IX Item "use-l (OSSL_KDF_PARAM_KBKDF_USE_L) <integer>"
  191. Set to \fB0\fR to disable use of the optional Fixed Input data 'L' (see \s-1SP800\-108\s0).
  192. The default value of \fB1\fR will be used if unspecified.
  193. .ie n .IP """use-separator"" (\fB\s-1OSSL_KDF_PARAM_KBKDF_USE_SEPARATOR\s0\fR) <integer>" 4
  194. .el .IP "``use-separator'' (\fB\s-1OSSL_KDF_PARAM_KBKDF_USE_SEPARATOR\s0\fR) <integer>" 4
  195. .IX Item "use-separator (OSSL_KDF_PARAM_KBKDF_USE_SEPARATOR) <integer>"
  196. Set to \fB0\fR to disable use of the optional Fixed Input data 'zero separator'
  197. (see \s-1SP800\-108\s0) that is placed between the Label and Context.
  198. The default value of \fB1\fR will be used if unspecified.
  199. .ie n .IP """r"" (\fB\s-1OSSL_KDF_PARAM_KBKDF_R\s0\fR) <integer>" 4
  200. .el .IP "``r'' (\fB\s-1OSSL_KDF_PARAM_KBKDF_R\s0\fR) <integer>" 4
  201. .IX Item "r (OSSL_KDF_PARAM_KBKDF_R) <integer>"
  202. Set the fixed value 'r', indicating the length of the counter in bits.
  203. .Sp
  204. Supported values are \fB8\fR, \fB16\fR, \fB24\fR, and \fB32\fR.
  205. The default value of \fB32\fR will be used if unspecified.
  206. .PP
  207. Depending on whether mac is \s-1CMAC\s0 or \s-1HMAC,\s0 either digest or cipher is required
  208. (respectively) and the other is unused. They are unused for \s-1KMAC128\s0 and \s-1KMAC256.\s0
  209. .PP
  210. The parameters key, salt, info, and seed correspond to \s-1KI,\s0 Label, Context, and
  211. \&\s-1IV\s0 (respectively) in \s-1SP800\-108.\s0 As in that document, salt, info, and seed are
  212. optional and may be omitted.
  213. .PP
  214. \&\*(L"mac\*(R", \*(L"digest\*(R", cipher\*(L" and \*(R"properties" are described in
  215. \&\*(L"\s-1PARAMETERS\*(R"\s0 in \s-1\fBEVP_KDF\s0\fR\|(3).
  216. .SH "NOTES"
  217. .IX Header "NOTES"
  218. A context for \s-1KBKDF\s0 can be obtained by calling:
  219. .PP
  220. .Vb 2
  221. \& EVP_KDF *kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
  222. \& EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
  223. .Ve
  224. .PP
  225. The output length of an \s-1KBKDF\s0 is specified via the \f(CW\*(C`keylen\*(C'\fR
  226. parameter to the \fBEVP_KDF_derive\fR\|(3) function.
  227. .PP
  228. Note that currently OpenSSL only implements counter and feedback modes. Other
  229. variants may be supported in the future.
  230. .SH "EXAMPLES"
  231. .IX Header "EXAMPLES"
  232. This example derives 10 bytes using \s-1COUNTER\-HMAC\-SHA256,\s0 with \s-1KI\s0 \*(L"secret\*(R",
  233. Label \*(L"label\*(R", and Context \*(L"context\*(R".
  234. .PP
  235. .Vb 4
  236. \& EVP_KDF *kdf;
  237. \& EVP_KDF_CTX *kctx;
  238. \& unsigned char out[10];
  239. \& OSSL_PARAM params[6], *p = params;
  240. \&
  241. \& kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
  242. \& kctx = EVP_KDF_CTX_new(kdf);
  243. \& EVP_KDF_free(kdf);
  244. \&
  245. \& *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
  246. \& "SHA2\-256", 0);
  247. \& *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC,
  248. \& "HMAC", 0);
  249. \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
  250. \& "secret", strlen("secret"));
  251. \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
  252. \& "label", strlen("label"));
  253. \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
  254. \& "context", strlen("context"));
  255. \& *p = OSSL_PARAM_construct_end();
  256. \& if (EVP_KDF_derive(kctx, out, sizeof(out), params) <= 0)
  257. \& error("EVP_KDF_derive");
  258. \&
  259. \& EVP_KDF_CTX_free(kctx);
  260. .Ve
  261. .PP
  262. This example derives 10 bytes using \s-1FEEDBACK\-CMAC\-AES256,\s0 with \s-1KI\s0 \*(L"secret\*(R",
  263. Label \*(L"label\*(R", and \s-1IV\s0 \*(L"sixteen bytes iv\*(R".
  264. .PP
  265. .Vb 5
  266. \& EVP_KDF *kdf;
  267. \& EVP_KDF_CTX *kctx;
  268. \& unsigned char out[10];
  269. \& OSSL_PARAM params[8], *p = params;
  270. \& unsigned char *iv = "sixteen bytes iv";
  271. \&
  272. \& kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
  273. \& kctx = EVP_KDF_CTX_new(kdf);
  274. \& EVP_KDF_free(kdf);
  275. \&
  276. \& *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CIPHER, "AES256", 0);
  277. \& *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC, "CMAC", 0);
  278. \& *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MODE, "FEEDBACK", 0);
  279. \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
  280. \& "secret", strlen("secret"));
  281. \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
  282. \& "label", strlen("label"));
  283. \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
  284. \& "context", strlen("context"));
  285. \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
  286. \& iv, strlen(iv));
  287. \& *p = OSSL_PARAM_construct_end();
  288. \& if (EVP_KDF_derive(kctx, out, sizeof(out), params) <= 0)
  289. \& error("EVP_KDF_derive");
  290. \&
  291. \& EVP_KDF_CTX_free(kctx);
  292. .Ve
  293. .SH "CONFORMING TO"
  294. .IX Header "CONFORMING TO"
  295. \&\s-1NIST SP800\-108, IETF RFC 6803, IETF RFC 8009.\s0
  296. .SH "SEE ALSO"
  297. .IX Header "SEE ALSO"
  298. \&\s-1\fBEVP_KDF\s0\fR\|(3),
  299. \&\fBEVP_KDF_CTX_free\fR\|(3),
  300. \&\fBEVP_KDF_CTX_get_kdf_size\fR\|(3),
  301. \&\fBEVP_KDF_derive\fR\|(3),
  302. \&\*(L"\s-1PARAMETERS\*(R"\s0 in \s-1\fBEVP_KDF\s0\fR\|(3)
  303. .SH "HISTORY"
  304. .IX Header "HISTORY"
  305. This functionality was added in OpenSSL 3.0.
  306. .PP
  307. Support for \s-1KMAC\s0 was added in OpenSSL 3.1.
  308. .SH "COPYRIGHT"
  309. .IX Header "COPYRIGHT"
  310. Copyright 2019\-2022 The OpenSSL Project Authors. All Rights Reserved.
  311. Copyright 2019 Red Hat, Inc.
  312. .PP
  313. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  314. this file except in compliance with the License. You can obtain a copy
  315. in the file \s-1LICENSE\s0 in the source distribution or at
  316. <https://www.openssl.org/source/license.html>.