28 RCSIDH(lib_eap_tls_h,
"$Id: 5d63710780e3beabd8dcb6610f7c4a32fca5ef58 $")
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <netinet/tcp.h>
45 #include <arpa/inet.h>
51 #include <freeradius-devel/server/base.h>
52 #include <freeradius-devel/tls/base.h>
53 #include <freeradius-devel/eap/base.h>
55 #define TLS_HEADER_LEN 4
56 #define TLS_HEADER_LENGTH_FIELD_LEN 4
73 #define TLS_RESERVED4(x) (((x) & 0x01) != 0)
74 #define TLS_RESERVED3(x) (((x) & 0x02) != 0)
75 #define TLS_RESERVED2(x) (((x) & 0x04) != 0)
76 #define TLS_RESERVED1(x) (((x) & 0x08) != 0)
77 #define TLS_RESERVED0(x) (((x) & 0x10) != 0)
78 #define TLS_START(x) (((x) & 0x20) != 0)
79 #define TLS_MORE_FRAGMENTS(x) (((x) & 0x40) != 0)
80 #define TLS_LENGTH_INCLUDED(x) (((x) & 0x80) != 0)
82 #define TLS_CHANGE_CIPHER_SPEC(x) (((x) & 0x0014) == 0x0014)
83 #define TLS_ALERT(x) (((x) & 0x0015) == 0x0015)
84 #define TLS_HANDSHAKE(x) (((x) & 0x0016) == 0x0016)
86 #define SET_START(x) ((x) | (0x20))
87 #define SET_MORE_FRAGMENTS(x) ((x) | (0x40))
88 #define SET_LENGTH_INCLUDED(x) ((x) | (0x80))
187 fr_tls_record_t *record,
size_t record_len,
size_t frag_len);
191 char const *keying_prf_label,
size_t keying_prf_label_len);
201 SSL_CTX *ssl_ctx,
bool client_cert) CC_HINT(
nonnull);
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
#define USES_APPLE_DEPRECATED_API
A section grouping multiple CONF_PAIR.
Tracks the progress of a single session of any EAP method.
Signals that can be sent to a request.
An element in an arbitrarily ordered array of name to num mappings.
int base_flags
Some protocols use the reserved bits of the EAP-TLS flags (such as PEAP).
eap_tls_status_t state
The state of the EAP-TLS session.
bool phase2
Whether we're in phase 2.
@ EAP_TLS_RECORD_RECV_FIRST
Received first fragment of a record.
@ EAP_TLS_INVALID
Invalid, don't reply.
@ EAP_TLS_HANDLED
TLS code has handled it.
@ EAP_TLS_RECORD_RECV_MORE
Received additional fragment of a record.
@ EAP_TLS_ACK_SEND
Acknowledge receipt of a record or record fragment.
@ EAP_TLS_RECORD_SEND
We're sending a record.
@ EAP_TLS_RECORD_RECV_COMPLETE
Received final fragment of a record.
@ EAP_TLS_START_SEND
We're starting a new TLS session.
@ EAP_TLS_FAIL
Fail, send fail.
@ EAP_TLS_ESTABLISHED
Session established, send success (or start phase2).
fr_tls_session_t * tls_session
TLS session used to authenticate peer or tunnel sensitive data.
eap_tls_session_t * eap_tls_session_init(request_t *request, eap_session_t *eap_session, SSL_CTX *ssl_ctx, bool client_cert)
Create a new fr_tls_session_t associated with an eap_session_t.
size_t keying_prf_label_len
length of the keying PRF label.
bool record_in_started
Whether a record transfer from the peer is currently in progress.
size_t record_out_total_len
Actual/Total TLS message length we're sending.
char const * keying_prf_label
PRF label to use for generating keying material.
int eap_tls_compose(request_t *request, eap_session_t *eap_session, eap_tls_status_t status, uint8_t flags, fr_tls_record_t *record, size_t record_len, size_t frag_len)
Convert the EAP-TLS reply packet into an EAP packet.
void eap_crypto_prf_label_init(eap_tls_prf_label_t *prf_label, eap_session_t *eap_session, char const *keying_prf_label, size_t keying_prf_label_len)
Initialize the PRF label fields.
fr_table_num_ordered_t const eap_tls_status_table[]
size_t context_len
length of the context
size_t record_in_total_len
How long the peer indicated the complete tls record would be.
size_t eap_tls_status_table_len
int eap_crypto_mppe_keys(request_t *request, SSL *ssl, eap_tls_prf_label_t *prf_label)
Generate keys according to RFC 5216 and add to the reply.
int eap_tls_start(request_t *request, eap_session_t *eap_session)
Send an initial EAP-TLS request to the peer.
int eap_tls_request(request_t *request, eap_session_t *eap_session)
Frames the OpenSSL data that needs to be sent to the client in an EAP-Request.
int eap_tls_success(request_t *request, eap_session_t *eap_session, eap_tls_prf_label_t *prf_label))
Send an EAP-TLS success.
int eap_tls_fail(request_t *request, eap_session_t *eap_session)
Send an EAP-TLS failure.
char const * sessid_prf_label
PRF label to use when generating the session ID.
fr_tls_conf_t * eap_tls_conf_parse(CONF_SECTION *cs, char const *key)
Parse TLS configuration.
bool record_out_started
for methods with inner auth, if the inner auth succeeded.
size_t record_in_recvd_len
How much of the record we've received so far.
int use_context
for SSL_export_keying_material().
int eap_crypto_tls_session_id(TALLOC_CTX *ctx, request_t *request, SSL *ssl, eap_tls_prf_label_t *prf_label, uint8_t **out, uint8_t eap_type)
bool authentication_success
size_t sessid_prf_label_len
Length of the session ID PRF label.
bool include_length
A flag to include length in every TLS Data/Alert packet.
unlang_action_t eap_tls_process(request_t *request, eap_session_t *eap_session)
Process an EAP TLS request.
Tracks the state of an EAP-TLS session.
static size_t char ** out