eap_tls_common.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * EAP-TLS/PEAP/TTLS/FAST server common functions
  3. * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef EAP_TLS_COMMON_H
  15. #define EAP_TLS_COMMON_H
  16. /**
  17. * struct eap_ssl_data - TLS data for EAP methods
  18. */
  19. struct eap_ssl_data {
  20. /**
  21. * conn - TLS connection context data from tls_connection_init()
  22. */
  23. struct tls_connection *conn;
  24. /**
  25. * tls_out - TLS message to be sent out in fragments
  26. */
  27. struct wpabuf *tls_out;
  28. /**
  29. * tls_out_pos - The current position in the outgoing TLS message
  30. */
  31. size_t tls_out_pos;
  32. /**
  33. * tls_out_limit - Maximum fragment size for outgoing TLS messages
  34. */
  35. size_t tls_out_limit;
  36. /**
  37. * tls_in - Received TLS message buffer for re-assembly
  38. */
  39. struct wpabuf *tls_in;
  40. /**
  41. * phase2 - Whether this TLS connection is used in EAP phase 2 (tunnel)
  42. */
  43. int phase2;
  44. /**
  45. * eap - EAP state machine allocated with eap_server_sm_init()
  46. */
  47. struct eap_sm *eap;
  48. enum { MSG, FRAG_ACK, WAIT_FRAG_ACK } state;
  49. struct wpabuf tmpbuf;
  50. };
  51. /* EAP TLS Flags */
  52. #define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
  53. #define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
  54. #define EAP_TLS_FLAGS_START 0x20
  55. #define EAP_TLS_VERSION_MASK 0x07
  56. /* could be up to 128 bytes, but only the first 64 bytes are used */
  57. #define EAP_TLS_KEY_LEN 64
  58. int eap_server_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
  59. int verify_peer);
  60. void eap_server_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
  61. u8 * eap_server_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
  62. char *label, size_t len);
  63. struct wpabuf * eap_server_tls_build_msg(struct eap_ssl_data *data,
  64. int eap_type, int version, u8 id);
  65. struct wpabuf * eap_server_tls_build_ack(u8 id, int eap_type, int version);
  66. int eap_server_tls_phase1(struct eap_sm *sm, struct eap_ssl_data *data);
  67. struct wpabuf * eap_server_tls_encrypt(struct eap_sm *sm,
  68. struct eap_ssl_data *data,
  69. const struct wpabuf *plain);
  70. int eap_server_tls_process(struct eap_sm *sm, struct eap_ssl_data *data,
  71. struct wpabuf *respData, void *priv, int eap_type,
  72. int (*proc_version)(struct eap_sm *sm, void *priv,
  73. int peer_version),
  74. void (*proc_msg)(struct eap_sm *sm, void *priv,
  75. const struct wpabuf *respData));
  76. #endif /* EAP_TLS_COMMON_H */