SSL_export_keying_material.pod 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. =pod
  2. =head1 NAME
  3. SSL_export_keying_material,
  4. SSL_export_keying_material_early
  5. - obtain keying material for application use
  6. =head1 SYNOPSIS
  7. #include <openssl/ssl.h>
  8. int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,
  9. const char *label, size_t llen,
  10. const unsigned char *context,
  11. size_t contextlen, int use_context);
  12. int SSL_export_keying_material_early(SSL *s, unsigned char *out, size_t olen,
  13. const char *label, size_t llen,
  14. const unsigned char *context,
  15. size_t contextlen);
  16. =head1 DESCRIPTION
  17. During the creation of a TLS or DTLS connection shared keying material is
  18. established between the two endpoints. The functions
  19. SSL_export_keying_material() and SSL_export_keying_material_early() enable an
  20. application to use some of this keying material for its own purposes in
  21. accordance with RFC5705 (for TLSv1.2 and below) or RFC8446 (for TLSv1.3).
  22. SSL_export_keying_material() derives keying material using
  23. the F<exporter_master_secret> established in the handshake.
  24. SSL_export_keying_material_early() is only usable with TLSv1.3, and derives
  25. keying material using the F<early_exporter_master_secret> (as defined in the
  26. TLS 1.3 RFC). For the client, the F<early_exporter_master_secret> is only
  27. available when the client attempts to send 0-RTT data. For the server, it is
  28. only available when the server accepts 0-RTT data.
  29. An application may need to securely establish the context within which this
  30. keying material will be used. For example this may include identifiers for the
  31. application session, application algorithms or parameters, or the lifetime of
  32. the context. The context value is left to the application but must be the same
  33. on both sides of the communication.
  34. For a given SSL connection B<s>, B<olen> bytes of data will be written to
  35. B<out>. The application specific context should be supplied in the location
  36. pointed to by B<context> and should be B<contextlen> bytes long. Provision of
  37. a context is optional. If the context should be omitted entirely then
  38. B<use_context> should be set to 0. Otherwise it should be any other value. If
  39. B<use_context> is 0 then the values of B<context> and B<contextlen> are ignored.
  40. Note that in TLSv1.2 and below a zero length context is treated differently from
  41. no context at all, and will result in different keying material being returned.
  42. In TLSv1.3 a zero length context is that same as no context at all and will
  43. result in the same keying material being returned.
  44. An application specific label should be provided in the location pointed to by
  45. B<label> and should be B<llen> bytes long. Typically this will be a value from
  46. the IANA Exporter Label Registry
  47. (L<https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels>).
  48. Alternatively labels beginning with "EXPERIMENTAL" are permitted by the standard
  49. to be used without registration. TLSv1.3 imposes a maximum label length of
  50. 249 bytes.
  51. Note that this function is only defined for TLSv1.0 and above, and DTLSv1.0 and
  52. above. Attempting to use it in SSLv3 will result in an error.
  53. =head1 RETURN VALUES
  54. SSL_export_keying_material() returns 0 or -1 on failure or 1 on success.
  55. SSL_export_keying_material_early() returns 0 on failure or 1 on success.
  56. =head1 HISTORY
  57. The SSL_export_keying_material_early() function was added in OpenSSL 1.1.1.
  58. =head1 COPYRIGHT
  59. Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  60. Licensed under the Apache License 2.0 (the "License"). You may not use
  61. this file except in compliance with the License. You can obtain a copy
  62. in the file LICENSE in the source distribution or at
  63. L<https://www.openssl.org/source/license.html>.
  64. =cut