Commit 72e10a0e authored by Cedric Roux's avatar Cedric Roux Committed by francescomani

nrUE: handle security settings for SRB1 and reestablishment

For the moment absoluteFrequencySSB is hardcoded. Fixed in a following commit.
parent a0e9716a
...@@ -619,7 +619,8 @@ static void nr_rrc_handle_msg3_indication(NR_UE_RRC_INST_t *rrc, rnti_t rnti) ...@@ -619,7 +619,8 @@ static void nr_rrc_handle_msg3_indication(NR_UE_RRC_INST_t *rrc, rnti_t rnti)
nr_rlc_reestablish_entity(rrc->ue_id, lc_id); nr_rlc_reestablish_entity(rrc->ue_id, lc_id);
// apply the specified configuration defined in 9.2.1 for SRB1 // apply the specified configuration defined in 9.2.1 for SRB1
nr_rlc_reconfigure_entity(rrc->ue_id, lc_id, NULL); nr_rlc_reconfigure_entity(rrc->ue_id, lc_id, NULL);
// TODO configure lower layers to suspend integrity protection and ciphering for SRB1 // suspend integrity protection and ciphering for SRB1
nr_pdcp_config_set_security(rrc->ue_id, srb_id, 0, NULL, NULL, NULL);
// resume SRB1 // resume SRB1
rrc->Srb[srb_id] = RB_ESTABLISHED; rrc->Srb[srb_id] = RB_ESTABLISHED;
break; break;
...@@ -1331,14 +1332,36 @@ static void nr_rrc_ue_process_rrcReestablishment(NR_UE_RRC_INST_t *rrc, ...@@ -1331,14 +1332,36 @@ static void nr_rrc_ue_process_rrcReestablishment(NR_UE_RRC_INST_t *rrc,
// store the nextHopChainingCount value // store the nextHopChainingCount value
NR_RRCReestablishment_IEs_t *ies = rrcReestablishment->criticalExtensions.choice.rrcReestablishment; NR_RRCReestablishment_IEs_t *ies = rrcReestablishment->criticalExtensions.choice.rrcReestablishment;
AssertFatal(ies, "Not expecting RRCReestablishment_IEs to be NULL\n"); AssertFatal(ies, "Not expecting RRCReestablishment_IEs to be NULL\n");
int nh = rrcReestablishment->criticalExtensions.choice.rrcReestablishment->nextHopChainingCount; // TODO need to understand how to use nextHopChainingCount
// TODO update the K gNB key based on the current K gNB key or the NH, using the stored nextHopChainingCount value // int nh = rrcReestablishment->criticalExtensions.choice.rrcReestablishment->nextHopChainingCount;
// TODO derive the K RRCenc and K UPenc keys associated with the previously configured cipheringAlgorithm
// TODO derive the K RRCint and K UPint keys associated with the previously configured integrityProtAlgorithm // update the K gNB key based on the current K gNB key or the NH, using the stored nextHopChainingCount value
/* TODO: retrieve absoluteFrequencySSB correctly */
int absoluteFrequencySSB = 621312;
nr_derive_key_ng_ran_star(rrc->phyCellID, absoluteFrequencySSB, rrc->kgnb, rrc->kgnb);
// derive the K RRCenc and K UPenc keys associated with the previously configured cipheringAlgorithm
// derive the K RRCint and K UPint keys associated with the previously configured integrityProtAlgorithm
uint8_t kRRCenc[16] = {0};
uint8_t kRRCint[16] = {0};
uint8_t kUPenc[16] = {0};
uint8_t kUPint[16] = {0};
nr_derive_key(UP_ENC_ALG, rrc->cipheringAlgorithm, rrc->kgnb, kUPenc);
nr_derive_key(UP_INT_ALG, rrc->integrityProtAlgorithm, rrc->kgnb, kUPint);
nr_derive_key(RRC_ENC_ALG, rrc->cipheringAlgorithm, rrc->kgnb, kRRCenc);
nr_derive_key(RRC_INT_ALG, rrc->integrityProtAlgorithm, rrc->kgnb, kRRCint);
// TODO request lower layers to verify the integrity protection of the RRCReestablishment message // TODO request lower layers to verify the integrity protection of the RRCReestablishment message
// TODO if the integrity protection check of the RRCReestablishment message fails -> go to IDLE // TODO if the integrity protection check of the RRCReestablishment message fails -> go to IDLE
// TODO configure lower layers to resume integrity protection for SRB1
// TODO configure lower layers to resume ciphering for SRB1 // configure lower layers to resume integrity protection for SRB1
// configure lower layers to resume ciphering for SRB1
int srb_id = 1;
int security_mode = (rrc->integrityProtAlgorithm << 4)
| rrc->cipheringAlgorithm;
nr_pdcp_config_set_security(rrc->ue_id, srb_id, security_mode, kRRCenc, kRRCint, kUPenc);
// release the measurement gap configuration indicated by the measGapConfig, if configured // release the measurement gap configuration indicated by the measGapConfig, if configured
rrcPerNB_t *rrcNB = rrc->perNB + gNB_index; rrcPerNB_t *rrcNB = rrc->perNB + gNB_index;
asn1cFreeStruc(asn_DEF_NR_MeasGapConfig, rrcNB->measGapConfig); asn1cFreeStruc(asn_DEF_NR_MeasGapConfig, rrcNB->measGapConfig);
......
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