Introduced define for uint8_t integrity and ciphering keys data structures
- the goal is to improve maintanability
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#define NR_RRC_HEADER_SIZE_MAX 64
|
#define NR_RRC_HEADER_SIZE_MAX 64
|
||||||
#define NR_RRC_BUFFER_SIZE_MAX 1024
|
#define NR_RRC_BUFFER_SIZE_MAX 1024
|
||||||
#define NR_NUM_SRB 4
|
#define NR_NUM_SRB 4
|
||||||
|
#define NR_K_KEY_SIZE 16 /* K keys have 128 bits length */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char Payload[NR_RRC_BUFFER_SIZE_MAX];
|
char Payload[NR_RRC_BUFFER_SIZE_MAX];
|
||||||
|
|||||||
@@ -408,8 +408,8 @@ static void activate_srb(gNB_RRC_UE_t *UE, int srb_id)
|
|||||||
if (srb_id == 1) {
|
if (srb_id == 1) {
|
||||||
nr_pdcp_add_srbs(true, UE->rrc_ue_id, list, 0, NULL, NULL);
|
nr_pdcp_add_srbs(true, UE->rrc_ue_id, list, 0, NULL, NULL);
|
||||||
} else {
|
} else {
|
||||||
uint8_t kRRCenc[16] = {0};
|
uint8_t kRRCenc[NR_K_KEY_SIZE] = {0};
|
||||||
uint8_t kRRCint[16] = {0};
|
uint8_t kRRCint[NR_K_KEY_SIZE] = {0};
|
||||||
nr_derive_key(RRC_ENC_ALG, UE->ciphering_algorithm, UE->kgnb, kRRCenc);
|
nr_derive_key(RRC_ENC_ALG, UE->ciphering_algorithm, UE->kgnb, kRRCenc);
|
||||||
nr_derive_key(RRC_INT_ALG, UE->integrity_algorithm, UE->kgnb, kRRCint);
|
nr_derive_key(RRC_INT_ALG, UE->integrity_algorithm, UE->kgnb, kRRCint);
|
||||||
|
|
||||||
@@ -904,13 +904,13 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context
|
|||||||
|
|
||||||
LOG_I(NR_RRC, "[RAPROC] UE %04x Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n", ue_p->rnti, size);
|
LOG_I(NR_RRC, "[RAPROC] UE %04x Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n", ue_p->rnti, size);
|
||||||
|
|
||||||
uint8_t kRRCenc[16] = {0};
|
/* Ciphering and Integrity according to TS 33.501 */
|
||||||
uint8_t kRRCint[16] = {0};
|
uint8_t kRRCenc[NR_K_KEY_SIZE] = {0};
|
||||||
uint8_t kUPenc[16] = {0};
|
uint8_t kRRCint[NR_K_KEY_SIZE] = {0};
|
||||||
|
uint8_t kUPenc[NR_K_KEY_SIZE] = {0};
|
||||||
/* Derive the keys from kgnb */
|
/* Derive the keys from kgnb */
|
||||||
if (ue_p->Srb[1].Active)
|
if (ue_p->Srb[1].Active)
|
||||||
nr_derive_key(UP_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kUPenc);
|
nr_derive_key(UP_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kUPenc);
|
||||||
|
|
||||||
nr_derive_key(RRC_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kRRCenc);
|
nr_derive_key(RRC_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kRRCenc);
|
||||||
nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, kRRCint);
|
nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, kRRCint);
|
||||||
|
|
||||||
|
|||||||
@@ -130,9 +130,9 @@ nr_rrc_pdcp_config_security(
|
|||||||
)
|
)
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
uint8_t kRRCenc[16] = {0};
|
uint8_t kRRCenc[NR_K_KEY_SIZE] = {0};
|
||||||
uint8_t kRRCint[16] = {0};
|
uint8_t kRRCint[NR_K_KEY_SIZE] = {0};
|
||||||
uint8_t kUPenc[16] = {0};
|
uint8_t kUPenc[NR_K_KEY_SIZE] = {0};
|
||||||
//uint8_t *k_kdf = NULL;
|
//uint8_t *k_kdf = NULL;
|
||||||
static int print_keys= 1;
|
static int print_keys= 1;
|
||||||
gNB_RRC_UE_t *UE = &ue_context_pP->ue_context;
|
gNB_RRC_UE_t *UE = &ue_context_pP->ue_context;
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a
|
|||||||
gtpv1u_enb_create_tunnel_req_t create_tunnel_req;
|
gtpv1u_enb_create_tunnel_req_t create_tunnel_req;
|
||||||
gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp;
|
gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp;
|
||||||
protocol_ctxt_t ctxt={0};
|
protocol_ctxt_t ctxt={0};
|
||||||
uint8_t kUPenc[16] = {0};
|
uint8_t kUPenc[NR_K_KEY_SIZE] = {0};
|
||||||
uint8_t kUPint[16] = {0};
|
uint8_t kUPint[NR_K_KEY_SIZE] = {0};
|
||||||
int i;
|
int i;
|
||||||
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
|
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
|
||||||
|
|
||||||
|
|||||||
@@ -987,9 +987,9 @@ static void nr_rrc_ue_process_securityModeCommand(NR_UE_RRC_INST_t *ue_rrc,
|
|||||||
c1->present = NR_UL_DCCH_MessageType__c1_PR_securityModeComplete;
|
c1->present = NR_UL_DCCH_MessageType__c1_PR_securityModeComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t kRRCenc[16] = {0};
|
uint8_t kRRCenc[NR_K_KEY_SIZE] = {0};
|
||||||
uint8_t kUPenc[16] = {0};
|
uint8_t kUPenc[NR_K_KEY_SIZE] = {0};
|
||||||
uint8_t kRRCint[16] = {0};
|
uint8_t kRRCint[NR_K_KEY_SIZE] = {0};
|
||||||
nr_derive_key(UP_ENC_ALG, ue_rrc->cipheringAlgorithm, ue_rrc->kgnb, kUPenc);
|
nr_derive_key(UP_ENC_ALG, ue_rrc->cipheringAlgorithm, ue_rrc->kgnb, kUPenc);
|
||||||
nr_derive_key(RRC_ENC_ALG, ue_rrc->cipheringAlgorithm, ue_rrc->kgnb, kRRCenc);
|
nr_derive_key(RRC_ENC_ALG, ue_rrc->cipheringAlgorithm, ue_rrc->kgnb, kRRCenc);
|
||||||
nr_derive_key(RRC_INT_ALG, ue_rrc->integrityProtAlgorithm, ue_rrc->kgnb, kRRCint);
|
nr_derive_key(RRC_INT_ALG, ue_rrc->integrityProtAlgorithm, ue_rrc->kgnb, kRRCint);
|
||||||
@@ -1167,8 +1167,8 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc,
|
|||||||
if (radioBearerConfig->srb3_ToRelease)
|
if (radioBearerConfig->srb3_ToRelease)
|
||||||
nr_pdcp_release_srb(ue_rrc->ue_id, 3);
|
nr_pdcp_release_srb(ue_rrc->ue_id, 3);
|
||||||
|
|
||||||
uint8_t kRRCenc[16] = {0};
|
uint8_t kRRCenc[NR_K_KEY_SIZE] = {0};
|
||||||
uint8_t kRRCint[16] = {0};
|
uint8_t kRRCint[NR_K_KEY_SIZE] = {0};
|
||||||
if (ue_rrc->as_security_activated) {
|
if (ue_rrc->as_security_activated) {
|
||||||
if (radioBearerConfig->securityConfig != NULL) {
|
if (radioBearerConfig->securityConfig != NULL) {
|
||||||
// When the field is not included, continue to use the currently configured keyToUse
|
// When the field is not included, continue to use the currently configured keyToUse
|
||||||
|
|||||||
Reference in New Issue
Block a user