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