Home | History | Annotate | Download | only in eap_common
      1 /*
      2  * EAP server/peer: EAP-PAX shared routines
      3  * Copyright (c) 2005-2007, Jouni Malinen <j (at) w1.fi>
      4  *
      5  * This software may be distributed under the terms of the BSD license.
      6  * See README for more details.
      7  */
      8 
      9 #ifndef EAP_PAX_COMMON_H
     10 #define EAP_PAX_COMMON_H
     11 
     12 #ifdef _MSC_VER
     13 #pragma pack(push, 1)
     14 #endif /* _MSC_VER */
     15 
     16 struct eap_pax_hdr {
     17 	u8 op_code;
     18 	u8 flags;
     19 	u8 mac_id;
     20 	u8 dh_group_id;
     21 	u8 public_key_id;
     22 	/* Followed by variable length payload and ICV */
     23 } STRUCT_PACKED;
     24 
     25 #ifdef _MSC_VER
     26 #pragma pack(pop)
     27 #endif /* _MSC_VER */
     28 
     29 
     30 /* op_code: */
     31 enum {
     32 	EAP_PAX_OP_STD_1 = 0x01,
     33 	EAP_PAX_OP_STD_2 = 0x02,
     34 	EAP_PAX_OP_STD_3 = 0x03,
     35 	EAP_PAX_OP_SEC_1 = 0x11,
     36 	EAP_PAX_OP_SEC_2 = 0x12,
     37 	EAP_PAX_OP_SEC_3 = 0x13,
     38 	EAP_PAX_OP_SEC_4 = 0x14,
     39 	EAP_PAX_OP_SEC_5 = 0x15,
     40 	EAP_PAX_OP_ACK = 0x21
     41 };
     42 
     43 /* flags: */
     44 #define EAP_PAX_FLAGS_MF			0x01
     45 #define EAP_PAX_FLAGS_CE			0x02
     46 #define EAP_PAX_FLAGS_AI			0x04
     47 
     48 /* mac_id: */
     49 #define EAP_PAX_MAC_HMAC_SHA1_128		0x01
     50 #define EAP_PAX_HMAC_SHA256_128			0x02
     51 
     52 /* dh_group_id: */
     53 #define EAP_PAX_DH_GROUP_NONE			0x00
     54 #define EAP_PAX_DH_GROUP_2048_MODP		0x01
     55 #define EAP_PAX_DH_GROUP_3072_MODP		0x02
     56 #define EAP_PAX_DH_GROUP_NIST_ECC_P_256		0x03
     57 
     58 /* public_key_id: */
     59 #define EAP_PAX_PUBLIC_KEY_NONE			0x00
     60 #define EAP_PAX_PUBLIC_KEY_RSAES_OAEP		0x01
     61 #define EAP_PAX_PUBLIC_KEY_RSA_PKCS1_V1_5	0x02
     62 #define EAP_PAX_PUBLIC_KEY_EL_GAMAL_NIST_ECC	0x03
     63 
     64 /* ADE type: */
     65 #define EAP_PAX_ADE_VENDOR_SPECIFIC		0x01
     66 #define EAP_PAX_ADE_CLIENT_CHANNEL_BINDING	0x02
     67 #define EAP_PAX_ADE_SERVER_CHANNEL_BINDING	0x03
     68 
     69 
     70 #define EAP_PAX_RAND_LEN 32
     71 #define EAP_PAX_MAC_LEN 16
     72 #define EAP_PAX_ICV_LEN 16
     73 #define EAP_PAX_AK_LEN 16
     74 #define EAP_PAX_MK_LEN 16
     75 #define EAP_PAX_CK_LEN 16
     76 #define EAP_PAX_ICK_LEN 16
     77 
     78 
     79 int eap_pax_kdf(u8 mac_id, const u8 *key, size_t key_len,
     80 		const char *identifier,
     81 		const u8 *entropy, size_t entropy_len,
     82 		size_t output_len, u8 *output);
     83 int eap_pax_mac(u8 mac_id, const u8 *key, size_t key_len,
     84 		const u8 *data1, size_t data1_len,
     85 		const u8 *data2, size_t data2_len,
     86 		const u8 *data3, size_t data3_len,
     87 		u8 *mac);
     88 int eap_pax_initial_key_derivation(u8 mac_id, const u8 *ak, const u8 *e,
     89 				   u8 *mk, u8 *ck, u8 *ick);
     90 
     91 #endif /* EAP_PAX_COMMON_H */
     92