SSL_EXPORT_KEYING_MATERIAL(3SSL)
π SSL_EXPORT_KEYING_MATERIAL π
okay bestie, so this is the 3SSL manual page β it's from OpenSSL and it's literally about stealing (affectionately) some of the secret sauce your TLS connection already made, so your app can use it too. no cap.
β¨ 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 vibe-check each other and establish shared keying material between them. cute, iconic. and these two functions β SSL_export_keying_material() and SSL_export_keying_material_early() β let your application take some of that keying material and use it for its own lil purposes, following RFC5705 (for TLSv1.2 and below) or RFC8446 (for TLSv1.3). π
SSL_export_keying_material() derives keying material using the exporter_master_secret that got established in the handshake. yes, that's the whole vibe.
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, okurrr). 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.
ngl, an application might need to securely establish the context within which this keying material is gonna be used. like, for example this could include identifiers for the application session, application algorithms or parameters, or the lifetime of the context. the context value is left up to the application, BUT β and this is the important part, bestie β it must be the same on both sides of the communication. fr fr. no mismatches.
so 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. providing a context is optional, you're not obligated. if the context should be omitted entirely then use_context should be set to 0. otherwise it should be any other value. and if use_context is 0 then the values of context and contextlen are just... ignored. π
β οΈ okay so mind the gap: 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. meanwhile in TLSv1.3 a zero length context is the same as no context at all and will result in the same keying material being returned. it's giving "same word, different meaning depending on the era". π
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 β go off, unregistered queen. β¨ and heads up: TLSv1.3 imposes a maximum label length of 249 bytes.
β οΈ also 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. so like, don't.
π 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 whole era.
π 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 β version 4.0.3, dated 2026-09-29, SSL_EXPORT_KEYING_MATERIAL(3SSL), and yes this manual page ate and left no crumbs. periodt. π
β¨π¦
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms