UE/EMM: move _security_data to nas_user_t
This commit is contained in:
@@ -64,6 +64,7 @@ Description Defines the security mode control EMM procedure executed by the
|
|||||||
# include "assertions.h"
|
# include "assertions.h"
|
||||||
#include "secu_defs.h"
|
#include "secu_defs.h"
|
||||||
#include "msc.h"
|
#include "msc.h"
|
||||||
|
#include "SecurityModeControl.h"
|
||||||
|
|
||||||
#if defined(NAS_BUILT_IN_UE)
|
#if defined(NAS_BUILT_IN_UE)
|
||||||
#include "nas_itti_messaging.h"
|
#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,
|
static int _security_kenb(const OctetString *kasme, OctetString *kenb,
|
||||||
uint32_t count);
|
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);
|
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 rc = RETURNerror;
|
||||||
int emm_cause = EMM_CAUSE_SUCCESS;
|
int emm_cause = EMM_CAUSE_SUCCESS;
|
||||||
int security_context_is_new = FALSE;
|
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)",
|
LOG_TRACE(INFO, "EMM-PROC - Security mode control requested (ksi=%d)",
|
||||||
ksi);
|
ksi);
|
||||||
@@ -226,17 +221,17 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Derive the eNodeB key */
|
/* Derive the eNodeB key */
|
||||||
if (_security_data.kenb.value == NULL) {
|
if (security_data->kenb.value == NULL) {
|
||||||
_security_data.kenb.value = (uint8_t *)calloc(1,AUTH_KENB_SIZE);
|
security_data->kenb.value = (uint8_t *)calloc(1,AUTH_KENB_SIZE);
|
||||||
_security_data.kenb.length = 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) {
|
if (rc != RETURNerror) {
|
||||||
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context kenb");
|
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context kenb");
|
||||||
// LG COMMENT rc = _security_kenb(&user->emm_data->security->kasme,
|
// LG COMMENT rc = _security_kenb(&user->emm_data->security->kasme,
|
||||||
rc = _security_kenb(&user->emm_data->non_current->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));
|
*(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;
|
emm_cause = EMM_CAUSE_SECURITY_MODE_REJECTED;
|
||||||
|
|
||||||
/* Release security mode control internal data */
|
/* Release security mode control internal data */
|
||||||
if (_security_data.kenb.value) {
|
if (security_data->kenb.value) {
|
||||||
free(_security_data.kenb.value);
|
free(security_data->kenb.value);
|
||||||
_security_data.kenb.value = NULL;
|
security_data->kenb.value = NULL;
|
||||||
_security_data.kenb.length = 0;
|
security_data->kenb.length = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#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");
|
LOG_TRACE(ERROR, "NAS-PROC - Failed to alloc authentication_data");
|
||||||
// FIXME stop here
|
// 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 */
|
/* Initialize the EMM procedure manager */
|
||||||
emm_main_initialize(user, emm_cb, imei);
|
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/Authentication.h"
|
||||||
#include "EMM/IdleMode_defs.h"
|
#include "EMM/IdleMode_defs.h"
|
||||||
#include "API/USIM/usim_api.h"
|
#include "API/USIM/usim_api.h"
|
||||||
|
#include "SecurityModeControl.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd;
|
int fd;
|
||||||
@@ -66,6 +67,7 @@ typedef struct {
|
|||||||
emm_data_t *emm_data; // EPS mobility management data
|
emm_data_t *emm_data; // EPS mobility management data
|
||||||
emm_plmn_list_t *emm_plmn_list; // list of PLMN identities
|
emm_plmn_list_t *emm_plmn_list; // list of PLMN identities
|
||||||
authentication_data_t *authentication_data;
|
authentication_data_t *authentication_data;
|
||||||
|
security_data_t *security_data; //Internal data used for security mode control procedure
|
||||||
// Hardware persistent storage
|
// Hardware persistent storage
|
||||||
usim_data_t usim_data; // USIM application data
|
usim_data_t usim_data; // USIM application data
|
||||||
} nas_user_t;
|
} nas_user_t;
|
||||||
|
|||||||
Reference in New Issue
Block a user