2014-12-18 18:10:10 -06:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
#include <linux/types.h>
|
2018-09-14 17:30:03 +02:00
|
|
|
#include "src/eapolutil.h"
|
2014-12-18 18:10:10 -06:00
|
|
|
|
2015-02-24 10:54:23 -06:00
|
|
|
struct eapol_sm;
|
2016-11-02 23:46:19 +01:00
|
|
|
struct handshake_state;
|
2017-04-29 03:53:26 +02:00
|
|
|
struct preauth_sm;
|
2017-09-22 05:06:40 +02:00
|
|
|
enum handshake_kde;
|
2018-08-09 11:13:55 -07:00
|
|
|
enum ie_rsn_akm_suite;
|
2015-02-24 10:54:23 -06:00
|
|
|
|
2018-05-01 11:01:51 -05:00
|
|
|
typedef int (*eapol_tx_packet_func_t)(uint32_t ifindex,
|
|
|
|
const uint8_t *dest, uint16_t proto,
|
|
|
|
const struct eapol_frame *ef,
|
|
|
|
bool noencrypt,
|
|
|
|
void *user_data);
|
2016-06-22 15:49:15 -07:00
|
|
|
typedef void (*eapol_rekey_offload_func_t)(uint32_t ifindex,
|
|
|
|
const uint8_t *kek,
|
|
|
|
const uint8_t *kck,
|
|
|
|
uint64_t replay_counter,
|
|
|
|
void *user_data);
|
2016-09-13 13:30:54 -05:00
|
|
|
typedef void (*eapol_sm_event_func_t)(unsigned int event,
|
|
|
|
const void *event_data,
|
|
|
|
void *user_data);
|
2017-04-29 03:53:26 +02:00
|
|
|
typedef void (*eapol_preauth_cb_t)(const uint8_t *pmk, void *user_data);
|
|
|
|
typedef void (*eapol_preauth_destroy_func_t)(void *user_data);
|
2017-09-07 23:04:45 +02:00
|
|
|
typedef void (*eapol_frame_watch_func_t)(uint16_t proto, const uint8_t *from,
|
|
|
|
const struct eapol_frame *frame,
|
|
|
|
void *user_data);
|
2015-02-24 11:09:42 -06:00
|
|
|
|
2018-08-09 11:13:55 -07:00
|
|
|
bool eapol_calculate_mic(enum ie_rsn_akm_suite akm, const uint8_t *kck,
|
2019-01-17 12:25:28 -08:00
|
|
|
const struct eapol_key *frame, uint8_t *mic,
|
|
|
|
size_t mic_len);
|
2018-08-09 11:13:55 -07:00
|
|
|
bool eapol_verify_mic(enum ie_rsn_akm_suite akm, const uint8_t *kck,
|
2019-01-17 12:25:28 -08:00
|
|
|
const struct eapol_key *frame, size_t mic_len);
|
2014-12-27 22:37:39 -06:00
|
|
|
|
2018-08-09 11:13:55 -07:00
|
|
|
uint8_t *eapol_decrypt_key_data(enum ie_rsn_akm_suite akm, const uint8_t *kek,
|
2015-02-24 15:59:36 -06:00
|
|
|
const struct eapol_key *frame,
|
2019-01-17 12:25:28 -08:00
|
|
|
size_t *decrypted_size, size_t mic_len);
|
2015-02-13 20:37:17 -06:00
|
|
|
|
2019-01-17 12:25:28 -08:00
|
|
|
bool eapol_verify_ptk_1_of_4(const struct eapol_key *ek, size_t mic_len);
|
2015-02-23 15:39:26 -06:00
|
|
|
bool eapol_verify_ptk_2_of_4(const struct eapol_key *ek);
|
2015-05-06 01:48:35 +02:00
|
|
|
bool eapol_verify_ptk_3_of_4(const struct eapol_key *ek, bool is_wpa);
|
|
|
|
bool eapol_verify_ptk_4_of_4(const struct eapol_key *ek, bool is_wpa);
|
2015-05-06 01:48:34 +02:00
|
|
|
bool eapol_verify_gtk_1_of_2(const struct eapol_key *ek, bool is_wpa);
|
2015-05-05 22:04:21 -05:00
|
|
|
bool eapol_verify_gtk_2_of_2(const struct eapol_key *ek, bool is_wpa);
|
2015-02-13 16:08:33 -06:00
|
|
|
|
2014-12-27 22:33:46 -06:00
|
|
|
struct eapol_key *eapol_create_ptk_2_of_4(
|
|
|
|
enum eapol_protocol_version protocol,
|
|
|
|
enum eapol_key_descriptor_version version,
|
2015-02-13 13:54:50 -06:00
|
|
|
uint64_t key_replay_counter,
|
2014-12-27 22:33:46 -06:00
|
|
|
const uint8_t snonce[],
|
|
|
|
size_t extra_len,
|
2015-05-06 01:48:35 +02:00
|
|
|
const uint8_t *extra_data,
|
2019-01-17 12:25:28 -08:00
|
|
|
bool is_wpa,
|
|
|
|
size_t mic_len);
|
2015-02-13 14:10:28 -06:00
|
|
|
|
|
|
|
struct eapol_key *eapol_create_ptk_4_of_4(
|
|
|
|
enum eapol_protocol_version protocol,
|
|
|
|
enum eapol_key_descriptor_version version,
|
2015-05-06 01:48:35 +02:00
|
|
|
uint64_t key_replay_counter,
|
2019-01-17 12:25:28 -08:00
|
|
|
bool is_wpa,
|
|
|
|
size_t mic_len);
|
2015-05-06 01:48:35 +02:00
|
|
|
|
|
|
|
struct eapol_key *eapol_create_gtk_2_of_2(
|
|
|
|
enum eapol_protocol_version protocol,
|
|
|
|
enum eapol_key_descriptor_version version,
|
|
|
|
uint64_t key_replay_counter,
|
2019-01-17 12:25:28 -08:00
|
|
|
bool is_wpa, uint8_t wpa_key_id,
|
|
|
|
size_t mic_len);
|
2015-02-24 10:54:23 -06:00
|
|
|
|
2018-05-01 11:01:51 -05:00
|
|
|
void __eapol_rx_packet(uint32_t ifindex, const uint8_t *src, uint16_t proto,
|
|
|
|
const uint8_t *frame, size_t len, bool noencrypt);
|
|
|
|
void __eapol_tx_packet(uint32_t ifindex, const uint8_t *dst, uint16_t proto,
|
|
|
|
const struct eapol_frame *frame, bool noencrypt);
|
2015-02-24 11:10:42 -06:00
|
|
|
void __eapol_set_tx_packet_func(eapol_tx_packet_func_t func);
|
2016-09-12 10:02:04 -05:00
|
|
|
void __eapol_set_tx_user_data(void *user_data);
|
|
|
|
|
2016-06-22 15:49:15 -07:00
|
|
|
void __eapol_set_rekey_offload_func(eapol_rekey_offload_func_t func);
|
|
|
|
void __eapol_update_replay_counter(uint32_t ifindex, const uint8_t *spa,
|
|
|
|
const uint8_t *aa, uint64_t replay_counter);
|
2018-04-02 11:47:43 -07:00
|
|
|
void __eapol_set_config(struct l_settings *config);
|
2015-02-24 11:09:42 -06:00
|
|
|
|
2016-11-02 23:46:19 +01:00
|
|
|
struct eapol_sm *eapol_sm_new(struct handshake_state *hs);
|
2015-02-24 10:54:23 -06:00
|
|
|
void eapol_sm_free(struct eapol_sm *sm);
|
2015-02-24 10:55:50 -06:00
|
|
|
|
2016-08-10 16:32:45 -05:00
|
|
|
void eapol_sm_set_protocol_version(struct eapol_sm *sm,
|
|
|
|
enum eapol_protocol_version protocol_version);
|
|
|
|
|
2016-10-11 01:36:48 -05:00
|
|
|
void eapol_sm_set_use_eapol_start(struct eapol_sm *sm, bool enabled);
|
2017-08-18 14:22:55 +02:00
|
|
|
void eapol_sm_set_require_handshake(struct eapol_sm *sm, bool enabled);
|
2018-06-22 11:13:29 -07:00
|
|
|
void eapol_sm_set_listen_interval(struct eapol_sm *sm, uint16_t interval);
|
2015-03-25 22:34:05 -05:00
|
|
|
void eapol_sm_set_user_data(struct eapol_sm *sm, void *user_data);
|
2016-09-13 13:30:54 -05:00
|
|
|
void eapol_sm_set_event_func(struct eapol_sm *sm, eapol_sm_event_func_t func);
|
2016-11-02 23:46:19 +01:00
|
|
|
|
|
|
|
void eapol_register(struct eapol_sm *sm);
|
2017-10-27 14:39:53 -07:00
|
|
|
bool eapol_start(struct eapol_sm *sm);
|
2017-04-29 03:53:26 +02:00
|
|
|
|
|
|
|
struct preauth_sm *eapol_preauth_start(const uint8_t *aa,
|
|
|
|
const struct handshake_state *hs,
|
|
|
|
eapol_preauth_cb_t cb, void *user_data,
|
|
|
|
eapol_preauth_destroy_func_t destroy);
|
|
|
|
void eapol_preauth_cancel(uint32_t ifindex);
|
2015-02-24 11:12:22 -06:00
|
|
|
|
2015-02-24 11:08:03 -06:00
|
|
|
bool eapol_init();
|
|
|
|
bool eapol_exit();
|