Skip to content
Permalink
Browse files

Add missing OpenSSL functions

  • Loading branch information...
arr2036 committed Jan 20, 2019
1 parent 2376cfa commit 816c22001248e0e6ea70ee91b4e8779f41851cc2
Showing with 71 additions and 0 deletions.
  1. +1 −0 src/lib/tls/all.mk
  2. +9 −0 src/lib/tls/base-h
  3. +61 −0 src/lib/tls/missing.c
@@ -10,6 +10,7 @@ SOURCES := \
conf.c \
ctx.c \
log.c \
missing.c \
ocsp.c \
session.c \
utils.c \
@@ -538,6 +538,15 @@ int tls_log_error(REQUEST *request, char const *msg, ...) CC_HINT(format (print
int tls_log_io_error(REQUEST *request, tls_session_t *session, int ret, char const *msg, ...)
CC_HINT(format (printf, 4, 5));

/*
* tls/missing.c
*/
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
size_t SSL_get_client_random(const SSL *ssl, unsigned char *out, size_t outlen);
size_t SSL_get_server_random(const SSL *ssl, unsigned char *out, size_t outlen);
size_t SSL_SESSION_get_master_key(const SSL_SESSION *s, unsigned char *out, size_t outlen);
#endif

/*
* tls/ocsp.c
*/
@@ -0,0 +1,61 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/

/**
* $Id$
*
* @file tls/missing.c
* @brief Compatibility functions for OpenSSL
*
* @copyright 2019 Arran Cudbard-Bell <a.cudbardb@freeradius.org>
* @copyright 2019 The FreeRADIUS server project
*/
#include "base.h"

#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
/*
* OpenSSL compatibility, to avoid ifdef's through the rest of the code.
*/
size_t SSL_get_client_random(const SSL *s, unsigned char *out, size_t outlen)
{
if (!outlen) return sizeof(s->s3->client_random);

if (outlen > sizeof(s->s3->client_random)) outlen = sizeof(s->s3->client_random);

memcpy(out, s->s3->client_random, outlen);
return outlen;
}

size_t SSL_get_server_random(const SSL *s, unsigned char *out, size_t outlen)
{
if (!outlen) return sizeof(s->s3->server_random);

if (outlen > sizeof(s->s3->server_random)) outlen = sizeof(s->s3->server_random);

memcpy(out, s->s3->server_random, outlen);
return outlen;
}

size_t SSL_SESSION_get_master_key(const SSL_SESSION *s, unsigned char *out, size_t outlen)
{
if (!outlen) return s->master_key_length;

if (outlen > (size_t)s->master_key_length) outlen = (size_t)s->master_key_length;

memcpy(out, s->master_key, outlen);
return outlen;
}
#endif

0 comments on commit 816c220

Please sign in to comment.
You can’t perform that action at this time.