openssl-kdf.pod.in 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. =pod
  2. {- OpenSSL::safe::output_do_not_edit_headers(); -}
  3. =head1 NAME
  4. openssl-kdf - perform Key Derivation Function operations
  5. =head1 SYNOPSIS
  6. B<openssl kdf>
  7. [B<-help>]
  8. [B<-cipher>]
  9. [B<-digest>]
  10. [B<-mac>]
  11. [B<-kdfopt> I<nm>:I<v>]
  12. [B<-keylen> I<num>]
  13. [B<-out> I<filename>]
  14. [B<-binary>]
  15. {- $OpenSSL::safe::opt_provider_synopsis -}
  16. I<kdf_name>
  17. =head1 DESCRIPTION
  18. The key derivation functions generate a derived key from either a secret or
  19. password.
  20. =head1 OPTIONS
  21. =over 4
  22. =item B<-help>
  23. Print a usage message.
  24. =item B<-keylen> I<num>
  25. The output size of the derived key. This field is required.
  26. =item B<-out> I<filename>
  27. Filename to output to, or standard output by default.
  28. =item B<-binary>
  29. Output the derived key in binary form. Uses hexadecimal text format if not specified.
  30. =item B<-cipher> I<name>
  31. Specify the cipher to be used by the KDF.
  32. Not all KDFs require a cipher and it is an error to use this option in such
  33. cases.
  34. =item B<-digest> I<name>
  35. Specify the digest to be used by the KDF.
  36. Not all KDFs require a digest and it is an error to use this option in such
  37. cases.
  38. To see the list of supported digests, use C<openssl list -digest-commands>.
  39. =item B<-mac> I<name>
  40. Specify the MAC to be used by the KDF.
  41. Not all KDFs require a MAC and it is an error to use this option in such
  42. cases.
  43. =item B<-kdfopt> I<nm>:I<v>
  44. Passes options to the KDF algorithm.
  45. A comprehensive list of parameters can be found in L<EVP_KDF(3)/PARAMETERS>.
  46. Common parameter names used by EVP_KDF_CTX_set_params() are:
  47. =over 4
  48. =item B<key:>I<string>
  49. Specifies the secret key as an alphanumeric string (use if the key contains
  50. printable characters only).
  51. The string length must conform to any restrictions of the KDF algorithm.
  52. A key must be specified for most KDF algorithms.
  53. =item B<hexkey:>I<string>
  54. Alternative to the B<key:> option where
  55. the secret key is specified in hexadecimal form (two hex digits per byte).
  56. =item B<pass:>I<string>
  57. Specifies the password as an alphanumeric string (use if the password contains
  58. printable characters only).
  59. The password must be specified for PBKDF2 and scrypt.
  60. =item B<hexpass:>I<string>
  61. Alternative to the B<pass:> option where
  62. the password is specified in hexadecimal form (two hex digits per byte).
  63. =item B<salt:>I<string>
  64. Specifies a non-secret unique cryptographic salt as an alphanumeric string
  65. (use if it contains printable characters only).
  66. The length must conform to any restrictions of the KDF algorithm.
  67. A salt parameter is required for several KDF algorithms,
  68. such as L<EVP_KDF-PBKDF2(7)>.
  69. =item B<hexsalt:>I<string>
  70. Alternative to the B<salt:> option where
  71. the salt is specified in hexadecimal form (two hex digits per byte).
  72. =item B<info:>I<string>
  73. Some KDF implementations, such as L<EVP_KDF-HKDF(7)>, take an 'info' parameter
  74. for binding the derived key material
  75. to application- and context-specific information.
  76. Specifies the info, fixed info, other info or shared info argument
  77. as an alphanumeric string (use if it contains printable characters only).
  78. The length must conform to any restrictions of the KDF algorithm.
  79. =item B<hexinfo:>I<string>
  80. Alternative to the B<info:> option where
  81. the info is specified in hexadecimal form (two hex digits per byte).
  82. =item B<digest:>I<string>
  83. This option is identical to the B<-digest> option.
  84. =item B<cipher:>I<string>
  85. This option is identical to the B<-cipher> option.
  86. =item B<mac:>I<string>
  87. This option is identical to the B<-mac> option.
  88. =back
  89. {- $OpenSSL::safe::opt_provider_item -}
  90. =item I<kdf_name>
  91. Specifies the name of a supported KDF algorithm which will be used.
  92. The supported algorithms names include TLS1-PRF, HKDF, SSKDF, PBKDF2,
  93. SSHKDF, X942KDF-ASN1, X942KDF-CONCAT, X963KDF and SCRYPT.
  94. =back
  95. =head1 EXAMPLES
  96. Use TLS1-PRF to create a hex-encoded derived key from a secret key and seed:
  97. openssl kdf -keylen 16 -kdfopt digest:SHA2-256 -kdfopt key:secret \
  98. -kdfopt seed:seed TLS1-PRF
  99. Use HKDF to create a hex-encoded derived key from a secret key, salt and info:
  100. openssl kdf -keylen 10 -kdfopt digest:SHA2-256 -kdfopt key:secret \
  101. -kdfopt salt:salt -kdfopt info:label HKDF
  102. Use SSKDF with KMAC to create a hex-encoded derived key from a secret key, salt and info:
  103. openssl kdf -keylen 64 -kdfopt mac:KMAC-128 -kdfopt maclen:20 \
  104. -kdfopt hexkey:b74a149a161545 -kdfopt hexinfo:348a37a2 \
  105. -kdfopt hexsalt:3638271ccd68a2 SSKDF
  106. Use SSKDF with HMAC to create a hex-encoded derived key from a secret key, salt and info:
  107. openssl kdf -keylen 16 -kdfopt mac:HMAC -kdfopt digest:SHA2-256 \
  108. -kdfopt hexkey:b74a149a -kdfopt hexinfo:348a37a2 \
  109. -kdfopt hexsalt:3638271c SSKDF
  110. Use SSKDF with Hash to create a hex-encoded derived key from a secret key, salt and info:
  111. openssl kdf -keylen 14 -kdfopt digest:SHA2-256 \
  112. -kdfopt hexkey:6dbdc23f045488 \
  113. -kdfopt hexinfo:a1b2c3d4 SSKDF
  114. Use SSHKDF to create a hex-encoded derived key from a secret key, hash and session_id:
  115. openssl kdf -keylen 16 -kdfopt digest:SHA2-256 \
  116. -kdfopt hexkey:0102030405 \
  117. -kdfopt hexxcghash:06090A \
  118. -kdfopt hexsession_id:01020304 \
  119. -kdfopt type:A SSHKDF
  120. Use PBKDF2 to create a hex-encoded derived key from a password and salt:
  121. openssl kdf -keylen 32 -kdfopt digest:SHA256 -kdfopt pass:password \
  122. -kdfopt salt:salt -kdfopt iter:2 PBKDF2
  123. Use scrypt to create a hex-encoded derived key from a password and salt:
  124. openssl kdf -keylen 64 -kdfopt pass:password -kdfopt salt:NaCl \
  125. -kdfopt n:1024 -kdfopt r:8 -kdfopt p:16 \
  126. -kdfopt maxmem_bytes:10485760 SCRYPT
  127. =head1 NOTES
  128. The KDF mechanisms that are available will depend on the options
  129. used when building OpenSSL.
  130. =head1 SEE ALSO
  131. L<openssl(1)>,
  132. L<openssl-pkeyutl(1)>,
  133. L<EVP_KDF(3)>,
  134. L<EVP_KDF-SCRYPT(7)>,
  135. L<EVP_KDF-TLS1_PRF(7)>,
  136. L<EVP_KDF-PBKDF2(7)>,
  137. L<EVP_KDF-HKDF(7)>,
  138. L<EVP_KDF-SS(7)>,
  139. L<EVP_KDF-SSHKDF(7)>,
  140. L<EVP_KDF-X942-ASN1(7)>,
  141. L<EVP_KDF-X942-CONCAT(7)>,
  142. L<EVP_KDF-X963(7)>
  143. =head1 HISTORY
  144. Added in OpenSSL 3.0
  145. =head1 COPYRIGHT
  146. Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
  147. Licensed under the Apache License 2.0 (the "License"). You may not use
  148. this file except in compliance with the License. You can obtain a copy
  149. in the file LICENSE in the source distribution or at
  150. L<https://www.openssl.org/source/license.html>.
  151. =cut