| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifndef _EAP_H_ |
| 9 |
#define _EAP_H_ |
| 10 |
|
| 11 |
#include "common/attributes.h" |
| 12 |
#include "config.h" |
| 13 |
#include "crypto/srp.h" |
| 14 |
#include "librist/librist_srp.h" |
| 15 |
#include <stdint.h> |
| 16 |
#include <stddef.h> |
| 17 |
#include <stdbool.h> |
| 18 |
|
| 19 |
|
| 20 |
#define EAPOL_TYPE_EAP 0 |
| 21 |
#define EAPOL_TYPE_START 1 |
| 22 |
#define EAPOL_TYPE_LOGOFF 2 |
| 23 |
|
| 24 |
RIST_PACKED_STRUCT(eapol_hdr, { |
| 25 |
uint8_t eapversion; |
| 26 |
uint8_t eaptype; |
| 27 |
uint16_t length; |
| 28 |
}) |
| 29 |
|
| 30 |
|
| 31 |
#define EAP_CODE_REQUEST 1 |
| 32 |
#define EAP_CODE_RESPONSE 2 |
| 33 |
#define EAP_CODE_SUCCESS 3 |
| 34 |
#define EAP_CODE_FAILURE 4 |
| 35 |
|
| 36 |
RIST_PACKED_STRUCT(eap_hdr, { |
| 37 |
uint8_t code; |
| 38 |
uint8_t identifier; |
| 39 |
uint16_t length; |
| 40 |
}) |
| 41 |
|
| 42 |
#define EAPOL_EAP_HDRS_OFFSET sizeof(struct eapol_hdr) + sizeof(struct eap_hdr) |
| 43 |
|
| 44 |
#define EAP_TYPE_IDENTITY 1 |
| 45 |
#define EAP_TYPE_NOTIFICATION 2 |
| 46 |
#define EAP_TYPE_NAK 3 |
| 47 |
#define EAP_TYPE_MD5_CHALLENGE 4 |
| 48 |
|
| 49 |
|
| 50 |
#define EAP_TYPE_SRP_SHA1 19 |
| 51 |
|
| 52 |
|
| 53 |
#define EAP_SRP_SUBTYPE_CHALLENGE 1 |
| 54 |
#define EAP_SRP_SUBTYPE_SERVER_KEY 2 |
| 55 |
|
| 56 |
|
| 57 |
#define EAP_SRP_SUBTYPE_CLIENT_KEY 1 |
| 58 |
#define EAP_SRP_SYPTYPE_CLIENT_VALIDATOR 2 |
| 59 |
|
| 60 |
|
| 61 |
#define EAP_SRP_SUBTYPE_SERVER_VALIDATOR 3 |
| 62 |
#define EAP_SRP_SUBTYPE_LWRECHALLENGE 4 |
| 63 |
#define EAP_SRP_SUBTYPE_PASSWORD_REQUEST_RESPONSE 0x10 |
| 64 |
|
| 65 |
RIST_PACKED_STRUCT(eap_srp_hdr, { |
| 66 |
uint8_t type; |
| 67 |
uint8_t subtype; |
| 68 |
}) |
| 69 |
|
| 70 |
#define EAP_ROLE_AUTHENTICATEE 0 |
| 71 |
#define EAP_ROLE_AUTHENTICATOR 1 |
| 72 |
|
| 73 |
#define EAP_AUTH_STATE_FAILED -1 |
| 74 |
#define EAP_AUTH_STATE_UNAUTH 0 |
| 75 |
#define EAP_AUTH_STATE_SUCCESS 1 |
| 76 |
#define EAP_AUTH_STATE_REAUTH 2 |
| 77 |
|
| 78 |
#define EAP_PASSPHRASE_STATE_SENDING 0 |
| 79 |
#define EAP_PASSPHRASE_STATE_SUCCESS 1 |
| 80 |
#define EAP_PASSPHRASE_STATE_FAILED 2 |
| 81 |
|
| 82 |
#define EAP_LENERR -1 |
| 83 |
#define EAP_WRONGIDENTIFIER -2 |
| 84 |
#define EAP_UNEXPECTEDRESPONSE -3 |
| 85 |
#define EAP_UNEXPECTEDREQUEST -4 |
| 86 |
#define EAP_SRP_WRONGSUBTYPE -5 |
| 87 |
#define EAP_INTERNALERR -6 |
| 88 |
#define EAP_AUTH_FAILED -7 |
| 89 |
#define EAP_AUTH_TERMINATED -8 |
| 90 |
|
| 91 |
struct eapsrp_ctx; |
| 92 |
RIST_PRIV int eap_process_eapol(struct eapsrp_ctx* ctx, uint8_t pkt[], size_t len); |
| 93 |
RIST_PRIV int eap_request_identity(struct eapsrp_ctx *ctx); |
| 94 |
RIST_PRIV int _librist_proto_eap_start(struct eapsrp_ctx *ctx); |
| 95 |
RIST_PRIV void eap_periodic(struct eapsrp_ctx *ctx); |
| 96 |
RIST_PRIV bool eap_is_authenticated(struct eapsrp_ctx *ctx); |
| 97 |
RIST_PRIV void eap_delete_ctx(struct eapsrp_ctx **in); |
| 98 |
RIST_PRIV int eap_clone_ctx(struct eapsrp_ctx *in, struct rist_peer *peer); |
| 99 |
RIST_PRIV void eap_set_ip_string(struct eapsrp_ctx *ctx, char ip_string[]); |
| 100 |
RIST_PRIV bool rist_eap_password_sending_done(struct eapsrp_ctx *ctx); |
| 101 |
RIST_PRIV bool rist_eap_may_rollover_tx(struct eapsrp_ctx *ctx); |
| 102 |
RIST_PRIV void rist_eap_send_passphrase(struct eapsrp_ctx *ctx, const char *passphrase); |
| 103 |
RIST_PRIV int _librist_proto_eap_start(struct eapsrp_ctx *ctx); |
| 104 |
#endif |