From: Arran Cudbard-Bell Date: Thu, 25 May 2017 20:29:38 +0000 (-0400) Subject: Fix scope, and use secure erase in mppe_keys X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2290d68457e5cc373b76aa2b558491a54964d26d;p=thirdparty%2Ffreeradius-server.git Fix scope, and use secure erase in mppe_keys We should probably have a secret flag for attributes to ensure they get secure erased... --- diff --git a/src/modules/rlm_eap/lib/base/mppe_keys.c b/src/modules/rlm_eap/lib/base/mppe_keys.c index 2b170b968e8..082e70fbbd4 100644 --- a/src/modules/rlm_eap/lib/base/mppe_keys.c +++ b/src/modules/rlm_eap/lib/base/mppe_keys.c @@ -25,10 +25,14 @@ RCSID("$Id$") USES_APPLE_DEPRECATED_API /* OpenSSL API has been deprecated by Apple */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include + #include "eap_tls.h" #include #include + #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) /* * OpenSSL compatibility, to avoid ifdef's through the rest of the code. @@ -117,7 +121,7 @@ static void P_hash(EVP_MD const *evp_md, HMAC_CTX_free(ctx_a); HMAC_CTX_free(ctx_out); - memset(a, 0, sizeof(a)); + memset_s(a, 0, sizeof(a), sizeof(a)); } /* EAP-FAST Pseudo-Random Function (T-PRF): RFC 4851, Section 5.5 */ @@ -187,9 +191,13 @@ static void PRF(unsigned char const *secret, unsigned int secret_len, */ void eap_tls_gen_mppe_keys(REQUEST *request, SSL *s, char const *prf_label) { - uint8_t out[4 * EAP_TLS_MPPE_KEY_LEN]; - uint8_t *p; - size_t prf_size; + uint8_t out[4 * EAP_TLS_MPPE_KEY_LEN]; + uint8_t *p; + size_t prf_size; + size_t master_key_len; + uint8_t seed[64 + (2 * SSL3_RANDOM_SIZE)]; + uint8_t buf[4 * EAP_TLS_MPPE_KEY_LEN]; + uint8_t master_key[SSL_MAX_MASTER_KEY_LENGTH]; prf_size = strlen(prf_label); @@ -198,11 +206,6 @@ void eap_tls_gen_mppe_keys(REQUEST *request, SSL *s, char const *prf_label) #endif { - size_t master_key_len; - uint8_t seed[64 + (2 * SSL3_RANDOM_SIZE)]; - uint8_t buf[4 * EAP_TLS_MPPE_KEY_LEN]; - uint8_t master_key[SSL_MAX_MASTER_KEY_LENGTH]; - p = seed; memcpy(p, prf_label, prf_size); p += prf_size;