From: Alan T. DeKok Date: Thu, 26 May 2016 15:25:14 +0000 (-0400) Subject: Use old PRF functions if SSL_export_keying_material() fails. X-Git-Tag: branch_3_1_x~316 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2f69fb29ce8edf00476ad0bd976d0c35c16d699;p=thirdparty%2Ffreeradius-server.git Use old PRF functions if SSL_export_keying_material() fails. Because https://tools.ietf.org/html/rfc5705#section-6 says that certain labels are prohibited, and OpenSSL enforces that prohibition. We need the keys for EAP, so we have to *always* implement the functions. Because SSL_export_keying_material() might fail. We'll need a later commit to implement the TLS 1.2 PRF. --- diff --git a/src/modules/rlm_eap/libeap/mppe_keys.c b/src/modules/rlm_eap/libeap/mppe_keys.c index 0265a1f153c..4be125391fd 100644 --- a/src/modules/rlm_eap/libeap/mppe_keys.c +++ b/src/modules/rlm_eap/libeap/mppe_keys.c @@ -29,7 +29,6 @@ USES_APPLE_DEPRECATED_API /* OpenSSL API has been deprecated by Apple */ #include -#if OPENSSL_VERSION_NUMBER < 0x10001000L /* * TLS PRF from RFC 2246 */ @@ -98,7 +97,6 @@ static void PRF(unsigned char const *secret, unsigned int secret_len, out[i] ^= buf[i]; } } -#endif #define EAPTLS_MPPE_KEY_LEN 32 @@ -118,7 +116,8 @@ void eap_tls_gen_mppe_keys(REQUEST *request, SSL *s, char const *prf_label) ERROR("Failed generating keying material"); return; } -#else +#endif + { uint8_t seed[64 + (2 * SSL3_RANDOM_SIZE)]; uint8_t buf[4 * EAPTLS_MPPE_KEY_LEN]; @@ -138,7 +137,6 @@ void eap_tls_gen_mppe_keys(REQUEST *request, SSL *s, char const *prf_label) PRF(s->session->master_key, s->session->master_key_length, seed, prf_size, out, buf, sizeof(out)); } -#endif RDEBUG2("Adding session keys"); p = out; @@ -159,16 +157,17 @@ void eap_tls_gen_mppe_keys(REQUEST *request, SSL *s, char const *prf_label) */ void eap_tls_gen_challenge(SSL *s, uint8_t *buffer, size_t size, char const *prf_label) { -#if OPENSSL_VERSION_NUMBER >= 0x10001000L - SSL_export_keying_material(s, buffer, size, prf_label, - strlen(prf_label), NULL, 0, 0); - -#else uint8_t out[32], buf[32]; uint8_t seed[128 + 2*SSL3_RANDOM_SIZE]; uint8_t *p = seed; size_t len; +#if OPENSSL_VERSION_NUMBER >= 0x10001000L + if (SSL_export_keying_material(s, buffer, size, prf_label, + strlen(prf_label), NULL, 0, 0) == 1) return; + +#endif + len = strlen(prf_label); if (len > 128) len = 128; @@ -182,7 +181,6 @@ void eap_tls_gen_challenge(SSL *s, uint8_t *buffer, size_t size, char const *prf PRF(s->session->master_key, s->session->master_key_length, seed, p - seed, out, buf, sizeof(out)); memcpy(buffer, out, size); -#endif } /*