The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
rlm_eap_aka_prime.c
Go to the documentation of this file.
1/*
2 * This program is is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or (at
5 * your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 85b5a3e383baea2516a5ab9b21f70c04f2f1a2e1 $
19 * @file rlm_eap_aka_prime.c
20 * @brief Implements EAP-AKA'
21 *
22 * @author Arran Cudbard-Bell <a.cudbardb@freeradius.org>
23 *
24 * @copyright 2021 Arran Cudbard-Bell <a.cudbardb@freeradius.org>
25 * @copyright 2019 The FreeRADIUS server project
26 * @copyright 2019 Network RADIUS SAS <legal.com>
27 */
28RCSID("$Id: 85b5a3e383baea2516a5ab9b21f70c04f2f1a2e1 $")
29
30#include <freeradius-devel/eap/base.h>
31#include <freeradius-devel/eap_aka_sim/attrs.h>
32#include <freeradius-devel/eap_aka_sim/base.h>
33#include <freeradius-devel/eap_aka_sim/module.h>
34#include <freeradius-devel/server/virtual_servers.h>
35#include <freeradius-devel/unlang/module.h>
36#include <freeradius-devel/util/rand.h>
37#include <freeradius-devel/util/debug.h>
38
44
46
47static unlang_action_t mod_session_init(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
48{
49 eap_session_t *eap_session = eap_session_get(request->parent);
50 eap_aka_sim_mod_session_t *mod_session;
51
52 MEM(mod_session = talloc_zero(eap_session, eap_aka_sim_mod_session_t));
53 mod_session->id = (uint8_t)(fr_rand() & 0xff);
54 mod_session->ctx.hmac_md = mod_session->ctx.checkcode_md = EVP_sha256();
55 eap_session->opaque = mod_session;
56 eap_session->process = eap_aka_sim_process;
57
58 return eap_session->process(p_result, mctx, request);
59}
60
61static int mod_instantiate(module_inst_ctx_t const *mctx)
62{
63 eap_aka_sim_module_conf_t *inst = talloc_get_type_abort(mctx->mi->data, eap_aka_sim_module_conf_t);
64
66
67 return 0;
68}
69
70static eap_type_t mod_type_identity(UNUSED void *instance, char const *id, size_t len)
71{
73
75}
76
77static int mod_load(void)
78{
79 if (fr_aka_sim_init() < 0) return -1;
80
82
83 return 0;
84}
85
86static void mod_unload(void)
87{
89
91}
92
93/*
94 * The module name should be the only globally exported symbol.
95 * That is, everything else should be 'static'.
96 */
98 .common = {
99 .magic = MODULE_MAGIC_INIT,
100 .name = "eap_aka_prime",
101
103 .inst_type = "eap_aka_sim_module_conf_t",
105
106 .onload = mod_load,
107 .unload = mod_unload,
108
110 },
111 .provides = { FR_EAP_METHOD_AKA_PRIME },
112 .type_identity = mod_type_identity,
113 .session_init = mod_session_init,
114 .namespace = &dict_eap_aka_sim
115};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
#define RCSID(id)
Definition build.h:483
#define UNUSED
Definition build.h:315
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:658
cf_parse_t func
Override default parsing behaviour for the specified type with a custom parsing function.
Definition cf_parse.h:612
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:241
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:595
#define MEM(x)
Definition debug.h:36
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
enum eap_type eap_type_t
@ FR_EAP_METHOD_AKA_PRIME
Definition types.h:96
@ FR_EAP_METHOD_INVALID
Definition types.h:45
int fr_aka_sim_xlat_func_register(void)
Definition xlat.c:497
EVP_MD const * hmac_md
HMAC digest algorithm, usually EVP_sha1().
Definition base.h:240
EVP_MD const * checkcode_md
HMAC we use for calculating the checkcode.
Definition base.h:241
void fr_aka_sim_xlat_func_unregister(void)
Definition xlat.c:521
fr_aka_sim_ctx_t ctx
Definition module.h:79
uint8_t id
Last ID used, monotonically increments.
Definition module.h:72
Structure used to track session state at the module level.
Definition module.h:71
static eap_session_t * eap_session_get(request_t *request)
Definition session.h:82
void * opaque
Opaque data used by EAP methods.
Definition session.h:62
module_method_t process
Callback that should be used to process the next round.
Definition session.h:64
Tracks the progress of a single session of any EAP method.
Definition session.h:40
fr_dict_t const * dict_eap_aka_sim
Definition base.c:48
void fr_aka_sim_free(void)
Definition base.c:315
int fr_aka_sim_init(void)
Definition base.c:284
eap_type_t fr_aka_sim_id_to_eap_type(char const *id, size_t len)
Determine if a given identity is a 3gpp identity, and return the EAP method hinted.
Definition id.c:306
@ FR_TYPE_VOID
User data.
unsigned char uint8_t
module_instance_t * mi
Instance of the module being instantiated.
Definition module_ctx.h:51
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
static const conf_parser_t config[]
Definition base.c:183
uint32_t fr_rand(void)
Return a 32-bit random number.
Definition rand.c:105
rlm_rcode_t
Return codes indicating the result of the module call.
Definition rcode.h:40
static int mod_load(void)
static void mod_unload(void)
rlm_eap_submodule_t rlm_eap_aka_prime
static conf_parser_t submodule_config[]
static int mod_instantiate(module_inst_ctx_t const *mctx)
static eap_type_t mod_type_identity(UNUSED void *instance, char const *id, size_t len)
static unlang_action_t mod_session_init(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
static int instantiate(module_inst_ctx_t const *mctx)
Definition rlm_rest.c:1310
size_t inst_size
Size of the module's instance data.
Definition module.h:203
void * data
Module's instance data.
Definition module.h:271
unlang_action_t eap_aka_sim_process(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Decode EAP session data into attribute.
Definition module.c:295
eap_aka_sim_process_conf_t * inst
eap_type_t type
The preferred EAP-Type of this instance of the EAP-SIM/AKA/AKA' state machine.
module_t common
Common fields provided by all modules.
Definition submodule.h:50
eap_type_t provides[MAX_PROVIDED_METHODS]
Allow the module to register itself for more than one EAP-Method.
Definition submodule.h:52
Interface exported by EAP submodules.
Definition submodule.h:49
int virtual_server_cf_parse(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Wrapper for the config parser to allow pass1 resolution of virtual servers.