Commit a265e2e8 authored by Frédéric Leroy's avatar Frédéric Leroy

UE/EMM: move _security_data to nas_user_t

parent 8230f94f
......@@ -64,6 +64,7 @@ Description Defines the security mode control EMM procedure executed by the
# include "assertions.h"
#include "secu_defs.h"
#include "msc.h"
#include "SecurityModeControl.h"
#if defined(NAS_BUILT_IN_UE)
#include "nas_itti_messaging.h"
......@@ -92,13 +93,6 @@ static int _security_knas_int(const OctetString *kasme, OctetString *knas_int,
static int _security_kenb(const OctetString *kasme, OctetString *kenb,
uint32_t count);
/*
* Internal data used for security mode control procedure
*/
static struct {
OctetString kenb; /* eNodeB security key */
} _security_data;
static void _security_release(emm_security_context_t *ctx);
/*
......@@ -153,6 +147,7 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
int rc = RETURNerror;
int emm_cause = EMM_CAUSE_SUCCESS;
int security_context_is_new = FALSE;
security_data_t *security_data = user->security_data;
LOG_TRACE(INFO, "EMM-PROC - Security mode control requested (ksi=%d)",
ksi);
......@@ -226,17 +221,17 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
}
/* Derive the eNodeB key */
if (_security_data.kenb.value == NULL) {
_security_data.kenb.value = (uint8_t *)calloc(1,AUTH_KENB_SIZE);
_security_data.kenb.length = AUTH_KENB_SIZE;
if (security_data->kenb.value == NULL) {
security_data->kenb.value = (uint8_t *)calloc(1,AUTH_KENB_SIZE);
security_data->kenb.length = AUTH_KENB_SIZE;
}
if (_security_data.kenb.value != NULL) {
if (security_data->kenb.value != NULL) {
if (rc != RETURNerror) {
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context kenb");
// LG COMMENT rc = _security_kenb(&user->emm_data->security->kasme,
rc = _security_kenb(&user->emm_data->non_current->kasme,
&_security_data.kenb,
&security_data->kenb,
*(uint32_t *)(&user->emm_data->non_current->ul_count));
}
}
......@@ -303,10 +298,10 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
emm_cause = EMM_CAUSE_SECURITY_MODE_REJECTED;
/* Release security mode control internal data */
if (_security_data.kenb.value) {
free(_security_data.kenb.value);
_security_data.kenb.value = NULL;
_security_data.kenb.length = 0;
if (security_data->kenb.value) {
free(security_data->kenb.value);
security_data->kenb.value = NULL;
security_data->kenb.length = 0;
}
}
}
......
#ifndef _SECURITYMODECONTROL_H
#define _SECURITYMODECONTROL_H
/*
* Internal data used for security mode control procedure
*/
typedef struct {
OctetString kenb; /* eNodeB security key */
} security_data_t;
#endif
......@@ -102,6 +102,13 @@ void nas_proc_initialize(nas_user_t *user, emm_indication_callback_t emm_cb,
LOG_TRACE(ERROR, "NAS-PROC - Failed to alloc authentication_data");
// FIXME stop here
}
user->security_data = calloc(1, sizeof(security_data_t));
if ( user->security_data == NULL ) {
LOG_TRACE(ERROR, "NAS-PROC - Failed to alloc security_data");
// FIXME stop here
}
/* Initialize the EMM procedure manager */
emm_main_initialize(user, emm_cb, imei);
......
......@@ -53,6 +53,7 @@ Description NAS type definition to manage a user equipment
#include "EMM/Authentication.h"
#include "EMM/IdleMode_defs.h"
#include "API/USIM/usim_api.h"
#include "SecurityModeControl.h"
typedef struct {
int fd;
......@@ -66,6 +67,7 @@ typedef struct {
emm_data_t *emm_data; // EPS mobility management data
emm_plmn_list_t *emm_plmn_list; // list of PLMN identities
authentication_data_t *authentication_data;
security_data_t *security_data; //Internal data used for security mode control procedure
// Hardware persistent storage
usim_data_t usim_data; // USIM application data
} nas_user_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment