Commit aa2cebd2 authored by Anatolii Pankevych's avatar Anatolii Pankevych

bugz 124092: [NAS][nrUE] enable security

parent 43fed655
...@@ -1052,7 +1052,7 @@ static int _nas_message_decrypt( ...@@ -1052,7 +1052,7 @@ static int _nas_message_decrypt(
stream_cipher.message = (unsigned char *)src; stream_cipher.message = (unsigned char *)src;
/* length in bits */ /* length in bits */
stream_cipher.blength = length << 3; stream_cipher.blength = length << 3;
nas_stream_encrypt_eea1(&stream_cipher, (unsigned char *)dest); nas_stream_encrypt_eea2(&stream_cipher, (unsigned char *)dest);
/* Decode the first octet (security header type or EPS bearer identity, /* Decode the first octet (security header type or EPS bearer identity,
* and protocol discriminator) */ * and protocol discriminator) */
DECODE_U8(dest, *(uint8_t*)(&header), size); DECODE_U8(dest, *(uint8_t*)(&header), size);
...@@ -1097,7 +1097,7 @@ static int _nas_message_decrypt( ...@@ -1097,7 +1097,7 @@ static int _nas_message_decrypt(
LOG_FUNC_RETURN (0); LOG_FUNC_RETURN (0);
}; };
LOG_FUNC_RETURN (0); LOG_FUNC_RETURN (0);
} }
/**************************************************************************** /****************************************************************************
......
This diff is collapsed.
...@@ -85,18 +85,34 @@ ...@@ -85,18 +85,34 @@
#define PAYLOAD_CONTAINER_LENGTH_MIN 3 #define PAYLOAD_CONTAINER_LENGTH_MIN 3
#define PAYLOAD_CONTAINER_LENGTH_MAX 65537 #define PAYLOAD_CONTAINER_LENGTH_MAX 65537
#define NR_NAS_CIP_INT_KEY_LEN_BYTES (16)
#define NIA0_ALG_ID EIA0_ALG_ID
// 3GPP TS 33.501: D.3.1.2 128-NIA1 128-NIA1 is identical to 128-EIA1 as specified in Annex B of TS 33.401
#define NIA1_128_ALG_ID EIA1_128_ALG_ID
// 3GPP TS 33.501: D.3.1.3 128-NIA2 128-NIA2 is identical to 128-EIA2 as specified in Annex B of TS 33.401
#define NIA2_128_ALG_ID EIA2_128_ALG_ID
#define NEA0_ALG_ID EEA0_ALG_ID
// 3GPP TS 33.501: D.2.1.2 128-NEA1 128-NEA1 is identical to 128-EEA1 as specified in Annex B of TS 33.401
#define NEA1_128_ALG_ID EEA1_128_ALG_ID
// 3GPP TS 33.501: D.2.1.3 128-NEA2 128-NEA2 is identical to 128-EEA2 as specified in Annex B of TS 33.401
#define NEA2_128_ALG_ID EEA2_128_ALG_ID
/* Security Key for SA UE */ /* Security Key for SA UE */
typedef struct { typedef struct {
uint8_t kausf[32]; uint8_t kausf[32];
uint8_t kseaf[32]; uint8_t kseaf[32];
uint8_t kamf[32]; uint8_t kamf[32];
uint8_t knas_int[16]; uint8_t knas_int[NR_NAS_CIP_INT_KEY_LEN_BYTES];
uint8_t knas_enc[NR_NAS_CIP_INT_KEY_LEN_BYTES];
uint8_t res[16]; uint8_t res[16];
uint8_t rand[16]; uint8_t rand[16];
uint8_t kgnb[32]; uint8_t kgnb[32];
} ue_sa_security_key_t; } ue_sa_security_key_t;
typedef enum fgs_protocol_discriminator_e { typedef enum fgs_protocol_discriminator_e {
/* Protocol discriminator identifier for 5GS Mobility Management */ /* Protocol discriminator identifier for 5GS Mobility Management */
FGS_MOBILITY_MANAGEMENT_MESSAGE = 0x7E, FGS_MOBILITY_MANAGEMENT_MESSAGE = 0x7E,
...@@ -105,7 +121,6 @@ typedef enum fgs_protocol_discriminator_e { ...@@ -105,7 +121,6 @@ typedef enum fgs_protocol_discriminator_e {
FGS_SESSION_MANAGEMENT_MESSAGE = 0x2E, FGS_SESSION_MANAGEMENT_MESSAGE = 0x2E,
} fgs_protocol_discriminator_t; } fgs_protocol_discriminator_t;
typedef struct { typedef struct {
uint8_t ex_protocol_discriminator; uint8_t ex_protocol_discriminator;
uint8_t security_header_type; uint8_t security_header_type;
...@@ -135,8 +150,6 @@ typedef union { ...@@ -135,8 +150,6 @@ typedef union {
fgs_service_request_msg fgs_service_request; fgs_service_request_msg fgs_service_request;
} MM_msg; } MM_msg;
typedef struct { typedef struct {
MM_msg mm_msg; /* 5GS Mobility Management messages */ MM_msg mm_msg; /* 5GS Mobility Management messages */
} fgs_nas_message_plain_t; } fgs_nas_message_plain_t;
...@@ -146,7 +159,6 @@ typedef struct { ...@@ -146,7 +159,6 @@ typedef struct {
fgs_nas_message_plain_t plain; fgs_nas_message_plain_t plain;
} fgs_nas_message_security_protected_t; } fgs_nas_message_security_protected_t;
typedef union { typedef union {
fgs_nas_message_security_header_t header; fgs_nas_message_security_header_t header;
fgs_nas_message_security_protected_t security_protected; fgs_nas_message_security_protected_t security_protected;
...@@ -184,7 +196,12 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id); ...@@ -184,7 +196,12 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id);
void generateServiceRequest(as_nas_info_t *initialNasMsg, int Mod_id); void generateServiceRequest(as_nas_info_t *initialNasMsg, int Mod_id);
void *nas_nrue_task(void *args_p); void *nas_nrue_task(void *args_p);
#endif /* __NR_NAS_MSG_SIM_H__*/ /**
* The helper function to recalculate the kgnb, where kgnb=f(kamf, ulNasCount).
* With current implementation, NAS calulates and reports the kgnb value to RRC
* once, but UE need this key refreshed after the RRC Release for subsequent
* calculations of AS Security keys. Note, the NAS keeps track of UlNASCount.
*/
void updateKgNB(int Mod_id, uint8_t *kgnb);
#endif /* __NR_NAS_MSG_SIM_H__*/
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