From b0e0c2a654d791543cd5728163e6912b085e09e8 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 26 Oct 2017 17:55:50 +1100 Subject: src/openssl.c: Add compat routines for SSL_SESSION_get_master_key --- src/openssl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/openssl.c b/src/openssl.c index 0633edd..be0fa58 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -357,6 +357,10 @@ #define HAVE_SSL_OP_NO_DTLS_MASK OPENSSL_PREREQ(1,1,0) #endif +#ifndef HAVE_SSL_SESSION_MASTER_KEY +#define HAVE_SSL_SESSION_MASTER_KEY OPENSSL_PREREQ(1,1,0) +#endif + #ifndef HAVE_STACK_OPENSSL_STRING_FUNCS #define HAVE_STACK_OPENSSL_STRING_FUNCS (OPENSSL_PREREQ(1,0,0) || LIBRESSL_PREREQ(2,0,0)) #endif @@ -1723,6 +1727,22 @@ static size_t compat_SSL_get_client_random(const SSL *ssl, unsigned char *out, s } #endif +#if !HAVE_SSL_SESSION_MASTER_KEY +#define SSL_SESSION_get_master_key(...) EXPAND( compat_SSL_SESSION_get_master_key(__VA_ARGS__) ) +static size_t compat_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen) { + if (session->master_key_length < 0) { + /* Should never happen */ + return 0; + } + if (outlen == 0) + return session->master_key_length; + if (outlen > (size_t)session->master_key_length) + outlen = session->master_key_length; + memcpy(out, session->master_key, outlen); + return outlen; +} +#endif + #if !HAVE_SSL_CLIENT_VERSION #define SSL_client_version(...) EXPAND( compat_SSL_client_version(__VA_ARGS__) ) -- cgit v1.2.3-59-g8ed1b