openssl-kdf.pod.in 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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<-kdfopt> I<nm>:I<v>]
  9. [B<-keylen> I<num>]
  10. [B<-out> I<filename>]
  11. [B<-binary>]
  12. {- $OpenSSL::safe::opt_provider_synopsis -}
  13. I<kdf_name>
  14. =head1 DESCRIPTION
  15. The key derivation functions generate a derived key from either a secret or
  16. password.
  17. =head1 OPTIONS
  18. =over 4
  19. =item B<-help>
  20. Print a usage message.
  21. =item B<-keylen> I<num>
  22. The output size of the derived key. This field is required.
  23. =item B<-out> I<filename>
  24. Filename to output to, or standard output by default.
  25. =item B<-binary>
  26. Output the derived key in binary form. Uses hexadecimal text format if not specified.
  27. =item B<-kdfopt> I<nm>:I<v>
  28. Passes options to the KDF algorithm.
  29. A comprehensive list of parameters can be found in the EVP_KDF_CTX
  30. implementation documentation.
  31. Common parameter names used by EVP_KDF_CTX_set_params() are:
  32. =over 4
  33. =item B<key:>I<string>
  34. Specifies the secret key as an alphanumeric string (use if the key contains
  35. printable characters only).
  36. The string length must conform to any restrictions of the KDF algorithm.
  37. A key must be specified for most KDF algorithms.
  38. =item B<hexkey:>I<string>
  39. Specifies the secret key in hexadecimal form (two hex digits per byte).
  40. The key length must conform to any restrictions of the KDF algorithm.
  41. A key must be specified for most KDF algorithms.
  42. =item B<pass:>I<string>
  43. Specifies the password as an alphanumeric string (use if the password contains
  44. printable characters only).
  45. The password must be specified for PBKDF2 and scrypt.
  46. =item B<hexpass:>I<string>
  47. Specifies the password in hexadecimal form (two hex digits per byte).
  48. The password must be specified for PBKDF2 and scrypt.
  49. =item B<digest:>I<string>
  50. Specifies the name of a digest as an alphanumeric string.
  51. To see the list of supported digests, use the command I<list -digest-commands>.
  52. =back
  53. {- $OpenSSL::safe::opt_provider_item -}
  54. =item I<kdf_name>
  55. Specifies the name of a supported KDF algorithm which will be used.
  56. The supported algorithms names include TLS1-PRF, HKDF, SSKDF, PBKDF2,
  57. SSHKDF, X942KDF, X963KDF and SCRYPT.
  58. =back
  59. =head1 EXAMPLES
  60. Use TLS1-PRF to create a hex-encoded derived key from a secret key and seed:
  61. openssl kdf -keylen 16 -kdfopt digest:SHA2-256 -kdfopt key:secret \
  62. -kdfopt seed:seed TLS1-PRF
  63. Use HKDF to create a hex-encoded derived key from a secret key, salt and info:
  64. openssl kdf -keylen 10 -kdfopt digest:SHA2-256 -kdfopt key:secret \
  65. -kdfopt salt:salt -kdfopt info:label HKDF
  66. Use SSKDF with KMAC to create a hex-encoded derived key from a secret key, salt and info:
  67. openssl kdf -keylen 64 -kdfopt mac:KMAC-128 -kdfopt maclen:20 \
  68. -kdfopt hexkey:b74a149a161545 -kdfopt hexinfo:348a37a2 \
  69. -kdfopt hexsalt:3638271ccd68a2 SSKDF
  70. Use SSKDF with HMAC to create a hex-encoded derived key from a secret key, salt and info:
  71. openssl kdf -keylen 16 -kdfopt mac:HMAC -kdfopt digest:SHA2-256 \
  72. -kdfopt hexkey:b74a149a -kdfopt hexinfo:348a37a2 \
  73. -kdfopt hexsalt:3638271c SSKDF
  74. Use SSKDF with Hash to create a hex-encoded derived key from a secret key, salt and info:
  75. openssl kdf -keylen 14 -kdfopt digest:SHA2-256 \
  76. -kdfopt hexkey:6dbdc23f045488 \
  77. -kdfopt hexinfo:a1b2c3d4 SSKDF
  78. Use SSHKDF to create a hex-encoded derived key from a secret key, hash and session_id:
  79. openssl kdf -keylen 16 -kdfopt digest:SHA2-256 \
  80. -kdfopt hexkey:0102030405 \
  81. -kdfopt hexxcghash:06090A \
  82. -kdfopt hexsession_id:01020304 \
  83. -kdfopt type:A SSHKDF
  84. Use PBKDF2 to create a hex-encoded derived key from a password and salt:
  85. openssl kdf -keylen 32 -kdfopt digest:SHA256 -kdfopt pass:password \
  86. -kdfopt salt:salt -kdfopt iter:2 PBKDF2
  87. Use scrypt to create a hex-encoded derived key from a password and salt:
  88. openssl kdf -keylen 64 -kdfopt pass:password -kdfopt salt:NaCl \
  89. -kdfopt N:1024 -kdfopt r:8 -kdfopt p:16 \
  90. -kdfopt maxmem_bytes:10485760 SCRYPT
  91. =head1 NOTES
  92. The KDF mechanisms that are available will depend on the options
  93. used when building OpenSSL.
  94. =head1 SEE ALSO
  95. L<openssl(1)>,
  96. L<openssl-pkeyutl(1)>,
  97. L<EVP_KDF(3)>,
  98. L<EVP_KDF-SCRYPT(7)>,
  99. L<EVP_KDF-TLS1_PRF(7)>,
  100. L<EVP_KDF-PBKDF2(7)>,
  101. L<EVP_KDF-HKDF(7)>,
  102. L<EVP_KDF-SS(7)>,
  103. L<EVP_KDF-SSHKDF(7)>,
  104. L<EVP_KDF-X942(7)>,
  105. L<EVP_KDF-X963(7)>
  106. =head1 HISTORY
  107. Added in OpenSSL 3.0
  108. =head1 COPYRIGHT
  109. Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  110. Licensed under the Apache License 2.0 (the "License"). You may not use
  111. this file except in compliance with the License. You can obtain a copy
  112. in the file LICENSE in the source distribution or at
  113. L<https://www.openssl.org/source/license.html>.
  114. =cut