The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Implements the EAP part of EAP-TLS. More...
#include <freeradius-devel/unlang/function.h>
#include <freeradius-devel/unlang/interpret.h>
#include <freeradius-devel/server/pair.h>
#include "tls.h"
#include "attrs.h"
Go to the source code of this file.
Functions | |
static int | eap_tls_ack (request_t *request, eap_session_t *eap_session) |
ACK a fragment of the TLS record from the peer. More... | |
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. More... | |
fr_tls_conf_t * | eap_tls_conf_parse (CONF_SECTION *cs, char const *attr) |
Parse TLS configuration. More... | |
int | eap_tls_fail (request_t *request, eap_session_t *eap_session) |
Send an EAP-TLS failure. More... | |
static unlang_action_t | eap_tls_handshake_push (request_t *request, eap_session_t *eap_session) |
Push functions to continue the handshake asynchronously. More... | |
static unlang_action_t | eap_tls_handshake_resume (UNUSED rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx) |
Process the result from the last TLS handshake round. More... | |
unlang_action_t | eap_tls_process (request_t *request, eap_session_t *eap_session) |
Process an EAP TLS request. More... | |
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. More... | |
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. More... | |
static eap_tls_status_t | eap_tls_session_status (request_t *request, eap_session_t *eap_session) |
Reduce session states down into an easy to use status. More... | |
int | eap_tls_start (request_t *request, eap_session_t *eap_session) |
Send an initial EAP-TLS request to the peer. More... | |
int | eap_tls_success (request_t *request, eap_session_t *eap_session, eap_tls_prf_label_t *prf_label) |
Send an EAP-TLS success. More... | |
static eap_tls_status_t | eap_tls_verify (request_t *request, eap_session_t *eap_session) |
Check that this EAP-TLS packet is correct and the progression of EAP-TLS packets is sane. More... | |
Variables | |
USES_APPLE_DEPRECATED_API fr_table_num_ordered_t const | eap_tls_status_table [] |
size_t | eap_tls_status_table_len = NUM_ELEMENTS(eap_tls_status_table) |
Implements the EAP part of EAP-TLS.
RFC 2716 Section 4.2. PPP EAP TLS Request Packet
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Code | Identifier | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Flags | TLS Message Length +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TLS Message Length | TLS Data... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Structure of an EAP-TLS packet
code = EAP-code id = EAP-id length = code + id + length + flags + tlsdata = 1 + 1 + 2 + 1 + X length = EAP-length - 1(EAP-Type = 1 octet) flags = EAP-typedata[0] (1 octet) data_len = EAP-typedata[1-4] (4 octets), if L flag set = length - 5(code+id+length+flags), otherwise data = EAP-typedata[5-n], if L flag set = EAP-typedata[1-n], otherwise packet = EAP-typedata (complete typedata)
The S flag is set only within the EAP-TLS start message sent from the EAP server to the peer.
Similarly, when the EAP server receives an EAP-Response with the M bit set, it MUST respond with an EAP-Request with EAP-Type = EAP-TLS and no data. This serves as a fragment ACK. The EAP peer MUST wait.
The Length field is two octets and indicates the length of the EAP packet including the Code, Identifier, Length, Type, and TLS data fields.
The TLS Message Length field is four octets and indicates the complete reassembled length of the TLS record fragment.
Definition in file tls.c.
|
static |
ACK a fragment of the TLS record from the peer.
EAP server sends an ACK when it determines there are More fragments to receive to make the complete TLS-record.
When the EAP server receives an EAP-Response with the M bit set, it MUST respond with an EAP-Request with EAP-Type = EAP-TLS and no data. This serves as a fragment ACK.
In order to prevent errors in the processing of fragments, the EAP server MUST use increment the Identifier value for each fragment ACK contained within an EAP-Request, and the peer MUST include this Identifier value in the subsequent fragment contained within an EAP-Reponse.
[in] | request | The current subrequest. |
[in] | eap_session | that we're acking the fragment for. |
Definition at line 464 of file tls.c.
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.
The EAP packet will be written to eap_round->request, with the original reply being untouched.
[in] | request | The current subrequest. |
[in] | eap_session | to continue. |
[in] | status | What type of packet we're sending. |
[in] | flags | to set. This is checked to determine if we need to include a length field. |
[in] | record | The record buffer to read from. This most only be set for EAP_TLS_RECORD_SEND packets. |
[in] | record_len | the length of the record we're sending. |
[in] | frag_len | the length of the fragment we're sending. |
Definition at line 114 of file tls.c.
fr_tls_conf_t* eap_tls_conf_parse | ( | CONF_SECTION * | cs, |
char const * | attr | ||
) |
Parse TLS configuration.
If the option given by 'attr' is set, we find the config section of that name and use that for the TLS configuration. If not, we fall back to compatibility mode and read the TLS options from the 'tls' section.
cs | to derive the configuration from. |
attr | identifier for common TLS configuration. |
Definition at line 1231 of file tls.c.
int eap_tls_fail | ( | request_t * | request, |
eap_session_t * | eap_session | ||
) |
Send an EAP-TLS failure.
Composes an EAP-TLS-Failure. This is a message with code EAP_TLS_FAILURE. It contains no cryptographic material, and is not protected.
In addition to sending the failure, will destroy any cached session data.
[in] | request | The current subrequest. |
[in] | eap_session | that failed. |
Definition at line 322 of file tls.c.
|
inlinestatic |
|
static |
Process the result from the last TLS handshake round.
Definition at line 806 of file tls.c.
unlang_action_t eap_tls_process | ( | request_t * | request, |
eap_session_t * | eap_session | ||
) |
Process an EAP TLS request.
Here we implement a basic state machine. The state machine is implicit and is driven by the state of the TLS session and the flags sent. INCOMING DATA:
During EAP-TLS initialization, TLS Context object will be initialised and stored. For every new authentication request, TLS will open a new session object and that session object SHOULD be maintained even after the session is completed, for session resumption.
request | the request |
eap_session | to continue. |
Definition at line 963 of file tls.c.
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.
A single TLS record may be up to 16384 octets in length, but a TLS message may span multiple TLS records, and a TLS certificate message may theoretically, be as big as 16MB.
In EAP-TLS with no inner method, this is used primarily to send our certificate chain to the peer.
In other methods this function is also called to package up application data for the inner tunnel method.
The eap_tls_session->length_included flag determines whether we include the extra four byte length field in the request and set the L flag.
If present, the tls_length field indicates the total length of the reassembled TLS record.
If eap_tls_session->length_included this means we include L flag and the tls_length field in EVERY packet we send out.
If !eap_tls_session->length_included this means we include L flag and tls_length field ONLY in First packet of a fragment series. We do not use it anywhere else.
request | the request |
eap_session | that's continuing. |
Definition at line 372 of file tls.c.
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.
Creates a new server fr_tls_session_t and associates it with an eap_session_t adding EAP specific opaque data to the SSL session created during fr_tls_session_t initialisation.
[in] | request | The current subrequest. |
[in] | eap_session | to use as a context for the eap_tls_session_t |
[in] | ssl_ctx | to use to configure the fr_tls_session_t. |
[in] | client_cert | Whether we require the peer to prevent a certificate. |
Definition at line 1131 of file tls.c.
|
static |
Reduce session states down into an easy to use status.
[in] | request | The current subrequest. |
[in] | eap_session | that we're acking the fragment for. |
Definition at line 484 of file tls.c.
int eap_tls_start | ( | request_t * | request, |
eap_session_t * | eap_session | ||
) |
Send an initial EAP-TLS request to the peer.
Once having received the peer's Identity, the EAP server MUST respond with an EAP-TLS/Start packet, which is an EAP-Request packet with EAP-Type = EAP-TLS, the Start (S) bit set, and no data.
The EAP-TLS conversation will then begin, with the peer sending an EAP-Response packet with EAP-Type = EAP-TLS. The data field of that packet will be the TLS data.
The S flag is set only within the EAP-TLS start message sent from the EAP server to the peer.
Fragment length is Framed-MTU - 4.
[in] | request | The current subrequest. |
[in] | eap_session | to initiate. |
Definition at line 239 of file tls.c.
int eap_tls_success | ( | request_t * | request, |
eap_session_t * | eap_session, | ||
eap_tls_prf_label_t * | prf_label | ||
) |
Send an EAP-TLS success.
Composes an EAP-TLS-Success. This is a message with code EAP_TLS_ESTABLISHED. It contains no cryptographic material, and is not protected.
We add the MPPE keys here. These are used by the NAS. The supplicant will derive the same keys separately.
[in] | request | The current subrequest. |
[in] | eap_session | that completed successfully. |
[in] | prf_label | PRF label struct |
Definition at line 264 of file tls.c.
|
static |
Check that this EAP-TLS packet is correct and the progression of EAP-TLS packets is sane.
[in] | request | the current subrequest. |
[in] | eap_session | the current EAP session state. |
Definition at line 559 of file tls.c.
USES_APPLE_DEPRECATED_API fr_table_num_ordered_t const eap_tls_status_table[] |
size_t eap_tls_status_table_len = NUM_ELEMENTS(eap_tls_status_table) |