eap.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * eap.h - Extensible Authentication Protocol for PPP (RFC 2284)
  3. *
  4. * Copyright (c) 2001 by Sun Microsystems, Inc.
  5. * All rights reserved.
  6. *
  7. * Non-exclusive rights to redistribute, modify, translate, and use
  8. * this software in source and binary forms, in whole or in part, is
  9. * hereby granted, provided that the above copyright notice is
  10. * duplicated in any source form, and that neither the name of the
  11. * copyright holder nor the author is used to endorse or promote
  12. * products derived from this software.
  13. *
  14. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  15. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  17. *
  18. * Original version by James Carlson
  19. *
  20. * $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $
  21. */
  22. #ifndef PPP_EAP_H
  23. #define PPP_EAP_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /*
  28. * Packet header = Code, id, length.
  29. */
  30. #define EAP_HEADERLEN 4
  31. /* EAP message codes. */
  32. #define EAP_REQUEST 1
  33. #define EAP_RESPONSE 2
  34. #define EAP_SUCCESS 3
  35. #define EAP_FAILURE 4
  36. /* EAP types */
  37. #define EAPT_IDENTITY 1
  38. #define EAPT_NOTIFICATION 2
  39. #define EAPT_NAK 3 /* (response only) */
  40. #define EAPT_MD5CHAP 4
  41. #define EAPT_OTP 5 /* One-Time Password; RFC 1938 */
  42. #define EAPT_TOKEN 6 /* Generic Token Card */
  43. /* 7 and 8 are unassigned. */
  44. #define EAPT_RSA 9 /* RSA Public Key Authentication */
  45. #define EAPT_DSS 10 /* DSS Unilateral */
  46. #define EAPT_KEA 11 /* KEA */
  47. #define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */
  48. #define EAPT_TLS 13 /* EAP-TLS */
  49. #define EAPT_DEFENDER 14 /* Defender Token (AXENT) */
  50. #define EAPT_W2K 15 /* Windows 2000 EAP */
  51. #define EAPT_ARCOT 16 /* Arcot Systems */
  52. #define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */
  53. #define EAPT_NOKIACARD 18 /* Nokia IP smart card */
  54. #define EAPT_SRP 19 /* Secure Remote Password */
  55. /* 20 is deprecated */
  56. /* EAP SRP-SHA1 Subtypes */
  57. #define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */
  58. #define EAPSRP_CKEY 1 /* Response 1 - Client Key */
  59. #define EAPSRP_SKEY 2 /* Request 2 - Server Key */
  60. #define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */
  61. #define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */
  62. #define EAPSRP_ACK 3 /* Response 3 - final ack */
  63. #define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */
  64. #define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */
  65. #define SRP_PSEUDO_ID "pseudo_"
  66. #define SRP_PSEUDO_LEN 7
  67. #define MD5_SIGNATURE_SIZE 16
  68. #define MIN_CHALLENGE_LENGTH 16
  69. #define MAX_CHALLENGE_LENGTH 24
  70. enum eap_state_code {
  71. eapInitial = 0, /* No EAP authentication yet requested */
  72. eapPending, /* Waiting for LCP (no timer) */
  73. eapClosed, /* Authentication not in use */
  74. eapListen, /* Client ready (and timer running) */
  75. eapIdentify, /* EAP Identify sent */
  76. eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */
  77. eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */
  78. eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */
  79. eapMD5Chall, /* Sent MD5-Challenge */
  80. eapOpen, /* Completed authentication */
  81. eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */
  82. eapBadAuth /* Failed authentication */
  83. };
  84. #define EAP_STATES \
  85. "Initial", "Pending", "Closed", "Listen", "Identify", \
  86. "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
  87. #define eap_client_active(esp) ((esp)->es_client.ea_state == eapListen)
  88. #define eap_server_active(esp) \
  89. ((esp)->es_server.ea_state >= eapIdentify && \
  90. (esp)->es_server.ea_state <= eapMD5Chall)
  91. struct eap_auth {
  92. char *ea_name; /* Our name */
  93. char *ea_peer; /* Peer's name */
  94. void *ea_session; /* Authentication library linkage */
  95. u_char *ea_skey; /* Shared encryption key */
  96. int ea_timeout; /* Time to wait (for retransmit/fail) */
  97. int ea_maxrequests; /* Max Requests allowed */
  98. u_short ea_namelen; /* Length of our name */
  99. u_short ea_peerlen; /* Length of peer's name */
  100. enum eap_state_code ea_state;
  101. u_char ea_id; /* Current id */
  102. u_char ea_requests; /* Number of Requests sent/received */
  103. u_char ea_responses; /* Number of Responses */
  104. u_char ea_type; /* One of EAPT_* */
  105. u_int32_t ea_keyflags; /* SRP shared key usage flags */
  106. };
  107. /*
  108. * Complete EAP state for one PPP session.
  109. */
  110. typedef struct eap_state {
  111. int es_unit; /* Interface unit number */
  112. struct eap_auth es_client; /* Client (authenticatee) data */
  113. struct eap_auth es_server; /* Server (authenticator) data */
  114. int es_savedtime; /* Saved timeout */
  115. int es_rechallenge; /* EAP rechallenge interval */
  116. int es_lwrechallenge; /* SRP lightweight rechallenge inter */
  117. bool es_usepseudo; /* Use SRP Pseudonym if offered one */
  118. int es_usedpseudo; /* Set if we already sent PN */
  119. int es_challen; /* Length of challenge string */
  120. u_char es_challenge[MAX_CHALLENGE_LENGTH];
  121. } eap_state;
  122. /*
  123. * Timeouts.
  124. */
  125. #define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */
  126. #define EAP_DEFTRANSMITS 10 /* max # times to transmit */
  127. #define EAP_DEFREQTIME 20 /* Time to wait for peer request */
  128. #define EAP_DEFALLOWREQ 20 /* max # times to accept requests */
  129. extern eap_state eap_states[];
  130. void eap_authwithpeer __P((int unit, char *localname));
  131. void eap_authpeer __P((int unit, char *localname));
  132. extern struct protent eap_protent;
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif /* PPP_EAP_H */