25 RCSID(
"$Id: 4b58fc6d0d803fc119d4df8dc25c89e4be5d25c6 $")
27 #include <freeradius-devel/eap/types.h>
28 #include <freeradius-devel/server/module.h>
29 #include <freeradius-devel/server/pair.h>
30 #include <freeradius-devel/server/virtual_servers.h>
31 #include <freeradius-devel/unlang/interpret.h>
32 #include <freeradius-devel/unlang/module.h>
33 #include <freeradius-devel/util/rand.h>
64 uint8_t const *request_hmac_extra = NULL;
65 size_t request_hmac_extra_len = 0;
89 TALLOC_FREE(eap_session->
opaque);
100 code = rcode_to_eap_code[rcode];
105 TALLOC_FREE(eap_session->
opaque);
134 case FR_SUBTYPE_VALUE_AKA_IDENTITY:
135 case FR_SUBTYPE_VALUE_SIM_START:
161 case FR_SUBTYPE_VALUE_AKA_CHALLENGE:
167 if (
inst->aka.send_at_bidding_prefer_prime_is_set &&
168 !
inst->aka.send_at_bidding_prefer_prime) {
173 }
else if (
inst->aka.send_at_bidding_prefer_prime) {
175 vp->vp_uint16 = FR_BIDDING_VALUE_PREFER_AKA_PRIME;
179 case FR_SUBTYPE_VALUE_SIM_CHALLENGE:
180 case FR_SUBTYPE_VALUE_AKA_SIM_REAUTHENTICATION:
190 RPWDEBUG(
"Failed calculating checkcode");
201 request_hmac_extra =
vp->vp_octets;
202 request_hmac_extra_len =
vp->vp_length;
226 vp->vp_octets,
vp->vp_length));
235 MEM(mod_session->
ctx.
k_encr = talloc_memdup(mod_session,
vp->vp_octets,
vp->vp_length));
244 MEM(mod_session->
ctx.
k_aut = talloc_memdup(mod_session,
vp->vp_octets,
vp->vp_length));
259 encode_ctx.hmac_extra_len = request_hmac_extra_len;
261 RDEBUG2(
"Encoding attributes");
267 case FR_SUBTYPE_VALUE_AKA_IDENTITY:
276 RPWDEBUG(
"Failed initialising checkcode");
282 RPWDEBUG(
"Failed updating checkcode");
325 decode_ctx = mod_session->
ctx;
331 &request->request_pairs,
374 case FR_SUBTYPE_VALUE_AKA_IDENTITY:
379 RPWDEBUG(
"Failed updating checkcode");
384 case FR_SUBTYPE_VALUE_AKA_SIM_REAUTHENTICATION:
385 case FR_SUBTYPE_VALUE_AKA_CHALLENGE:
400 RPWDEBUG(
"Failed calculating checkcode");
408 case FR_SUBTYPE_VALUE_SIM_CHALLENGE:
424 RPEDEBUG(
"AT_MAC calculation failed");
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_PUSHED_CHILD
unlang_t pushed a new child onto the stack, execute it instead of continuing.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
bool set_request_id
Whether the EAP-Method already set the next request ID.
eap_packet_t * response
Packet we received from the peer.
eap_packet_t * request
Packet we will send to the peer.
@ FR_EAP_METHOD_AKA_PRIME
ssize_t fr_aka_sim_crypto_sign_packet(uint8_t out[static AKA_SIM_MAC_DIGEST_SIZE], eap_packet_t *eap_packet, bool zero_mac, EVP_MD const *md, uint8_t const *key, size_t const key_len, uint8_t const *hmac_extra, size_t const hmac_extra_len)
Calculate the digest value for a packet.
uint8_t const * k_aut
The authentication key used for signing.
int fr_aka_sim_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict, uint8_t const *data, size_t data_len, fr_aka_sim_ctx_t *decode_ctx)
Decode SIM/AKA/AKA' specific packet data.
ssize_t fr_aka_sim_crypto_finalise_checkcode(TALLOC_CTX *ctx, uint8_t **out, fr_aka_sim_checkcode_t *checkcode)
Write out the final checkcode value.
EVP_MD const * hmac_md
HMAC digest algorithm, usually EVP_sha1().
eap_packet_t * eap_packet
Needed for validating AT_MAC.
EVP_MD const * checkcode_md
HMAC we use for calculating the checkcode.
uint8_t const * k_encr
The encryption key used for encrypting.
uint8_t const * hmac_extra
Extra data for the HMAC function.
#define AKA_SIM_MAC_DIGEST_SIZE
Length of MAC used to prevent packet modification.
int fr_aka_sim_crypto_update_checkcode(fr_aka_sim_checkcode_t *checkcode, eap_packet_t *eap_packet)
Digest a packet, updating the checkcode.
ssize_t fr_aka_sim_encode(request_t *request, fr_pair_list_t *to_encode, void *encode_ctx)
int fr_aka_sim_crypto_init_checkcode(TALLOC_CTX *ctx, fr_aka_sim_checkcode_t **checkcode, EVP_MD const *md)
Initialise checkcode message digest.
uint8_t * response_hmac_extra
Data to concatenate to response packet before validating.
size_t response_hmac_extra_len
uint8_t id
Last ID used, monotonically increments.
fr_aka_sim_checkcode_t * checkcode_state
Digest of all identity packets we've seen.
Structure used to track session state at the module level.
void unlang_interpet_frame_discard(request_t *request)
Discard the bottom most frame on the request's stack.
rlm_rcode_t unlang_interpret_stack_result(request_t *request)
Get the current rcode for the frame.
void * opaque
Opaque data used by EAP methods.
eap_round_t * this_round
The EAP response we're processing, and the EAP request we're building.
static eap_session_t * eap_session_get(request_t *request)
bool finished
Whether we consider this session complete.
Tracks the progress of a single session of any EAP method.
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_bidding
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_permanent_id_req
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_k_encr
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_checkcode
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_k_aut
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_any_id_req
fr_dict_t const * dict_eap_aka_sim
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_mac
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_fullauth_id_req
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_subtype
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_hmac_extra_request
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_hmac_extra_response
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a fr_pair_list_t.
#define RPEDEBUG(fmt,...)
#define RPWDEBUG(fmt,...)
#define RPEDEBUG2(fmt,...)
#define REDEBUG2(fmt,...)
@ L_DBG_LVL_2
2nd highest priority debug messages (-xx | -X).
module_instance_t const * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
int fr_pair_value_mem_alloc(fr_pair_t *vp, uint8_t **out, size_t size, bool tainted)
Pre-allocate a memory buffer for a "octets" type value pair.
int fr_pair_value_memdup_buffer_shallow(fr_pair_t *vp, uint8_t const *src, bool tainted)
Assign a talloced buffer to a "octets" type value pair.
static fr_internal_encode_ctx_t encode_ctx
#define RDEBUG_ENABLED2()
#define RETURN_MODULE_REJECT
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_INVALID
The module considers the request invalid.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_NOTFOUND
User not found.
@ RLM_MODULE_UPDATED
OK (pairs modified).
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
void * data
Module's instance data.
#define pair_append_control(_attr, _da)
Allocate and append a fr_pair_t to the control list.
#define pair_update_reply(_attr, _da)
Return or allocate a fr_pair_t in the reply list.
#define pair_delete_reply(_pair_or_da)
Delete a fr_pair_t in the reply list.
#define pair_append_reply(_attr, _da)
Allocate and append a fr_pair_t to reply list.
#define pair_delete_control(_pair_or_da)
Delete a fr_pair_t in the control list.
static char buff[sizeof("18446744073709551615")+3]
static unlang_action_t mod_encode(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Encode EAP session data from attributes.
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.
unlang_action_t unlang_module_yield(request_t *request, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx)
Yield a request back to the interpreter from within a module.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
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.
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
static int talloc_const_free(void const *ptr)
Free const'd memory.
Functions to allow modules to push resumption frames onto the stack and inform the interpreter about ...
Master include file to access all functions and structures in the library.
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
#define fr_pair_dcursor_init(_cursor, _list)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
unlang_action_t virtual_server_push(request_t *request, CONF_SECTION *server_cs, bool top_frame)
Set the request processing function.