2015-10-30 11:12:15 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
2019-10-25 00:43:08 +02:00
|
|
|
* Copyright (C) 2013-2019 Intel Corporation. All rights reserved.
|
2015-10-30 11:12:15 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <ell/ell.h>
|
2018-10-19 08:24:57 +02:00
|
|
|
|
2019-04-03 18:34:22 +02:00
|
|
|
#include "src/missing.h"
|
2018-12-05 00:41:49 +01:00
|
|
|
#include "src/eap.h"
|
|
|
|
#include "src/eap-private.h"
|
|
|
|
#include "src/eap-tls-common.h"
|
2015-10-30 11:12:15 +01:00
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
static bool eap_tls_tunnel_ready(struct eap_state *eap,
|
|
|
|
const char *peer_identity)
|
2015-10-30 11:12:15 +01:00
|
|
|
{
|
|
|
|
uint8_t msk_emsk[128];
|
|
|
|
uint8_t iv[64];
|
|
|
|
|
|
|
|
eap_method_success(eap);
|
2018-12-05 00:41:49 +01:00
|
|
|
eap_tls_common_set_completed(eap);
|
2015-10-30 11:12:15 +01:00
|
|
|
|
|
|
|
/* MSK, EMSK and IV derivation */
|
2018-12-05 00:41:49 +01:00
|
|
|
eap_tls_common_tunnel_prf_get_bytes(eap, true, "client EAP encryption",
|
|
|
|
msk_emsk, 128);
|
|
|
|
eap_tls_common_tunnel_prf_get_bytes(eap, false, "client EAP encryption",
|
|
|
|
iv, 64);
|
2015-10-30 11:12:15 +01:00
|
|
|
|
2019-04-10 23:52:26 +02:00
|
|
|
/* TODO: Derive Session-ID */
|
|
|
|
eap_set_key_material(eap, msk_emsk + 0, 64, msk_emsk + 64, 64, iv, 64,
|
|
|
|
NULL, 0);
|
2019-03-19 01:25:22 +01:00
|
|
|
explicit_bzero(msk_emsk, sizeof(msk_emsk));
|
|
|
|
explicit_bzero(iv, sizeof(iv));
|
2015-10-30 11:12:15 +01:00
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
eap_tls_common_send_empty_response(eap);
|
2015-10-30 11:12:15 +01:00
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
return true;
|
2018-11-01 07:03:39 +01:00
|
|
|
}
|
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
static int eap_tls_settings_check(struct l_settings *settings,
|
|
|
|
struct l_queue *secrets,
|
|
|
|
const char *prefix,
|
|
|
|
struct l_queue **out_missing)
|
2015-10-30 11:12:15 +01:00
|
|
|
{
|
2018-12-05 00:41:49 +01:00
|
|
|
char tls_prefix[72];
|
2015-10-30 11:12:15 +01:00
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
snprintf(tls_prefix, sizeof(tls_prefix), "%sTLS-", prefix);
|
2015-10-30 11:12:15 +01:00
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
return eap_tls_common_settings_check(settings, secrets, tls_prefix,
|
|
|
|
out_missing);
|
2015-10-30 11:12:15 +01:00
|
|
|
}
|
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
static const struct eap_tls_variant_ops eap_tls_ops = {
|
|
|
|
.tunnel_ready = eap_tls_tunnel_ready,
|
|
|
|
};
|
2018-04-18 07:03:25 +02:00
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
static bool eap_tls_settings_load(struct eap_state *eap,
|
|
|
|
struct l_settings *settings,
|
|
|
|
const char *prefix)
|
2015-10-30 11:12:15 +01:00
|
|
|
{
|
2018-12-05 00:41:49 +01:00
|
|
|
char setting_key_prefix[72];
|
2015-10-30 11:12:15 +01:00
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
snprintf(setting_key_prefix, sizeof(setting_key_prefix), "%sTLS-",
|
|
|
|
prefix);
|
2015-10-30 11:12:15 +01:00
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
if (!eap_tls_common_settings_load(eap, settings, setting_key_prefix,
|
|
|
|
&eap_tls_ops, NULL))
|
|
|
|
return false;
|
2017-09-06 04:12:17 +02:00
|
|
|
|
2015-10-30 11:12:15 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-03 04:31:04 +01:00
|
|
|
static struct eap_method eap_tls = {
|
2019-04-02 20:59:32 +02:00
|
|
|
.request_type = EAP_TYPE_TLS,
|
2015-10-30 11:12:15 +01:00
|
|
|
.exports_msk = true,
|
|
|
|
.name = "TLS",
|
|
|
|
|
2018-12-05 00:41:49 +01:00
|
|
|
.handle_request = eap_tls_common_handle_request,
|
|
|
|
.handle_retransmit = eap_tls_common_handle_retransmit,
|
|
|
|
.reset_state = eap_tls_common_state_reset,
|
|
|
|
.free = eap_tls_common_state_free,
|
|
|
|
|
|
|
|
.check_settings = eap_tls_settings_check,
|
|
|
|
.load_settings = eap_tls_settings_load,
|
2015-10-30 11:12:15 +01:00
|
|
|
};
|
2015-11-03 04:31:04 +01:00
|
|
|
|
2019-06-05 23:59:59 +02:00
|
|
|
static struct eap_method eap_wfa_tls = {
|
|
|
|
.request_type = EAP_TYPE_EXPANDED,
|
|
|
|
.exports_msk = true,
|
|
|
|
.name = "WFA-TLS",
|
|
|
|
|
|
|
|
.handle_request = eap_tls_common_handle_request,
|
|
|
|
.handle_retransmit = eap_tls_common_handle_retransmit,
|
|
|
|
.reset_state = eap_tls_common_state_reset,
|
|
|
|
.free = eap_tls_common_state_free,
|
|
|
|
|
|
|
|
.check_settings = eap_tls_settings_check,
|
|
|
|
.load_settings = eap_tls_settings_load,
|
|
|
|
.vendor_id = { 0x00, 0x9f, 0x68 },
|
|
|
|
.vendor_type = 0x0000000d,
|
|
|
|
};
|
|
|
|
|
2015-11-03 04:31:04 +01:00
|
|
|
static int eap_tls_init(void)
|
|
|
|
{
|
|
|
|
l_debug("");
|
2019-06-05 23:59:59 +02:00
|
|
|
|
|
|
|
if (eap_register_method(&eap_tls) < 0)
|
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
return eap_register_method(&eap_wfa_tls);
|
2015-11-03 04:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void eap_tls_exit(void)
|
|
|
|
{
|
|
|
|
l_debug("");
|
|
|
|
eap_unregister_method(&eap_tls);
|
2019-06-05 23:59:59 +02:00
|
|
|
eap_unregister_method(&eap_wfa_tls);
|
2015-11-03 04:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
EAP_METHOD_BUILTIN(eap_tls, eap_tls_init, eap_tls_exit)
|