cleanup: reduce number of parameters to pdcp's set_security()
Also adapt callers. In particular nr_pdcp_reestablishment()
This commit is contained in:
@@ -145,20 +145,6 @@ void ue_cxt_mod_direct(MessageDef *msg,
|
||||
|
||||
void prepare_and_send_ue_context_modification_f1(rrc_gNB_ue_context_t *ue_context_p,
|
||||
e1ap_bearer_setup_resp_t *e1ap_resp);
|
||||
void nr_pdcp_add_srbs(eNB_flag_t enb_flag,
|
||||
ue_id_t UEid,
|
||||
NR_SRB_ToAddModList_t *const srb2add_list,
|
||||
const uint8_t security_modeP,
|
||||
uint8_t *const kRRCenc,
|
||||
uint8_t *const kUPint);
|
||||
|
||||
void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
|
||||
ue_id_t rntiMaybeUEid,
|
||||
NR_DRB_ToAddModList_t *const drb2add_list,
|
||||
const uint8_t security_modeP,
|
||||
uint8_t *const kUPenc,
|
||||
uint8_t *const kUPint);
|
||||
|
||||
void trigger_bearer_setup(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, pdusession_t *sessions, uint64_t ueAggMaxBitRateDownlink);
|
||||
|
||||
int rrc_gNB_generate_pcch_msg(sctp_assoc_t assoc_id, const NR_SIB1_t *sib, uint32_t tmsi, uint8_t paging_drx);
|
||||
|
||||
+23
-26
@@ -389,19 +389,19 @@ static void activate_srb(gNB_RRC_UE_t *UE, int srb_id)
|
||||
srb->srb_Identity = srb_id;
|
||||
|
||||
if (srb_id == 1) {
|
||||
nr_pdcp_add_srbs(true, UE->rrc_ue_id, list, 0, NULL, NULL);
|
||||
nr_pdcp_entity_security_keys_and_algos_t null_security_parameters = {0};
|
||||
nr_pdcp_add_srbs(true, UE->rrc_ue_id, list, &null_security_parameters);
|
||||
} else {
|
||||
uint8_t kRRCenc[NR_K_KEY_SIZE] = {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_INT_ALG, UE->integrity_algorithm, UE->kgnb, kRRCint);
|
||||
nr_pdcp_entity_security_keys_and_algos_t security_parameters;
|
||||
security_parameters.ciphering_algorithm = UE->ciphering_algorithm;
|
||||
security_parameters.integrity_algorithm = UE->integrity_algorithm;
|
||||
nr_derive_key(RRC_ENC_ALG, UE->ciphering_algorithm, UE->kgnb, security_parameters.ciphering_key);
|
||||
nr_derive_key(RRC_INT_ALG, UE->integrity_algorithm, UE->kgnb, security_parameters.integrity_key);
|
||||
|
||||
nr_pdcp_add_srbs(true,
|
||||
UE->rrc_ue_id,
|
||||
list,
|
||||
(UE->integrity_algorithm << 4) | UE->ciphering_algorithm,
|
||||
kRRCenc,
|
||||
kRRCint);
|
||||
&security_parameters);
|
||||
}
|
||||
freeSRBlist(list);
|
||||
}
|
||||
@@ -883,11 +883,10 @@ 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);
|
||||
|
||||
/* Ciphering and Integrity according to TS 33.501 */
|
||||
uint8_t kRRCenc[NR_K_KEY_SIZE] = {0};
|
||||
uint8_t kRRCint[NR_K_KEY_SIZE] = {0};
|
||||
nr_pdcp_entity_security_keys_and_algos_t security_parameters;
|
||||
/* Derive the keys from kgnb */
|
||||
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_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, security_parameters.ciphering_key);
|
||||
nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, security_parameters.integrity_key);
|
||||
LOG_I(NR_RRC,
|
||||
"Set PDCP security UE %d RNTI %04x nca %ld nia %d in RRCReestablishment\n",
|
||||
ue_p->rrc_ue_id,
|
||||
@@ -898,22 +897,19 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context
|
||||
* so let's configure only integrity protection right now.
|
||||
* Ciphering is enabled below, after generating RRCReestablishment.
|
||||
*/
|
||||
uint8_t security_mode = 0 | (ue_p->integrity_algorithm << 4);
|
||||
security_parameters.integrity_algorithm = ue_p->integrity_algorithm;
|
||||
security_parameters.ciphering_algorithm = 0;
|
||||
|
||||
/* SRBs */
|
||||
for (int srb_id = 1; srb_id < NR_NUM_SRB; srb_id++) {
|
||||
if (ue_p->Srb[srb_id].Active)
|
||||
nr_pdcp_config_set_security(ue_p->rrc_ue_id, srb_id, true, security_mode, kRRCenc, kRRCint);
|
||||
nr_pdcp_config_set_security(ue_p->rrc_ue_id, srb_id, true, &security_parameters);
|
||||
}
|
||||
/* Re-establish PDCP for SRB1, according to 5.3.7.4 of 3GPP TS 38.331 */
|
||||
nr_pdcp_reestablishment(ue_p->rrc_ue_id,
|
||||
1,
|
||||
true,
|
||||
ue_p->integrity_algorithm,
|
||||
kRRCint,
|
||||
/* ciphering is enabled below, after encoding RRCReestablishment */
|
||||
0,
|
||||
NULL);
|
||||
&security_parameters);
|
||||
/* F1AP DL RRC Message Transfer */
|
||||
f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->rrc_ue_id);
|
||||
RETURN_IF_INVALID_ASSOC_ID(ue_data);
|
||||
@@ -926,11 +922,11 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context
|
||||
nr_pdcp_data_req_srb(ue_p->rrc_ue_id, DCCH, rrc_gNB_mui++, size, (unsigned char *const)buffer, rrc_deliver_dl_rrc_message, &data);
|
||||
|
||||
/* RRCReestablishment has been generated, let's enable ciphering now. */
|
||||
security_mode = ue_p->ciphering_algorithm | (ue_p->integrity_algorithm << 4);
|
||||
security_parameters.ciphering_algorithm = ue_p->ciphering_algorithm;
|
||||
/* SRBs */
|
||||
for (int srb_id = 1; srb_id < NR_NUM_SRB; srb_id++) {
|
||||
if (ue_p->Srb[srb_id].Active)
|
||||
nr_pdcp_config_set_security(ue_p->rrc_ue_id, srb_id, true, security_mode, kRRCenc, kRRCint);
|
||||
nr_pdcp_config_set_security(ue_p->rrc_ue_id, srb_id, true, &security_parameters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -983,12 +979,13 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co
|
||||
*/
|
||||
int srb_id = 2;
|
||||
if (ue_p->Srb[srb_id].Active) {
|
||||
uint8_t kenc[NR_K_KEY_SIZE];
|
||||
uint8_t kint[NR_K_KEY_SIZE];
|
||||
nr_derive_key(RRC_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kenc);
|
||||
nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, kint);
|
||||
nr_pdcp_entity_security_keys_and_algos_t security_parameters;
|
||||
security_parameters.ciphering_algorithm = ue_p->ciphering_algorithm;
|
||||
security_parameters.integrity_algorithm = ue_p->integrity_algorithm;
|
||||
nr_derive_key(RRC_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, security_parameters.ciphering_key);
|
||||
nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, security_parameters.integrity_key);
|
||||
|
||||
nr_pdcp_reestablishment(ue_p->rrc_ue_id, srb_id, true, ue_p->integrity_algorithm, kint, ue_p->ciphering_algorithm, kenc);
|
||||
nr_pdcp_reestablishment(ue_p->rrc_ue_id, srb_id, true, &security_parameters);
|
||||
}
|
||||
/* PDCP Reestablishment of DRBs according to 5.3.5.6.5 of 3GPP TS 38.331 (over E1) */
|
||||
cuup_notify_reestablishment(rrc, ue_p);
|
||||
|
||||
@@ -135,28 +135,29 @@ nr_rrc_pdcp_config_security(
|
||||
)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
uint8_t kRRCenc[NR_K_KEY_SIZE] = {0};
|
||||
uint8_t kRRCint[NR_K_KEY_SIZE] = {0};
|
||||
//uint8_t *k_kdf = NULL;
|
||||
static int print_keys= 1;
|
||||
gNB_RRC_UE_t *UE = &ue_context_pP->ue_context;
|
||||
|
||||
/* Derive the keys from kgnb */
|
||||
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_pdcp_entity_security_keys_and_algos_t security_parameters;
|
||||
/* set ciphering algorithm depending on 'enable_ciphering' */
|
||||
security_parameters.ciphering_algorithm = enable_ciphering ? UE->ciphering_algorithm : 0;
|
||||
security_parameters.integrity_algorithm = UE->integrity_algorithm;
|
||||
/* use current ciphering algorithm, independently of 'enable_ciphering' to derive ciphering key */
|
||||
nr_derive_key(RRC_ENC_ALG, UE->ciphering_algorithm, UE->kgnb, security_parameters.ciphering_key);
|
||||
nr_derive_key(RRC_INT_ALG, UE->integrity_algorithm, UE->kgnb, security_parameters.integrity_key);
|
||||
|
||||
if ( LOG_DUMPFLAG( DEBUG_SECURITY ) ) {
|
||||
if (print_keys == 1 ) {
|
||||
print_keys =0;
|
||||
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, UE->kgnb, 32, "\nKgNB:");
|
||||
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, kRRCenc, 16,"\nKRRCenc:" );
|
||||
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, kRRCint, 16,"\nKRRCint:" );
|
||||
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, security_parameters.ciphering_key, 16,"\nKRRCenc:" );
|
||||
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, security_parameters.integrity_key, 16,"\nKRRCint:" );
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t security_mode =
|
||||
enable_ciphering ? UE->ciphering_algorithm | (UE->integrity_algorithm << 4) : 0 | (UE->integrity_algorithm << 4);
|
||||
nr_pdcp_config_set_security(ctxt_pP->rntiMaybeUEid, DCCH, true, security_mode, kRRCenc, kRRCint);
|
||||
nr_pdcp_config_set_security(ctxt_pP->rntiMaybeUEid, DCCH, true, &security_parameters);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -126,8 +126,7 @@ 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_resp_t create_tunnel_resp;
|
||||
protocol_ctxt_t ctxt={0};
|
||||
uint8_t kUPenc[NR_K_KEY_SIZE] = {0};
|
||||
uint8_t kUPint[NR_K_KEY_SIZE] = {0};
|
||||
nr_pdcp_entity_security_keys_and_algos_t security_parameters = {0};
|
||||
int i;
|
||||
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
|
||||
|
||||
@@ -218,8 +217,10 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a
|
||||
LOG_I(RRC, "selecting integrity algorithm %d\n", UE->integrity_algorithm);
|
||||
|
||||
/* derive UP security key */
|
||||
nr_derive_key(UP_ENC_ALG, UE->ciphering_algorithm, UE->kgnb, kUPenc);
|
||||
nr_derive_key(UP_INT_ALG, UE->integrity_algorithm, UE->kgnb, kUPint);
|
||||
security_parameters.ciphering_algorithm = UE->ciphering_algorithm;
|
||||
security_parameters.integrity_algorithm = UE->integrity_algorithm;
|
||||
nr_derive_key(UP_ENC_ALG, UE->ciphering_algorithm, UE->kgnb, security_parameters.ciphering_key);
|
||||
nr_derive_key(UP_INT_ALG, UE->integrity_algorithm, UE->kgnb, security_parameters.integrity_key);
|
||||
|
||||
e_NR_CipheringAlgorithm cipher_algo;
|
||||
switch (UE->ciphering_algorithm) {
|
||||
@@ -388,9 +389,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a
|
||||
nr_pdcp_add_drbs(ctxt.enb_flag,
|
||||
rrc_ue_id,
|
||||
ue_context_p->ue_context.rb_config->drb_ToAddModList,
|
||||
(ue_context_p->ue_context.integrity_algorithm << 4) | ue_context_p->ue_context.ciphering_algorithm,
|
||||
kUPenc,
|
||||
kUPint);
|
||||
&security_parameters);
|
||||
|
||||
ctxt.rntiMaybeUEid = du_ue_id;
|
||||
// assume only a single bearer
|
||||
|
||||
Reference in New Issue
Block a user