Home | History | Annotate | Download | only in eap_common
      1 /*
      2  * EAP-FAST definitions (RFC 4851)
      3  * Copyright (c) 2004-2008, Jouni Malinen <j (at) w1.fi>
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License version 2 as
      7  * published by the Free Software Foundation.
      8  *
      9  * Alternatively, this software may be distributed under the terms of BSD
     10  * license.
     11  *
     12  * See README and COPYING for more details.
     13  */
     14 
     15 #ifndef EAP_FAST_H
     16 #define EAP_FAST_H
     17 
     18 #define EAP_FAST_VERSION 1
     19 #define EAP_FAST_KEY_LEN 64
     20 #define EAP_FAST_SIMCK_LEN 40
     21 #define EAP_FAST_SKS_LEN 40
     22 #define EAP_FAST_CMK_LEN 20
     23 
     24 #define TLS_EXT_PAC_OPAQUE 35
     25 
     26 /*
     27  * RFC 5422: Section 4.2.1 - Formats for PAC TLV Attributes / Type Field
     28  * Note: bit 0x8000 (Mandatory) and bit 0x4000 (Reserved) are also defined
     29  * in the general PAC TLV format (Section 4.2).
     30  */
     31 #define PAC_TYPE_PAC_KEY 1
     32 #define PAC_TYPE_PAC_OPAQUE 2
     33 #define PAC_TYPE_CRED_LIFETIME 3
     34 #define PAC_TYPE_A_ID 4
     35 #define PAC_TYPE_I_ID 5
     36 /*
     37  * 6 was previous assigned for SERVER_PROTECTED_DATA, but
     38  * draft-cam-winget-eap-fast-provisioning-02.txt changed this to Reserved.
     39  */
     40 #define PAC_TYPE_A_ID_INFO 7
     41 #define PAC_TYPE_PAC_ACKNOWLEDGEMENT 8
     42 #define PAC_TYPE_PAC_INFO 9
     43 #define PAC_TYPE_PAC_TYPE 10
     44 
     45 #ifdef _MSC_VER
     46 #pragma pack(push, 1)
     47 #endif /* _MSC_VER */
     48 
     49 struct pac_tlv_hdr {
     50 	be16 type;
     51 	be16 len;
     52 } STRUCT_PACKED;
     53 
     54 #ifdef _MSC_VER
     55 #pragma pack(pop)
     56 #endif /* _MSC_VER */
     57 
     58 
     59 #define EAP_FAST_PAC_KEY_LEN 32
     60 
     61 /* RFC 5422: 4.2.6 PAC-Type TLV */
     62 #define PAC_TYPE_TUNNEL_PAC 1
     63 /* Application Specific Short Lived PACs (only in volatile storage) */
     64 /* User Authorization PAC */
     65 #define PAC_TYPE_USER_AUTHORIZATION 3
     66 /* Application Specific Long Lived PACs */
     67 /* Machine Authentication PAC */
     68 #define PAC_TYPE_MACHINE_AUTHENTICATION 2
     69 
     70 
     71 /*
     72  * RFC 5422:
     73  * Section 3.3 - Key Derivations Used in the EAP-FAST Provisioning Exchange
     74  */
     75 struct eap_fast_key_block_provisioning {
     76 	/* Extra key material after TLS key_block */
     77 	u8 session_key_seed[EAP_FAST_SKS_LEN];
     78 	u8 server_challenge[16]; /* MSCHAPv2 ServerChallenge */
     79 	u8 client_challenge[16]; /* MSCHAPv2 ClientChallenge */
     80 };
     81 
     82 
     83 struct wpabuf;
     84 struct tls_connection;
     85 
     86 struct eap_fast_tlv_parse {
     87 	u8 *eap_payload_tlv;
     88 	size_t eap_payload_tlv_len;
     89 	struct eap_tlv_crypto_binding_tlv *crypto_binding;
     90 	size_t crypto_binding_len;
     91 	int iresult;
     92 	int result;
     93 	int request_action;
     94 	u8 *pac;
     95 	size_t pac_len;
     96 };
     97 
     98 void eap_fast_put_tlv_hdr(struct wpabuf *buf, u16 type, u16 len);
     99 void eap_fast_put_tlv(struct wpabuf *buf, u16 type, const void *data,
    100 		      u16 len);
    101 void eap_fast_put_tlv_buf(struct wpabuf *buf, u16 type,
    102 			  const struct wpabuf *data);
    103 struct wpabuf * eap_fast_tlv_eap_payload(struct wpabuf *buf);
    104 void eap_fast_derive_master_secret(const u8 *pac_key, const u8 *server_random,
    105 				   const u8 *client_random, u8 *master_secret);
    106 u8 * eap_fast_derive_key(void *ssl_ctx, struct tls_connection *conn,
    107 			 const char *label, size_t len);
    108 void eap_fast_derive_eap_msk(const u8 *simck, u8 *msk);
    109 void eap_fast_derive_eap_emsk(const u8 *simck, u8 *emsk);
    110 int eap_fast_parse_tlv(struct eap_fast_tlv_parse *tlv,
    111 		       int tlv_type, u8 *pos, int len);
    112 
    113 #endif /* EAP_FAST_H */
    114