1 /* $NetBSD: eap.h,v 1.5 2021/01/09 16:39:28 christos Exp $ */ 2 3 /* 4 * eap.h - Extensible Authentication Protocol for PPP (RFC 2284) 5 * 6 * Copyright (c) 2001 by Sun Microsystems, Inc. 7 * All rights reserved. 8 * 9 * Non-exclusive rights to redistribute, modify, translate, and use 10 * this software in source and binary forms, in whole or in part, is 11 * hereby granted, provided that the above copyright notice is 12 * duplicated in any source form, and that neither the name of the 13 * copyright holder nor the author is used to endorse or promote 14 * products derived from this software. 15 * 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * 20 * Original version by James Carlson 21 * 22 * Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp 23 */ 24 25 #ifndef PPP_EAP_H 26 #define PPP_EAP_H 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /* 33 * Packet header = Code, id, length. 34 */ 35 #define EAP_HEADERLEN 4 36 37 38 /* EAP message codes. */ 39 #define EAP_REQUEST 1 40 #define EAP_RESPONSE 2 41 #define EAP_SUCCESS 3 42 #define EAP_FAILURE 4 43 44 /* EAP types */ 45 #define EAPT_IDENTITY 1 46 #define EAPT_NOTIFICATION 2 47 #define EAPT_NAK 3 /* (response only) */ 48 #define EAPT_MD5CHAP 4 49 #define EAPT_OTP 5 /* One-Time Password; RFC 1938 */ 50 #define EAPT_TOKEN 6 /* Generic Token Card */ 51 /* 7 and 8 are unassigned. */ 52 #define EAPT_RSA 9 /* RSA Public Key Authentication */ 53 #define EAPT_DSS 10 /* DSS Unilateral */ 54 #define EAPT_KEA 11 /* KEA */ 55 #define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */ 56 #define EAPT_TLS 13 /* EAP-TLS */ 57 #define EAPT_DEFENDER 14 /* Defender Token (AXENT) */ 58 #define EAPT_W2K 15 /* Windows 2000 EAP */ 59 #define EAPT_ARCOT 16 /* Arcot Systems */ 60 #define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */ 61 #define EAPT_NOKIACARD 18 /* Nokia IP smart card */ 62 #define EAPT_SRP 19 /* Secure Remote Password */ 63 /* 20 is deprecated */ 64 #define EAPT_TTLS 21 /* EAP Tunneled TLS Authentication Protocol RFC5281 */ 65 #define EAPT_RAS 22 /* Remote Access Service */ 66 #define EAPT_AKA 23 /* EAP method for 3rd Generation Authentication and Key Agreement RFC4187 */ 67 #define EAPT_3COM 24 /* EAP-3Com Wireless */ 68 #define EAPT_PEAP 25 /* Protected EAP */ 69 #define EAPT_MSCHAPV2 26 /* EAP-MSCHAPv2 RFC-draft-kamath-pppext-eap-mschapv2-02 */ 70 71 /* OpCodes for MSCHAPv2 */ 72 #define CHAP_CHALLENGE 1 73 #define CHAP_RESPONSE 2 74 #define CHAP_SUCCESS 3 75 #define CHAP_FAILURE 4 76 77 /* EAP SRP-SHA1 Subtypes */ 78 #define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */ 79 #define EAPSRP_CKEY 1 /* Response 1 - Client Key */ 80 #define EAPSRP_SKEY 2 /* Request 2 - Server Key */ 81 #define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */ 82 #define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */ 83 #define EAPSRP_ACK 3 /* Response 3 - final ack */ 84 #define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */ 85 86 #define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */ 87 88 #define SRP_PSEUDO_ID "pseudo_" 89 #define SRP_PSEUDO_LEN 7 90 91 #define MD5_SIGNATURE_SIZE 16 92 #define MIN_CHALLENGE_LENGTH 16 93 #define MAX_CHALLENGE_LENGTH 24 94 95 enum eap_state_code { 96 eapInitial = 0, /* No EAP authentication yet requested */ 97 eapPending, /* Waiting for LCP (no timer) */ 98 eapClosed, /* Authentication not in use */ 99 eapListen, /* Client ready (and timer running) */ 100 eapIdentify, /* EAP Identify sent */ 101 eapTlsStart, /* Send EAP-TLS start packet */ 102 eapTlsRecv, /* Receive EAP-TLS tls data */ 103 eapTlsSendAck, /* Send EAP-TLS ack */ 104 eapTlsSend, /* Send EAP-TLS tls data */ 105 eapTlsRecvAck, /* Receive EAP-TLS ack */ 106 eapTlsRecvClient, /* Receive EAP-TLS auth response from client*/ 107 eapTlsSendAlert, /* Send EAP-TLS tls alert (server)*/ 108 eapTlsRecvAlertAck, /* Receive EAP-TLS ack after sending alert */ 109 eapTlsRecvSuccess, /* Receive EAP success */ 110 eapTlsRecvFailure, /* Receive EAP failure */ 111 eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */ 112 eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */ 113 eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */ 114 eapMD5Chall, /* Sent MD5-Challenge */ 115 eapMSCHAPv2Chall, /* Sent MSCHAPv2-Challenge */ 116 eapOpen, /* Completed authentication */ 117 eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */ 118 eapBadAuth /* Failed authentication */ 119 }; 120 121 #define EAP_STATES \ 122 "Initial", "Pending", "Closed", "Listen", "Identify", \ 123 "TlsStart", "TlsRecv", "TlsSendAck", "TlsSend", "TlsRecvAck", "TlsRecvClient",\ 124 "TlsSendAlert", "TlsRecvAlertAck" , "TlsRecvSuccess", "TlsRecvFailure", \ 125 "SRP1", "SRP2", "SRP3", "MD5Chall", "MSCHAPv2Chall", "Open", "SRP4", "BadAuth" 126 127 #ifdef USE_EAPTLS 128 #define eap_client_active(esp) ((esp)->es_client.ea_state != eapInitial &&\ 129 (esp)->es_client.ea_state != eapPending &&\ 130 (esp)->es_client.ea_state != eapClosed) 131 #else 132 #define eap_client_active(esp) ((esp)->es_client.ea_state == eapListen) 133 #endif /* USE_EAPTLS */ 134 135 #define eap_server_active(esp) \ 136 ((esp)->es_server.ea_state >= eapIdentify && \ 137 (esp)->es_server.ea_state <= eapMD5Chall) 138 139 struct eap_auth { 140 char *ea_name; /* Our name */ 141 char *ea_peer; /* Peer's name */ 142 void *ea_session; /* Authentication library linkage */ 143 u_char *ea_skey; /* Shared encryption key */ 144 int ea_timeout; /* Time to wait (for retransmit/fail) */ 145 int ea_maxrequests; /* Max Requests allowed */ 146 u_short ea_namelen; /* Length of our name */ 147 u_short ea_peerlen; /* Length of peer's name */ 148 enum eap_state_code ea_state; 149 #ifdef USE_EAPTLS 150 enum eap_state_code ea_prev_state; 151 #endif 152 #ifdef CHAPMS 153 struct chap_digest_type *digest; 154 #endif 155 u_char ea_id; /* Current id */ 156 u_char ea_requests; /* Number of Requests sent/received */ 157 u_char ea_responses; /* Number of Responses */ 158 u_char ea_type; /* One of EAPT_* */ 159 u_int32_t ea_keyflags; /* SRP shared key usage flags */ 160 #ifdef USE_EAPTLS 161 bool ea_using_eaptls; 162 #endif 163 }; 164 165 /* 166 * Complete EAP state for one PPP session. 167 */ 168 typedef struct eap_state { 169 int es_unit; /* Interface unit number */ 170 struct eap_auth es_client; /* Client (authenticatee) data */ 171 struct eap_auth es_server; /* Server (authenticator) data */ 172 int es_savedtime; /* Saved timeout */ 173 int es_rechallenge; /* EAP rechallenge interval */ 174 int es_lwrechallenge; /* SRP lightweight rechallenge inter */ 175 bool es_usepseudo; /* Use SRP Pseudonym if offered one */ 176 int es_usedpseudo; /* Set if we already sent PN */ 177 int es_challen; /* Length of challenge string */ 178 u_char es_challenge[MAX_CHALLENGE_LENGTH]; 179 } eap_state; 180 181 /* 182 * Timeouts. 183 */ 184 #define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */ 185 #ifdef USE_EAPTLS 186 #define EAP_DEFTRANSMITS 30 /* max # times to transmit */ 187 /* certificates can be long ... */ 188 #else 189 #define EAP_DEFTRANSMITS 10 /* max # times to transmit */ 190 #endif /* USE_EAPTLS */ 191 #define EAP_DEFREQTIME 20 /* Time to wait for peer request */ 192 #define EAP_DEFALLOWREQ 20 /* max # times to accept requests */ 193 194 extern eap_state eap_states[]; 195 196 void eap_authwithpeer (int unit, char *localname); 197 void eap_authpeer (int unit, char *localname); 198 199 extern struct protent eap_protent; 200 201 #ifdef __cplusplus 202 } 203 #endif 204 205 #endif /* PPP_EAP_H */ 206 207