LIBRESSL-SSL_EXPORT_KEYING_MATERIAL(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

🌸 NAME 🌸

okay so welcome to the Library Functions Manual page for SSL_EXPORT_KEYING_MATERI(3) β€” and yes bestie, this whole page is about SSL_export_keying_material β€” the function for obtaining keying material for application use πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

library β€œlibssl” libcrypto #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);

✨ DESCRIPTION ✨

okay so picture this: during the creation of a TLS or DTLS connection, shared keying material is established between the two endpoints. The function SSL_export_keying_material() enables an application to use some of this keying material for its own purposes in accordance with RFC 5705. slay πŸ’…

An application may need to securely establish the context within which this keying material will be used. 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 must be the same on both sides of the communication β€” no cap, both sides gotta match 🫢

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. literally giving β€œoptional means optional” energy ✨

bestie, subtle but important: 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. so yeah, that distinction is real 😭

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. iconic loophole behavior, iykyk πŸ¦‹


πŸ”₯ RETURN VALUES πŸ”₯

SSL_export_keying_material() returns 1 on success or 0 or -1 on failure. that’s the whole vibe check πŸ’€


πŸ’œ SEE ALSO πŸ’œ

ssl(3) β€” go check it out bestie πŸŽ€


🌈 HISTORY 🌈

SSL_export_keying_material() first appeared in OpenSSL 1.0.1 and has been available since OpenBSD 5.3. periodt ⭐


πŸ’– cute little sign-off: this page is sourced from Debian, dated June 8, 2025, and the footer says SSL_EXPORT_KEYING_MATERIAL(3) β€” mwah, bye bestie 🫢✨

πŸ“¦ where this page comes from