| 1 |
/* |
| 2 |
* Copyright (c) 2011 Rustam Kovhaev. All rights reserved. |
| 3 |
* Copyright (c) 2021 Eivind Næss. All rights reserved. |
| 4 |
* |
| 5 |
* Redistribution and use in source and binary forms, with or without |
| 6 |
* modification, are permitted provided that the following conditions |
| 7 |
* are met: |
| 8 |
* |
| 9 |
* 1. Redistributions of source code must retain the above copyright |
| 10 |
* notice, this list of conditions and the following disclaimer. |
| 11 |
* |
| 12 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
* notice, this list of conditions and the following disclaimer in |
| 14 |
* the documentation and/or other materials provided with the |
| 15 |
* distribution. |
| 16 |
* |
| 17 |
* 3. The name(s) of the authors of this software must not be used to |
| 18 |
* endorse or promote products derived from this software without |
| 19 |
* prior written permission. |
| 20 |
* |
| 21 |
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO |
| 22 |
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 23 |
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY |
| 24 |
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 25 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN |
| 26 |
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
| 27 |
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 28 |
*/ |
| 29 |
|
| 30 |
#ifndef PPP_PEAP_H |
| 31 |
#define PPP_PEAP_H |
| 32 |
|
| 33 |
#include "pppdconf.h" |
| 34 |
|
| 35 |
#define PEAP_PHASE_1 1 |
| 36 |
#define PEAP_PHASE_2 2 |
| 37 |
|
| 38 |
#define PEAP_HEADERLEN 6 |
| 39 |
#define PEAP_FRAGMENT_LENGTH_FIELD 4 |
| 40 |
#define PEAP_FLAGS_FIELD 1 |
| 41 |
#define PEAP_FLAGS_ACK 0 |
| 42 |
|
| 43 |
#define PEAP_CAPABILITIES_TYPE 254 |
| 44 |
#define PEAP_CAPABILITIES_LEN 12 |
| 45 |
|
| 46 |
#define PEAP_TLV_TYPE 12 |
| 47 |
#define PEAP_TLV_LENGTH_FIELD 56 |
| 48 |
#define PEAP_TLV_SUBTYPE_REQUEST 0 |
| 49 |
#define PEAP_TLV_SUBTYPE_RESPONSE 1 |
| 50 |
#define PEAP_TLV_HEADERLEN 8 |
| 51 |
#define PEAP_TLV_RESULT_LEN 7 |
| 52 |
#define PEAP_TLV_LEN 71 |
| 53 |
|
| 54 |
/* |
| 55 |
* Microsoft PEAP client/server never exchange |
| 56 |
* outer TLVs during PEAP authentication |
| 57 |
*/ |
| 58 |
#define PEAP_TLV_DATA_LEN 61 |
| 59 |
|
| 60 |
#define PEAP_TLV_TK_LEN 60 |
| 61 |
#define PEAP_TLV_ISK_LEN 32 |
| 62 |
#define PEAP_TLV_IPMKSEED_LEN 59 |
| 63 |
#define PEAP_TLV_TEMPKEY_LEN 40 |
| 64 |
#define PEAP_TLV_IPMK_LEN 40 |
| 65 |
#define PEAP_TLV_CMK_LEN 20 |
| 66 |
#define PEAP_TLV_NONCE_LEN 32 |
| 67 |
#define PEAP_TLV_COMP_MAC_LEN 20 |
| 68 |
#define PEAP_TLV_CSK_LEN 128 |
| 69 |
#define PEAP_TLV_TK_SEED_LABEL "client EAP encryption" |
| 70 |
#define PEAP_TLV_IPMK_SEED_LABEL "Inner Methods Compound Keys" |
| 71 |
#define PEAP_TLV_CSK_SEED_LABEL "Session Key Generating Function" |
| 72 |
|
| 73 |
#define PEAP_S_FLAG_SET 0x20 |
| 74 |
#define PEAP_L_FLAG_SET 0x80 |
| 75 |
#define PEAP_LM_FLAG_SET 0xC0 |
| 76 |
#define PEAP_M_FLAG_SET 0x40 |
| 77 |
#define PEAP_NO_FLAGS 0x00 |
| 78 |
|
| 79 |
#define EAP_TLS_KEY_LEN 0x40 |
| 80 |
#define TLS_RECORD_MAX_SIZE 0x4000 |
| 81 |
|
| 82 |
struct peap_state; |
| 83 |
|
| 84 |
/** |
| 85 |
* Initialize the PEAP structure |
| 86 |
*/ |
| 87 |
int peap_init(struct peap_state** psm, const char *remote_name); |
| 88 |
|
| 89 |
/** |
| 90 |
* Process a PEAP packet |
| 91 |
*/ |
| 92 |
int peap_process(eap_state *esp, u_char id, u_char *inp, int len); |
| 93 |
|
| 94 |
/** |
| 95 |
* Clean up the PEAP structure |
| 96 |
*/ |
| 97 |
void peap_finish(struct peap_state **psm); |
| 98 |
|
| 99 |
#endif /* PPP_PEAP_H */ |