eap_tls_common.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * EAP-TLS/PEAP/TTLS/FAST server common functions
  3. * Copyright (c) 2004-2009, 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. #ifndef EAP_TLS_COMMON_H
  9. #define EAP_TLS_COMMON_H
  10. /**
  11. * struct eap_ssl_data - TLS data for EAP methods
  12. */
  13. struct eap_ssl_data {
  14. /**
  15. * conn - TLS connection context data from tls_connection_init()
  16. */
  17. struct tls_connection *conn;
  18. /**
  19. * tls_out - TLS message to be sent out in fragments
  20. */
  21. struct wpabuf *tls_out;
  22. /**
  23. * tls_out_pos - The current position in the outgoing TLS message
  24. */
  25. size_t tls_out_pos;
  26. /**
  27. * tls_out_limit - Maximum fragment size for outgoing TLS messages
  28. */
  29. size_t tls_out_limit;
  30. /**
  31. * tls_in - Received TLS message buffer for re-assembly
  32. */
  33. struct wpabuf *tls_in;
  34. /**
  35. * phase2 - Whether this TLS connection is used in EAP phase 2 (tunnel)
  36. */
  37. int phase2;
  38. /**
  39. * eap - EAP state machine allocated with eap_server_sm_init()
  40. */
  41. struct eap_sm *eap;
  42. enum { MSG, FRAG_ACK, WAIT_FRAG_ACK } state;
  43. struct wpabuf tmpbuf;
  44. };
  45. /* EAP TLS Flags */
  46. #define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
  47. #define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
  48. #define EAP_TLS_FLAGS_START 0x20
  49. #define EAP_TLS_VERSION_MASK 0x07
  50. /* could be up to 128 bytes, but only the first 64 bytes are used */
  51. #define EAP_TLS_KEY_LEN 64
  52. int eap_server_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
  53. int verify_peer);
  54. void eap_server_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
  55. u8 * eap_server_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
  56. char *label, size_t len);
  57. struct wpabuf * eap_server_tls_build_msg(struct eap_ssl_data *data,
  58. int eap_type, int version, u8 id);
  59. struct wpabuf * eap_server_tls_build_ack(u8 id, int eap_type, int version);
  60. int eap_server_tls_phase1(struct eap_sm *sm, struct eap_ssl_data *data);
  61. struct wpabuf * eap_server_tls_encrypt(struct eap_sm *sm,
  62. struct eap_ssl_data *data,
  63. const struct wpabuf *plain);
  64. int eap_server_tls_process(struct eap_sm *sm, struct eap_ssl_data *data,
  65. struct wpabuf *respData, void *priv, int eap_type,
  66. int (*proc_version)(struct eap_sm *sm, void *priv,
  67. int peer_version),
  68. void (*proc_msg)(struct eap_sm *sm, void *priv,
  69. const struct wpabuf *respData));
  70. #endif /* EAP_TLS_COMMON_H */