eap_tls.h
Go to the documentation of this file.
1 /**
2  * @file eap_tls.h
3  * @brief EAP-TLS authentication method
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2022-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneEAP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _EAP_TLS_H
32 #define _EAP_TLS_H
33 
34 //Dependencies
35 #include "eap/eap.h"
36 #include "supplicant/supplicant.h"
37 
38 //Offset to the TLS data field
39 #define EAP_TLS_TX_BUFFER_START_POS (sizeof(EapolPdu) + \
40  sizeof(EapTlsPacket) + sizeof(uint32_t))
41 
42 //Maximum fragment size (for first fragment)
43 #define EAP_TLS_MAX_INIT_FRAG_SIZE (EAP_MAX_FRAG_SIZE - sizeof(EapolPdu) - \
44  sizeof(EapTlsPacket) - sizeof(uint32_t))
45 
46 //Maximum fragment size (for subsequent fragments)
47 #define EAP_TLS_MAX_FRAG_SIZE (EAP_MAX_FRAG_SIZE - sizeof(EapolPdu) - \
48  sizeof(EapTlsPacket))
49 
50 
51 //C++ guard
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 //EAP-TLS related functions
58  const EapTlsPacket *request, size_t length);
59 
61  const EapTlsPacket *request, size_t length);
62 
64 
66 void eapCloseTls(SupplicantContext *context, error_t error);
67 
68 error_t eapTlsSendCallback(void *handle, const void *data, size_t length,
69  size_t *written, uint_t flags);
70 
71 error_t eapTlsReceiveCallback(void *handle, void *data, size_t size,
72  size_t *received, uint_t flags);
73 
74 //C++ guard
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif
void eapTlsBuildResponse(SupplicantContext *context)
Build EAP-TLS response.
Definition: eap_tls.c:234
802.1X supplicant
uint8_t data[]
Definition: ethernet.h:222
void eapCloseTls(SupplicantContext *context, error_t error)
Close TLS session.
Definition: eap_tls.c:384
#define SupplicantContext
Definition: supplicant.h:36
EapTlsPacket
Definition: eap.h:267
error_t
Error codes.
Definition: error.h:43
error_t eapOpenTls(SupplicantContext *context)
Open TLS session.
Definition: eap_tls.c:332
uint8_t length
Definition: tcp.h:368
void eapTlsProcessRequest(SupplicantContext *context, const EapTlsPacket *request, size_t length)
Process incoming EAP-TLS request.
Definition: eap_tls.c:79
uint8_t flags
Definition: tcp.h:351
error_t eapTlsReceiveCallback(void *handle, void *data, size_t size, size_t *received, uint_t flags)
TLS receive callback (I/O abstraction layer)
Definition: eap_tls.c:460
error_t eapTlsSendCallback(void *handle, const void *data, size_t length, size_t *written, uint_t flags)
TLS send callback (I/O abstraction layer)
Definition: eap_tls.c:412
error_t eapTlsCheckRequest(SupplicantContext *context, const EapTlsPacket *request, size_t length)
Check incoming EAP-TLS request.
Definition: eap_tls.c:51
unsigned int uint_t
Definition: compiler_port.h:50
EAP (Extensible Authentication Protocol)