SSL_export_keying_material − obtain keying material for application use
#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);
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 RFC5705.
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.
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. Note that a zero length context is treated differently to no context at all, and will result in different 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.
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.
SSL_export_keying_material() returns 0 or −1 on failure or 1 on success.
Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the OpenSSL license (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>.