1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimSSL_export_keying_material, 6e71b7053SJung-uk KimSSL_export_keying_material_early 7e71b7053SJung-uk Kim- obtain keying material for application use 8e71b7053SJung-uk Kim 9e71b7053SJung-uk Kim=head1 SYNOPSIS 10e71b7053SJung-uk Kim 11e71b7053SJung-uk Kim #include <openssl/ssl.h> 12e71b7053SJung-uk Kim 13e71b7053SJung-uk Kim int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, 14e71b7053SJung-uk Kim const char *label, size_t llen, 15e71b7053SJung-uk Kim const unsigned char *context, 16e71b7053SJung-uk Kim size_t contextlen, int use_context); 17e71b7053SJung-uk Kim 18e71b7053SJung-uk Kim int SSL_export_keying_material_early(SSL *s, unsigned char *out, size_t olen, 19e71b7053SJung-uk Kim const char *label, size_t llen, 20e71b7053SJung-uk Kim const unsigned char *context, 21e71b7053SJung-uk Kim size_t contextlen); 22e71b7053SJung-uk Kim 23e71b7053SJung-uk Kim=head1 DESCRIPTION 24e71b7053SJung-uk Kim 25e71b7053SJung-uk KimDuring the creation of a TLS or DTLS connection shared keying material is 26e71b7053SJung-uk Kimestablished between the two endpoints. The functions 27e71b7053SJung-uk KimSSL_export_keying_material() and SSL_export_keying_material_early() enable an 28e71b7053SJung-uk Kimapplication to use some of this keying material for its own purposes in 29e71b7053SJung-uk Kimaccordance with RFC5705 (for TLSv1.2 and below) or RFC8446 (for TLSv1.3). 30e71b7053SJung-uk Kim 31e71b7053SJung-uk KimSSL_export_keying_material() derives keying material using 32e71b7053SJung-uk Kimthe F<exporter_master_secret> established in the handshake. 33e71b7053SJung-uk Kim 34e71b7053SJung-uk KimSSL_export_keying_material_early() is only usable with TLSv1.3, and derives 35e71b7053SJung-uk Kimkeying material using the F<early_exporter_master_secret> (as defined in the 36e71b7053SJung-uk KimTLS 1.3 RFC). For the client, the F<early_exporter_master_secret> is only 37e71b7053SJung-uk Kimavailable when the client attempts to send 0-RTT data. For the server, it is 38e71b7053SJung-uk Kimonly available when the server accepts 0-RTT data. 39e71b7053SJung-uk Kim 40e71b7053SJung-uk KimAn application may need to securely establish the context within which this 41e71b7053SJung-uk Kimkeying material will be used. For example this may include identifiers for the 42e71b7053SJung-uk Kimapplication session, application algorithms or parameters, or the lifetime of 43e71b7053SJung-uk Kimthe context. The context value is left to the application but must be the same 44e71b7053SJung-uk Kimon both sides of the communication. 45e71b7053SJung-uk Kim 46e71b7053SJung-uk KimFor a given SSL connection B<s>, B<olen> bytes of data will be written to 47e71b7053SJung-uk KimB<out>. The application specific context should be supplied in the location 48e71b7053SJung-uk Kimpointed to by B<context> and should be B<contextlen> bytes long. Provision of 49e71b7053SJung-uk Kima context is optional. If the context should be omitted entirely then 50e71b7053SJung-uk KimB<use_context> should be set to 0. Otherwise it should be any other value. If 51e71b7053SJung-uk KimB<use_context> is 0 then the values of B<context> and B<contextlen> are ignored. 52e71b7053SJung-uk KimNote that in TLSv1.2 and below a zero length context is treated differently from 53e71b7053SJung-uk Kimno context at all, and will result in different keying material being returned. 54e71b7053SJung-uk KimIn TLSv1.3 a zero length context is that same as no context at all and will 55e71b7053SJung-uk Kimresult in the same keying material being returned. 56e71b7053SJung-uk Kim 57e71b7053SJung-uk KimAn application specific label should be provided in the location pointed to by 58e71b7053SJung-uk KimB<label> and should be B<llen> bytes long. Typically this will be a value from 59e71b7053SJung-uk Kimthe IANA Exporter Label Registry 60e71b7053SJung-uk Kim(L<https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels>). 61e71b7053SJung-uk KimAlternatively labels beginning with "EXPERIMENTAL" are permitted by the standard 626935a639SJung-uk Kimto be used without registration. TLSv1.3 imposes a maximum label length of 636935a639SJung-uk Kim249 bytes. 64e71b7053SJung-uk Kim 65e71b7053SJung-uk KimNote that this function is only defined for TLSv1.0 and above, and DTLSv1.0 and 66e71b7053SJung-uk Kimabove. Attempting to use it in SSLv3 will result in an error. 67e71b7053SJung-uk Kim 68e71b7053SJung-uk Kim=head1 RETURN VALUES 69e71b7053SJung-uk Kim 70e71b7053SJung-uk KimSSL_export_keying_material() returns 0 or -1 on failure or 1 on success. 71e71b7053SJung-uk Kim 72e71b7053SJung-uk KimSSL_export_keying_material_early() returns 0 on failure or 1 on success. 73e71b7053SJung-uk Kim 74*b077aed3SPierre Pronchery=head1 SEE ALSO 75*b077aed3SPierre Pronchery 76*b077aed3SPierre ProncheryL<ssl(7)> 77*b077aed3SPierre Pronchery 78e71b7053SJung-uk Kim=head1 HISTORY 79e71b7053SJung-uk Kim 806935a639SJung-uk KimThe SSL_export_keying_material_early() function was added in OpenSSL 1.1.1. 81e71b7053SJung-uk Kim 82e71b7053SJung-uk Kim=head1 COPYRIGHT 83e71b7053SJung-uk Kim 84e71b7053SJung-uk KimCopyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. 85e71b7053SJung-uk Kim 86*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 87e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 88e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 89e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 90e71b7053SJung-uk Kim 91e71b7053SJung-uk Kim=cut 92