eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

eap-private.h (4426B)


      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 /* EAP method API */
     31 
     32 enum eap_type {
     33 	EAP_TYPE_IDENTITY	= 1,
     34 	EAP_TYPE_NOTIFICATION	= 2,
     35 	EAP_TYPE_NAK		= 3,
     36 	__EAP_TYPE_MIN_METHOD	= 4,
     37 	EAP_TYPE_MD5_CHALLENGE	= 4,
     38 	EAP_TYPE_GTC		= 6,
     39 	EAP_TYPE_TLS		= 13,
     40 	EAP_TYPE_SIM		= 18,
     41 	EAP_TYPE_TTLS		= 21,
     42 	EAP_TYPE_AKA		= 23,
     43 	EAP_TYPE_PEAP		= 25,
     44 	EAP_TYPE_EXTENSIONS	= 33,
     45 	EAP_TYPE_AKA_PRIME	= 50,
     46 	EAP_TYPE_MSCHAPV2	= 26,
     47 	EAP_TYPE_PWD		= 52,
     48 	EAP_TYPE_EXPANDED	= 254,
     49 };
     50 
     51 enum eap_code {
     52 	EAP_CODE_REQUEST	= 1,
     53 	EAP_CODE_RESPONSE	= 2,
     54 	EAP_CODE_SUCCESS	= 3,
     55 	EAP_CODE_FAILURE	= 4,
     56 	EAP_CODE_INITIATE	= 5,
     57 	EAP_CODE_FINISH		= 6,
     58 };
     59 
     60 struct eap_method {
     61 	enum eap_type request_type;
     62 	uint8_t vendor_id[3];
     63 	uint32_t vendor_type;
     64 	bool exports_msk;
     65 	const char *name;
     66 
     67 	int (*check_settings)(struct l_settings *settings,
     68 				struct l_queue *secrets, const char *prefix,
     69 				struct l_queue **out_missing);
     70 
     71 	bool (*load_settings)(struct eap_state *eap,
     72 				struct l_settings *settings,
     73 				const char *prefix);
     74 
     75 	/* Reset the internal state back to initial conditions */
     76 	bool (*reset_state)(struct eap_state *eap);
     77 	void (*free)(struct eap_state *eap);
     78 
     79 	void (*handle_request)(struct eap_state *eap,
     80 				const uint8_t *pkt, size_t len);
     81 	void (*handle_retransmit)(struct eap_state *eap,
     82 				const uint8_t *pkt, size_t len);
     83 	const char *(*get_identity)(struct eap_state *eap);
     84 
     85 	bool (*validate_identity)(struct eap_state *eap, const char *identity);
     86 	void (*handle_response)(struct eap_state *eap,
     87 				const uint8_t *pkt, size_t len);
     88 };
     89 
     90 struct eap_method_desc {
     91 	const char *name;
     92 	int (*init)(void);
     93 	void (*exit)(void);
     94 } __attribute__((aligned(8)));
     95 
     96 #define EAP_METHOD_BUILTIN(name, init, exit)				\
     97 	_Pragma("GCC diagnostic push")					\
     98 	_Pragma("GCC diagnostic ignored \"-Wattributes\"")		\
     99 	static struct eap_method_desc __eap_builtin_ ## name		\
    100 		__attribute__((used, retain, section("__eap"),		\
    101 			       aligned(8))) = {				\
    102 			#name, init, exit				\
    103 		};							\
    104 	_Pragma("GCC diagnostic pop")
    105 
    106 int eap_register_method(struct eap_method *method);
    107 int eap_unregister_method(struct eap_method *method);
    108 
    109 /* Private EAP API */
    110 
    111 int __eap_check_settings(struct l_settings *settings, struct l_queue *secrets,
    112 				const char *prefix, bool set_key_material,
    113 				struct l_queue **missing);
    114 void __eap_handle_request(struct eap_state *eap, uint16_t id,
    115 						const uint8_t *pkt, size_t len);
    116 
    117 void eap_discard_success_and_failure(struct eap_state *eap, bool discard);
    118 
    119 void eap_set_data(struct eap_state *eap, void *data);
    120 void *eap_get_data(struct eap_state *eap);
    121 
    122 enum eap_type eap_get_method_type(struct eap_state *eap);
    123 const char *eap_get_method_name(struct eap_state *eap);
    124 
    125 void eap_set_key_material(struct eap_state *eap,
    126 				const uint8_t *msk_data, size_t msk_len,
    127 				const uint8_t *emsk_data, size_t emsk_len,
    128 				const uint8_t *iv, size_t iv_len,
    129 				const uint8_t *session_id, size_t session_len);
    130 
    131 void eap_start_complete_timeout(struct eap_state *eap);
    132 
    133 void eap_method_respond(struct eap_state *eap, uint8_t *buf, size_t len);
    134 void eap_method_new_request(struct eap_state *eap, uint8_t *buf, size_t len);
    135 bool eap_method_is_success(struct eap_state *eap);
    136 void eap_method_success(struct eap_state *eap);
    137 void eap_method_error(struct eap_state *eap);
    138 void eap_method_event(struct eap_state *eap, unsigned int type,
    139 							const void *data);
    140 
    141 void eap_save_last_id(struct eap_state *eap, uint8_t *last_id);
    142 void eap_restore_last_id(struct eap_state *eap, uint8_t last_id);