eap.h (3297B)
1 /* 2 * 3 * Wireless daemon for Linux 4 * 5 * Copyright (C) 2013-2019 Intel Corporation. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 * 21 */ 22 23 #include <stdint.h> 24 #include <stdbool.h> 25 #include <asm/byteorder.h> 26 #include <linux/types.h> 27 28 struct eap_state; 29 30 enum eap_result { 31 EAP_RESULT_SUCCESS, 32 EAP_RESULT_FAIL, 33 EAP_RESULT_TIMEOUT, 34 }; 35 36 enum eap_secret_type { 37 EAP_SECRET_LOCAL_PKEY_PASSPHRASE, 38 EAP_SECRET_REMOTE_PASSWORD, 39 EAP_SECRET_REMOTE_USER_PASSWORD, 40 }; 41 42 enum eap_secret_cache_policy { 43 EAP_CACHE_NEVER, 44 EAP_CACHE_TEMPORARY, 45 }; 46 47 struct eap_secret_info { 48 char *id; 49 char *id2; 50 enum eap_secret_type type; 51 char *parameter; 52 char *value; 53 enum eap_secret_cache_policy cache_policy; 54 }; 55 56 typedef void (*eap_tx_packet_func_t)(const uint8_t *eap_data, size_t len, 57 void *user_data); 58 typedef void (*eap_key_material_func_t)(const uint8_t *msk_data, size_t msk_len, 59 const uint8_t *emsk_data, size_t emsk_len, 60 const uint8_t *iv, size_t iv_len, 61 const uint8_t *session_id, size_t session_len, 62 void *user_data); 63 typedef void (*eap_complete_func_t)(enum eap_result result, void *user_data); 64 typedef void (*eap_event_func_t)(unsigned int event, const void *event_data, 65 void *user_data); 66 67 bool eap_secret_info_match(const void *a, const void *b); 68 void eap_secret_info_free(void *data); 69 70 struct eap_state *eap_new(eap_tx_packet_func_t tx_packet, 71 eap_complete_func_t complete, void *user_data); 72 void eap_free(struct eap_state *eap); 73 74 void eap_append_secret(struct l_queue **out_missing, enum eap_secret_type type, 75 const char *id, const char *id2, const char *parameter, 76 enum eap_secret_cache_policy cache_policy); 77 78 int eap_check_settings(struct l_settings *settings, struct l_queue *secrets, 79 const char *prefix, bool set_key_material, 80 struct l_queue **out_missing); 81 bool eap_load_settings(struct eap_state *eap, struct l_settings *settings, 82 const char *prefix); 83 bool eap_reset(struct eap_state *eap); 84 void eap_start(struct eap_state *eap); 85 86 void eap_set_key_material_func(struct eap_state *eap, 87 eap_key_material_func_t func); 88 void eap_set_event_func(struct eap_state *eap, eap_event_func_t func); 89 90 void eap_set_mtu(struct eap_state *eap, size_t mtu); 91 size_t eap_get_mtu(struct eap_state *eap); 92 93 const char *eap_get_identity(struct eap_state *eap); 94 95 void eap_rx_packet(struct eap_state *eap, const uint8_t *pkt, size_t len); 96 97 void eap_set_peer_id(struct eap_state *eap, const char *id); 98 const char *eap_get_peer_id(struct eap_state *eap); 99 100 void __eap_set_config(struct l_settings *config); 101 102 int eap_init(void); 103 void eap_exit(void);