Make peer headers build with C++ sources
[libeap.git] / src / eap_common / eap_fast_common.h
index 5d821da..c4f54ca 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * EAP-FAST definitions (RFC 4851)
- * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
 #ifndef EAP_FAST_H
 #define EAP_FAST_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define EAP_FAST_VERSION 1
 #define EAP_FAST_KEY_LEN 64
 #define EAP_FAST_SIMCK_LEN 40
 #define EAP_FAST_SKS_LEN 40
+#define EAP_FAST_CMK_LEN 20
 
 #define TLS_EXT_PAC_OPAQUE 35
 
 /*
- * draft-cam-winget-eap-fast-provisioning-04.txt:
- * Section 4.2.1 - Formats for PAC TLV Attributes / Type Field
+ * RFC 5422: Section 4.2.1 - Formats for PAC TLV Attributes / Type Field
  * Note: bit 0x8000 (Mandatory) and bit 0x4000 (Reserved) are also defined
  * in the general PAC TLV format (Section 4.2).
  */
@@ -58,10 +62,7 @@ struct pac_tlv_hdr {
 
 #define EAP_FAST_PAC_KEY_LEN 32
 
-/* draft-cam-winget-eap-fast-provisioning-04.txt: 4.2.6 PAC-Type TLV
- * Note: Machine Authentication PAC and User Authorization PAC were removed in
- * draft-cam-winget-eap-fast-provisioning-03.txt
- */
+/* RFC 5422: 4.2.6 PAC-Type TLV */
 #define PAC_TYPE_TUNNEL_PAC 1
 /* Application Specific Short Lived PACs (only in volatile storage) */
 /* User Authorization PAC */
@@ -72,8 +73,8 @@ struct pac_tlv_hdr {
 
 
 /*
- * draft-cam-winget-eap-fast-provisioning-04.txt:
- * Section 3.4 - Key Derivations Used in the EAP-FAST Provisioning Exchange
+ * RFC 5422:
+ * Section 3.3 - Key Derivations Used in the EAP-FAST Provisioning Exchange
  */
 struct eap_fast_key_block_provisioning {
        /* Extra key material after TLS key_block */
@@ -82,4 +83,39 @@ struct eap_fast_key_block_provisioning {
        u8 client_challenge[16]; /* MSCHAPv2 ClientChallenge */
 };
 
+
+struct wpabuf;
+struct tls_connection;
+
+struct eap_fast_tlv_parse {
+       u8 *eap_payload_tlv;
+       size_t eap_payload_tlv_len;
+       struct eap_tlv_crypto_binding_tlv *crypto_binding;
+       size_t crypto_binding_len;
+       int iresult;
+       int result;
+       int request_action;
+       u8 *pac;
+       size_t pac_len;
+};
+
+void eap_fast_put_tlv_hdr(struct wpabuf *buf, u16 type, u16 len);
+void eap_fast_put_tlv(struct wpabuf *buf, u16 type, const void *data,
+                     u16 len);
+void eap_fast_put_tlv_buf(struct wpabuf *buf, u16 type,
+                         const struct wpabuf *data);
+struct wpabuf * eap_fast_tlv_eap_payload(struct wpabuf *buf);
+void eap_fast_derive_master_secret(const u8 *pac_key, const u8 *server_random,
+                                  const u8 *client_random, u8 *master_secret);
+u8 * eap_fast_derive_key(void *ssl_ctx, struct tls_connection *conn,
+                        const char *label, size_t len);
+void eap_fast_derive_eap_msk(const u8 *simck, u8 *msk);
+void eap_fast_derive_eap_emsk(const u8 *simck, u8 *emsk);
+int eap_fast_parse_tlv(struct eap_fast_tlv_parse *tlv,
+                      int tlv_type, u8 *pos, int len);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* EAP_FAST_H */