SSL_EXPORT_KEYING_MATERIAL(3ossl)
π SSL_EXPORT_KEYING_MATERIAL π
okay bestie, this is the SSL_EXPORT_KEYING_MATERIAL(3ossl) page from the OpenSSL manual set. yes, we're doing crypto lore today, and honestly? it's giving main character energy. π
β¨ NAME β¨
SSL_export_keying_material, SSL_export_keying_material_early β obtain keying material for application use π¦
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,
const char *label, size_t llen,
const unsigned char *context,
size_t contextlen, int use_context);
int SSL_export_keying_material_early(SSL *s, unsigned char *out, size_t olen,
const char *label, size_t llen,
const unsigned char *context,
size_t contextlen);
π DESCRIPTION π
so when a TLS or DTLS connection gets built, the two endpoints establish shared keying material together. iconic. and the functions SSL_export_keying_material() and SSL_export_keying_material_early() let an application borrow some of that keying material for its own lil purposes β all per RFC5705 (for TLSv1.2 and below) or RFC8446 (for TLSv1.3). no cap. β¨
SSL_export_keying_material() derives keying material using the exporter_master_secret established in the handshake. slay.
SSL_export_keying_material_early() is only usable with TLSv1.3, and it derives keying material using the early_exporter_master_secret (as defined in the TLS 1.3 RFC). here's the tea tho:
- for the client, the
early_exporter_master_secretis only available when the client attempts to send 0-RTT data. - for the server, it is only available when the server accepts 0-RTT data.
fr fr, no 0-RTT, no early secret. π
An application may need to securely establish the context within which this keying material will be used. like, for example, this may include identifiers for the application session, application algorithms or parameters, or the lifetime of the context. The context value is left to the application β but it must be the same on both sides of the communication. both sides. besties. matching. or it's not gonna vibe. π
For a given SSL connection s, olen bytes of data will be written to out. The application specific context should be supplied in the location pointed to by context and should be contextlen bytes long. Provision of a context is optional. If the context should be omitted entirely then use_context should be set to 0. Otherwise it should be any other value. If use_context is 0 then the values of context and contextlen are ignored.
π¨ okay this part matters, listen up π¨ Note that in TLSv1.2 and below a zero length context is treated differently from no context at all, and will result in different keying material being returned. In TLSv1.3 a zero length context is that same as no context at all and will result in the same keying material being returned.
An application specific label should be provided in the location pointed to by label and should be llen bytes long. Typically this will be a value from the IANA Exporter Label Registry:
https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels
Alternatively, labels beginning with "EXPERIMENTAL" are permitted by the standard to be used without registration. (the β¨vibesβ¨ label, iykyk.) TLSv1.3 imposes a maximum label length of 249 bytes. don't push it. π
Note that this function is only defined for TLSv1.0 and above, and DTLSv1.0 and above. Attempting to use it in SSLv3 will result in an error. SSLv3 is not invited to this party. π
π RETURN VALUES π
SSL_export_keying_material()β returns0or-1on failure, or1on success. π«ΆSSL_export_keying_material_early()β returns0on failure, or1on success. π
π¦ SEE ALSO π¦
β HISTORY β
The SSL_export_keying_material_early() function was added in OpenSSL 1.1.1. a legend was born. π
π COPYRIGHT π
Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.
and that's the whole page bestie, mwah π
this was SSL_EXPORT_KEYING_MATERIAL(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β go forth and export that keying material responsibly, queen. ππ
β¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms