2
0

EVP_KDF-TLS1_PRF.pod 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. =pod
  2. =head1 NAME
  3. EVP_KDF-TLS1_PRF - The TLS1 PRF EVP_KDF implementation
  4. =head1 DESCRIPTION
  5. Support for computing the B<TLS1> PRF through the B<EVP_KDF> API.
  6. The EVP_KDF-TLS1_PRF algorithm implements the PRF used by TLS versions up to
  7. and including TLS 1.2.
  8. =head2 Identity
  9. "TLS1-PRF" is the name for this implementation; it
  10. can be used with the EVP_KDF_fetch() function.
  11. =head2 Supported parameters
  12. The supported parameters are:
  13. =over 4
  14. =item "properties" (B<OSSL_KDF_PARAM_PROPERTIES>) <UTF8 string>
  15. =item "digest" (B<OSSL_KDF_PARAM_DIGEST>) <UTF8 string>
  16. These parameters work as described in L<EVP_KDF(3)/PARAMETERS>.
  17. The B<OSSL_KDF_PARAM_DIGEST> parameter is used to set the message digest
  18. associated with the TLS PRF.
  19. EVP_md5_sha1() is treated as a special case which uses the
  20. PRF algorithm using both B<MD5> and B<SHA1> as used in TLS 1.0 and 1.1.
  21. =item "secret" (B<OSSL_KDF_PARAM_SECRET>) <octet string>
  22. This parameter sets the secret value of the TLS PRF.
  23. Any existing secret value is replaced.
  24. =item "seed" (B<OSSL_KDF_PARAM_SEED>) <octet string>
  25. This parameter sets the context seed.
  26. The length of the context seed cannot exceed 1024 bytes;
  27. this should be more than enough for any normal use of the TLS PRF.
  28. =back
  29. =head1 NOTES
  30. A context for the TLS PRF can be obtained by calling:
  31. EVP_KDF *kdf = EVP_KDF_fetch(NULL, "TLS1-PRF", NULL);
  32. EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
  33. The digest, secret value and seed must be set before a key is derived otherwise
  34. an error will occur.
  35. The output length of the PRF is specified by the I<keylen> parameter to the
  36. EVP_KDF_derive() function.
  37. =head1 EXAMPLES
  38. This example derives 10 bytes using SHA-256 with the secret key "secret"
  39. and seed value "seed":
  40. EVP_KDF *kdf;
  41. EVP_KDF_CTX *kctx;
  42. unsigned char out[10];
  43. OSSL_PARAM params[4], *p = params;
  44. kdf = EVP_KDF_fetch(NULL, "TLS1-PRF", NULL);
  45. kctx = EVP_KDF_CTX_new(kdf);
  46. EVP_KDF_free(kdf);
  47. *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
  48. SN_sha256, strlen(SN_sha256));
  49. *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET,
  50. "secret", (size_t)6);
  51. *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
  52. "seed", (size_t)4);
  53. *p = OSSL_PARAM_construct_end();
  54. if (EVP_KDF_CTX_set_params(kctx, params) <= 0) {
  55. error("EVP_KDF_CTX_set_params");
  56. }
  57. if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
  58. error("EVP_KDF_derive");
  59. }
  60. EVP_KDF_CTX_free(kctx);
  61. =head1 CONFORMING TO
  62. RFC 2246, RFC 5246 and NIST SP 800-135 r1
  63. =head1 SEE ALSO
  64. L<EVP_KDF(3)>,
  65. L<EVP_KDF_CTX_new(3)>,
  66. L<EVP_KDF_CTX_free(3)>,
  67. L<EVP_KDF_CTX_set_params(3)>,
  68. L<EVP_KDF_derive(3)>,
  69. L<EVP_KDF(3)/PARAMETERS>
  70. =head1 COPYRIGHT
  71. Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
  72. Licensed under the Apache License 2.0 (the "License"). You may not use
  73. this file except in compliance with the License. You can obtain a copy
  74. in the file LICENSE in the source distribution or at
  75. L<https://www.openssl.org/source/license.html>.
  76. =cut