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