Skip to content

Commit

Permalink
Load the EAP-AKA/EAP-SIM dictionaries and use the correct dictionary …
Browse files Browse the repository at this point in the history
…roots
  • Loading branch information
arr2036 committed Dec 10, 2018
1 parent 33f22e6 commit 14e75ea
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 28 deletions.
12 changes: 4 additions & 8 deletions src/modules/rlm_eap/lib/sim/base.c
Expand Up @@ -40,10 +40,10 @@ RCSID("$Id$")

static int instance_count = 0;

static fr_dict_t *dict_freeradius;
static fr_dict_t *dict_radius;
static fr_dict_t *dict_eap_sim;
static fr_dict_t *dict_eap_aka;
fr_dict_t *dict_freeradius;
fr_dict_t *dict_radius;
fr_dict_t *dict_eap_sim;
fr_dict_t *dict_eap_aka;

extern fr_dict_autoload_t libfreeradius_sim_dict[];
fr_dict_autoload_t libfreeradius_sim_dict[] = {
Expand All @@ -58,11 +58,9 @@ fr_dict_autoload_t libfreeradius_sim_dict[] = {
fr_dict_attr_t const *attr_eap_aka_ak;
fr_dict_attr_t const *attr_eap_aka_ck;
fr_dict_attr_t const *attr_eap_aka_ik;
fr_dict_attr_t const *attr_eap_aka_root;
fr_dict_attr_t const *attr_eap_aka_subtype;
fr_dict_attr_t const *attr_eap_aka_xres;
fr_dict_attr_t const *attr_eap_sim_kc;
fr_dict_attr_t const *attr_eap_sim_root;
fr_dict_attr_t const *attr_eap_sim_sres;
fr_dict_attr_t const *attr_eap_sim_subtype;
fr_dict_attr_t const *attr_sim_amf;
Expand Down Expand Up @@ -100,7 +98,6 @@ fr_dict_attr_autoload_t libfreeradius_sim_dict_attr[] = {
{ .out = &attr_eap_aka_padding, .name = "EAP-AKA-Padding", .type = FR_TYPE_OCTETS, .dict = &dict_eap_aka },
{ .out = &attr_eap_aka_rand, .name = "EAP-AKA-RAND", .type = FR_TYPE_OCTETS, .dict = &dict_eap_aka },
{ .out = &attr_eap_aka_res, .name = "EAP-AKA-RES", .type = FR_TYPE_OCTETS, .dict = &dict_eap_aka },
{ .out = &attr_eap_aka_root, .name = "EAP-AKA-Root", .type = FR_TYPE_TLV, .dict = &dict_eap_aka },
{ .out = &attr_eap_aka_subtype, .name = "EAP-AKA-Subtype", .type = FR_TYPE_UINT32, .dict = &dict_eap_aka },
{ .out = &attr_eap_aka_xres, .name = "EAP-AKA-XRES", .type = FR_TYPE_OCTETS, .dict = &dict_eap_aka },

Expand All @@ -110,7 +107,6 @@ fr_dict_attr_autoload_t libfreeradius_sim_dict_attr[] = {
{ .out = &attr_eap_sim_mac, .name = "EAP-SIM-MAC", .type = FR_TYPE_OCTETS, .dict = &dict_eap_sim },
{ .out = &attr_eap_sim_padding, .name = "EAP-SIM-Padding", .type = FR_TYPE_OCTETS, .dict = &dict_eap_sim },
{ .out = &attr_eap_sim_rand, .name = "EAP-SIM-RAND", .type = FR_TYPE_OCTETS, .dict = &dict_eap_sim },
{ .out = &attr_eap_sim_root, .name = "EAP-SIM-Root", .type = FR_TYPE_TLV, .dict = &dict_eap_sim },
{ .out = &attr_eap_sim_sres, .name = "EAP-SIM-SRES", .type = FR_TYPE_OCTETS, .dict = &dict_eap_sim },
{ .out = &attr_eap_sim_subtype, .name = "EAP-SIM-Subtype", .type = FR_TYPE_UINT32, .dict = &dict_eap_sim },

Expand Down
6 changes: 3 additions & 3 deletions src/modules/rlm_eap/lib/sim/decode.c
Expand Up @@ -1063,7 +1063,7 @@ static int decode_test_ctx_sim(void **out, TALLOC_CTX *ctx)
test_ctx = test_ctx_init(ctx, k_encr, sizeof(k_encr));
if (!test_ctx) return -1;

test_ctx->root = attr_eap_sim_root;
test_ctx->root = fr_dict_root(dict_eap_sim);
test_ctx->have_iv = true; /* Ensures IV is all zeros */

*out = test_ctx;
Expand All @@ -1081,7 +1081,7 @@ static int decode_test_ctx_aka(void **out, TALLOC_CTX *ctx)
test_ctx = test_ctx_init(ctx, k_encr, sizeof(k_encr));
if (!test_ctx) return -1;

test_ctx->root = attr_eap_aka_root;
test_ctx->root = fr_dict_root(dict_eap_aka);
test_ctx->have_iv = true; /* Ensures IV is all zeros */

*out = test_ctx;
Expand All @@ -1098,7 +1098,7 @@ static int decode_test_ctx_sim_rfc4186(void **out, TALLOC_CTX *ctx)
test_ctx = test_ctx_init(ctx, k_encr, sizeof(k_encr));
if (!test_ctx) return -1;

test_ctx->root = attr_eap_sim_root;
test_ctx->root = fr_dict_root(dict_eap_sim);

*out = test_ctx;

Expand Down
6 changes: 3 additions & 3 deletions src/modules/rlm_eap/lib/sim/encode.c
Expand Up @@ -1116,7 +1116,7 @@ static int encode_test_ctx_sim(void **out, TALLOC_CTX *ctx)
test_ctx = test_ctx_init(ctx, k_encr, sizeof(k_encr));
if (!test_ctx) return -1;

test_ctx->root = attr_eap_sim_root;
test_ctx->root = fr_dict_root(dict_eap_sim);
test_ctx->iv_included = true; /* Ensures IV is all zeros */

*out = test_ctx;
Expand All @@ -1133,7 +1133,7 @@ static int encode_test_ctx_aka(void **out, TALLOC_CTX *ctx)
test_ctx = test_ctx_init(ctx, k_encr, sizeof(k_encr));
if (!test_ctx) return -1;

test_ctx->root = attr_eap_aka_root;
test_ctx->root = fr_dict_root(dict_eap_aka);
test_ctx->iv_included = true; /* Ensures IV is all zeros */

*out = test_ctx;
Expand All @@ -1150,7 +1150,7 @@ static int encode_test_ctx_sim_rfc4186(void **out, TALLOC_CTX *ctx)
test_ctx = test_ctx_init(ctx, k_encr, sizeof(k_encr));
if (!test_ctx) return -1;

test_ctx->root = attr_eap_sim_root;
test_ctx->root = fr_dict_root(dict_eap_sim);

*out = test_ctx;

Expand Down
7 changes: 5 additions & 2 deletions src/modules/rlm_eap/lib/sim/sim_attrs.h
Expand Up @@ -54,14 +54,17 @@ DICT_SANITY_CHECK(MAC);
DICT_SANITY_CHECK(SUBTYPE);
#define FR_SIM_SUBTYPE (FR_EAP_SIM_SUBTYPE & FR_EAP_AKA_SUBTYPE)

extern fr_dict_t *dict_freeradius;
extern fr_dict_t *dict_radius;
extern fr_dict_t *dict_eap_sim;
extern fr_dict_t *dict_eap_aka;

extern fr_dict_attr_t const *attr_eap_aka_ak;
extern fr_dict_attr_t const *attr_eap_aka_ck;
extern fr_dict_attr_t const *attr_eap_aka_ik;
extern fr_dict_attr_t const *attr_eap_aka_root;
extern fr_dict_attr_t const *attr_eap_aka_subtype;
extern fr_dict_attr_t const *attr_eap_aka_xres;
extern fr_dict_attr_t const *attr_eap_sim_kc;
extern fr_dict_attr_t const *attr_eap_sim_root;
extern fr_dict_attr_t const *attr_eap_sim_sres;
extern fr_dict_attr_t const *attr_eap_sim_subtype;
extern fr_dict_attr_t const *attr_sim_amf;
Expand Down
8 changes: 3 additions & 5 deletions src/modules/rlm_eap/types/rlm_eap_aka/rlm_eap_aka.c
Expand Up @@ -70,7 +70,6 @@ fr_dict_autoload_t rlm_eap_aka_dict[] = {
{ NULL }
};

static fr_dict_attr_t const *attr_eap_aka_root;
static fr_dict_attr_t const *attr_eap_aka_subtype;
static fr_dict_attr_t const *attr_sim_amf;

Expand All @@ -96,7 +95,6 @@ static fr_dict_attr_t const *attr_eap_aka_result_ind;

extern fr_dict_attr_autoload_t rlm_eap_aka_dict_attr[];
fr_dict_attr_autoload_t rlm_eap_aka_dict_attr[] = {
{ .out = &attr_eap_aka_root, .name = "EAP-AKA-Root", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
{ .out = &attr_eap_aka_subtype, .name = "EAP-AKA-Subtype", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
{ .out = &attr_sim_amf, .name = "SIM-AMF", .type = FR_TYPE_OCTETS, .dict = &dict_freeradius },

Expand Down Expand Up @@ -131,7 +129,7 @@ static int eap_aka_compose(eap_session_t *eap_session)
REQUEST *request = eap_session->request;
ssize_t ret;
fr_sim_encode_ctx_t encoder_ctx = {
.root = attr_eap_aka_root,
.root = fr_dict_root(dict_eap_aka),
.keys = &eap_aka_session->keys,

.iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand All @@ -148,7 +146,7 @@ static int eap_aka_compose(eap_session_t *eap_session)
fr_cursor_init(&to_encode, &head);

while ((vp = fr_cursor_current(&cursor))) {
if (!fr_dict_parent_common(attr_eap_aka_root, vp->da, true)) {
if (!fr_dict_parent_common(encoder_ctx.root, vp->da, true)) {
fr_cursor_next(&cursor);
continue;
}
Expand Down Expand Up @@ -876,7 +874,7 @@ static rlm_rcode_t mod_process(UNUSED void *instance, eap_session_t *eap_session

fr_sim_decode_ctx_t ctx = {
.keys = &eap_aka_session->keys,
.root = attr_eap_aka_root
.root = fr_dict_root(dict_eap_aka)
};
VALUE_PAIR *vp, *vps, *subtype_vp;
fr_cursor_t cursor;
Expand Down
10 changes: 3 additions & 7 deletions src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c
Expand Up @@ -70,7 +70,6 @@ fr_dict_autoload_t rlm_eap_sim_dict[] = {
};

static fr_dict_attr_t const *attr_eap_sim_mk;
static fr_dict_attr_t const *attr_eap_sim_root;
static fr_dict_attr_t const *attr_eap_sim_subtype;

static fr_dict_attr_t const *attr_ms_mppe_send_key;
Expand All @@ -95,7 +94,6 @@ static fr_dict_attr_t const *attr_eap_sim_version_list;
extern fr_dict_attr_autoload_t rlm_eap_sim_dict_attr[];
fr_dict_attr_autoload_t rlm_eap_sim_dict_attr[] = {
{ .out = &attr_eap_sim_mk, .name = "EAP-SIM-MK", .type = FR_TYPE_OCTETS, .dict = &dict_freeradius },
{ .out = &attr_eap_sim_root, .name = "EAP-SIM-Root", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
{ .out = &attr_eap_sim_subtype, .name = "EAP-SIM-Subtype", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },

{ .out = &attr_ms_mppe_send_key, .name = "MS-MPPE-Send-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
Expand Down Expand Up @@ -130,7 +128,7 @@ static int eap_sim_compose(eap_session_t *eap_session, uint8_t const *hmac_extra
VALUE_PAIR *head = NULL, *vp;
REQUEST *request = eap_session->request;
fr_sim_encode_ctx_t encoder_ctx = {
.root = attr_eap_sim_root,
.root = fr_dict_root(dict_eap_sim),
.keys = &eap_sim_session->keys,

.iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand All @@ -152,7 +150,7 @@ static int eap_sim_compose(eap_session_t *eap_session, uint8_t const *hmac_extra
fr_cursor_init(&to_encode, &head);

while ((vp = fr_cursor_current(&cursor))) {
if (!fr_dict_parent_common(attr_eap_sim_root, vp->da, true)) {
if (!fr_dict_parent_common(fr_dict_root(dict_eap_sim), vp->da, true)) {
fr_cursor_next(&cursor);
continue;
}
Expand Down Expand Up @@ -871,7 +869,7 @@ static rlm_rcode_t mod_process(UNUSED void *instance, eap_session_t *eap_session
eap_sim_session_t *eap_sim_session = talloc_get_type_abort(eap_session->opaque, eap_sim_session_t);
fr_sim_decode_ctx_t ctx = {
.keys = &eap_sim_session->keys,
.root = attr_eap_sim_root
.root = fr_dict_root(dict_eap_sim)
};
VALUE_PAIR *subtype_vp, *from_peer, *vp;
fr_cursor_t cursor;
Expand All @@ -880,8 +878,6 @@ static rlm_rcode_t mod_process(UNUSED void *instance, eap_session_t *eap_session

int ret;

rad_assert(attr_eap_sim_root);

/*
* VPS is the data from the client
*/
Expand Down
1 change: 1 addition & 0 deletions src/tests/unit/eap_aka_decode.txt
Expand Up @@ -7,6 +7,7 @@ need-feature tls

# Load the EAP-SIM module
load eap-sim
load-dictionary eap-aka

#
# Encode some AKA attributes with special formats
Expand Down
1 change: 1 addition & 0 deletions src/tests/unit/eap_aka_encode.txt
Expand Up @@ -7,6 +7,7 @@ need-feature tls

# Load the EAP-SIM module
load eap-sim
load-dictionary eap-aka

#
# Encode some AKA attributes with special formats
Expand Down
1 change: 1 addition & 0 deletions src/tests/unit/eap_aka_error.txt
Expand Up @@ -9,6 +9,7 @@ need-feature tls

# Load the EAP-SIM module
load eap-sim
load-dictionary eap-aka

# AKA_RES with invalid length (too small)
decode-pair.aka_tp_decode 04 03 aa bb aa aa aa aa bb bb bb bb
Expand Down
1 change: 1 addition & 0 deletions src/tests/unit/eap_sim_decode.txt
Expand Up @@ -9,6 +9,7 @@ need-feature tls

# Load the EAP-SIM module
load eap-sim
load-dictionary eap-sim

# Boolean attribute
decode-pair.sim_tp_decode 0d 01 00 00
Expand Down
1 change: 1 addition & 0 deletions src/tests/unit/eap_sim_encode.txt
Expand Up @@ -7,6 +7,7 @@ need-feature tls

# Load the EAP-SIM module
load eap-sim
load-dictionary eap-sim

# Boolean attribute
encode-pair.sim_tp_encode EAP-SIM-Any-ID-Req = yes
Expand Down
1 change: 1 addition & 0 deletions src/tests/unit/eap_sim_error.txt
Expand Up @@ -9,6 +9,7 @@ need-feature tls

# Load the EAP-SIM module
load eap-sim
load-dictionary eap-sim

# Zero length attribute
decode-pair.sim_tp_decode 0d 00
Expand Down

0 comments on commit 14e75ea

Please sign in to comment.