diff options
author | daurnimator <quae@daurnimator.com> | 2017-10-26 17:55:50 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-10-26 17:55:50 +1100 |
commit | b0e0c2a654d791543cd5728163e6912b085e09e8 (patch) | |
tree | ca12db595adb322c1af5aff8ca1073ba38a9483d /src | |
parent | dee73c581f25525fdd3e1d05e7736161ad7e1702 (diff) | |
download | luaossl-b0e0c2a654d791543cd5728163e6912b085e09e8.tar.gz luaossl-b0e0c2a654d791543cd5728163e6912b085e09e8.tar.bz2 luaossl-b0e0c2a654d791543cd5728163e6912b085e09e8.zip |
src/openssl.c: Add compat routines for SSL_SESSION_get_master_key
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 20 |
1 files changed, 20 insertions, 0 deletions
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__) ) |