update it

This commit is contained in:
Sukchan Lee 2017-03-07 09:30:12 +09:00
parent bd31662aec
commit e7c9dbfc4d
5 changed files with 49 additions and 16 deletions

View File

@ -572,18 +572,19 @@ CORE_DECLARE(c_int32_t) nas_encode_nas_key_set_identifier(
/* 9.9.3.23 NAS security algorithms
* M V 1 */
#define NAS_SECURITY_ALGORITHMS_EIA0 0
#define NAS_SECURITY_ALGORITHMS_128_EIA1 1
#define NAS_SECURITY_ALGORITHMS_128_EIA2 2
#define NAS_SECURITY_ALGORITHMS_128_EIA3 3
#define NAS_SECURITY_ALGORITHMS_128_EEA1 1
#define NAS_SECURITY_ALGORITHMS_128_EEA2 2
#define NAS_SECURITY_ALGORITHMS_128_EEA3 3
#define NAS_SECURITY_ALGORITHMS_EIA0 0
#define NAS_SECURITY_ALGORITHMS_128_EIA1 1
#define NAS_SECURITY_ALGORITHMS_128_EIA2 2
#define NAS_SECURITY_ALGORITHMS_128_EIA3 3
#define NAS_SECURITY_ALGORITHMS_EEA0 0
#define NAS_SECURITY_ALGORITHMS_128_EEA1 1
#define NAS_SECURITY_ALGORITHMS_128_EEA2 2
#define NAS_SECURITY_ALGORITHMS_128_EEA3 3
typedef struct _nas_security_algorithms_t {
ED4(c_uint8_t spare1:1;,
c_uint8_t type_of_ciphering_algorithm:1;,
c_uint8_t type_of_ciphering_algorithm:3;,
c_uint8_t spare2:1;,
c_uint8_t type_of_integrity_protection_algorithm:1;)
c_uint8_t type_of_integrity_protection_algorithm:3;)
} __attribute__ ((packed)) nas_security_algorithms_t;
CORE_DECLARE(c_int32_t) nas_encode_nas_security_algorithms(

View File

@ -6,6 +6,7 @@
#include "core_index.h"
#include "context.h"
#include "nas_ies.h"
#include "s1ap_message.h"
#define CELL_PER_ENB 8
@ -64,6 +65,9 @@ status_t mme_ctx_init()
self.srvd_gummei.num_of_mme_code = 1;
self.srvd_gummei.mme_code[0] = 1;
self.selected_int_algorithm = NAS_SECURITY_ALGORITHMS_128_EIA1;
self.selected_enc_algorithm = NAS_SECURITY_ALGORITHMS_EIA0;
g_mme_ctx_initialized = 1;
return CORE_OK;

View File

@ -46,10 +46,22 @@ typedef struct _mme_ctx_t {
msgq_id queue_id;
tm_service_t tm_service;
c_uint32_t mme_ue_s1ap_id;
c_uint32_t mme_ue_s1ap_id; /** mme_ue_s1ap_id generator */
plmn_id_t plmn_id;
/* defined in 'nas_ies.h'
* #define NAS_SECURITY_ALGORITHMS_EIA0 0
* #define NAS_SECURITY_ALGORITHMS_128_EIA1 1
* #define NAS_SECURITY_ALGORITHMS_128_EIA1 2
* #define NAS_SECURITY_ALGORITHMS_128_EIA3 3 */
c_uint8_t selected_int_algorithm;
/* defined in 'nas_ies.h'
* #define NAS_SECURITY_ALGORITHMS_EIA0 0
* #define NAS_SECURITY_ALGORITHMS_128_EEA1 1
* #define NAS_SECURITY_ALGORITHMS_128_EEA2 2
* #define NAS_SECURITY_ALGORITHMS_128_EEA3 3 */
c_uint8_t selected_enc_algorithm;
/* S1SetupRequest */
c_uint16_t tracking_area_code;
c_uint16_t default_paging_drx;
@ -74,21 +86,24 @@ typedef struct _enb_ctx_t {
typedef struct _ue_ctx_t {
lnode_t node; /**< A node of list_t */
/* State Machine */
ue_emm_sm_t emm_sm;
/* UE identity */
c_uint32_t enb_ue_s1ap_id; /** eNB-UE-S1AP-ID received from eNB */
c_uint32_t mme_ue_s1ap_id; /** MME-UE-S1AP-ID received from MME */
c_uint8_t imsi[MAX_IMSI_LEN+1];
c_uint8_t imsi_len;
/* Security Context */
c_uint8_t xres[MAX_RES_LEN];
c_uint8_t xres_len;
c_uint8_t kasme[SHA256_DIGEST_SIZE];
c_uint8_t knasenc[SHA256_DIGEST_SIZE];
c_uint8_t knasint[SHA256_DIGEST_SIZE];
c_uint8_t knas_int[SHA256_DIGEST_SIZE/2];
c_uint8_t knas_enc[SHA256_DIGEST_SIZE/2];
/* Related Context for UE */
rab_list_t rab_list;
enb_ctx_t *enb;
} ue_ctx_t;

View File

@ -5,9 +5,17 @@
#include "nas_ies.h"
/* Algorithm Type Distinguishers */
#define MME_KDF_NAS_ENC_ALG 0x01
#define MME_KDF_NAS_INT_ALG 0x02
/* Algorithm Identity defined in nas_ies.h
#define NAS_SECURITY_ALGORITHMS_EIA0_EEA0 0
#define NAS_SECURITY_ALGORITHMS_128_EIA1_EEA1 1
#define NAS_SECURITY_ALGORITHMS_128_EIA1_EEA2 2
#define NAS_SECURITY_ALGORITHMS_128_EIA3_EEA3 3
*/
void mme_kdf_nas(c_uint8_t algorithm_type_distinguishers,
c_uint8_t algorithm_identity, c_uint8_t *kasme, c_uint8_t *knas);

View File

@ -9,6 +9,7 @@
#include "context.h"
#include "event.h"
#include "kdf.h"
#include "s1ap_path.h"
#include "s1ap_conv.h"
#include "nas_conv.h"
@ -208,6 +209,8 @@ static void ue_emm_handle_authentication_response(
nas_authentication_response_parameter_t *authentication_response_parameter =
&authentication_response->authentication_response_parameter;
d_assert(ue, return, "Null param");
if (authentication_response_parameter->length != ue->xres_len ||
memcmp(authentication_response_parameter->res,
ue->xres, ue->xres_len) != 0)
@ -216,6 +219,8 @@ static void ue_emm_handle_authentication_response(
return;
}
d_print_hex(authentication_response_parameter->res,
authentication_response_parameter->length);
mme_kdf_nas(MME_KDF_NAS_INT_ALG, mme_self()->selected_int_algorithm,
ue->kasme, ue->knas_int);
mme_kdf_nas(MME_KDF_NAS_ENC_ALG, mme_self()->selected_enc_algorithm,
ue->kasme, ue->knas_enc);
}