RRC: Implement proper NH chain synchronization for RRC Reestablishment
Refactor key derivation logic to properly handle Next Hop (NH) chain synchronization according to 3GPP TS 33.501 specifications for both RRC Reestablishment and Master Key Update procedures. Changes in rrc_gNB.c: - Clarify key derivation in rrc_gNB_generate_RRCReestablishment by explicitly selecting base key (NH or KgNB) based on nh_ncc value - Add comment explaining vertical vs horizontal derivation logic Changes in rrc_UE.c: - Add nr_sync_nh_chain(): Common helper to synchronize NH parameter chain per TS 33.501 Annex A.10, supporting both Master Key Update and RRC Reestablishment procedures - Add nr_derive_kgnb_horizontal(): Derive KNG-RAN* from current KgNB when NCC values match (horizontal derivation per TS 33.501 A.11/A.12) - Add nr_derive_kgnb_vertical(): Derive KNG-RAN* from synchronized NH after NH chain sync (vertical derivation per TS 33.501 A.11/A.12) - Add nr_update_kgnb_from_ncc(): Unified function implementing TS 33.501 6.9.2.3.4 logic for updating KgNB based on received nextHopChainingCount - Refactor as_security_key_update(): Use new nr_update_kgnb_from_ncc() helper function for cleaner, more maintainable code - Fix nr_rrc_ue_process_rrcReestablishment(): Properly handle received nextHopChainingCount and update KgNB using unified helper function - Add debug logging for key derivation process Key NAS deriver utils: - update derive_kgnb documentation and protect input keys with const attribute
This commit is contained in:
@@ -1092,7 +1092,10 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context
|
||||
const f1ap_served_cell_info_t *cell_info = &du->setup_req->cell[0].info;
|
||||
uint32_t ssb_arfcn = get_ssb_arfcn(du);
|
||||
LOG_I(NR_RRC, "Reestablishment update key pci=%d, earfcn_dl=%u\n", cell_info->nr_pci, ssb_arfcn);
|
||||
nr_derive_key_ng_ran_star(cell_info->nr_pci, ssb_arfcn, ue_p->nh_ncc > 0 ? ue_p->nh : ue_p->kgnb, ue_p->kgnb);
|
||||
|
||||
/* Derive KgNB* using NH if nh_ncc > 0 (vertical derivation), else use KgNB (horizontal derivation) */
|
||||
const uint8_t *base_key = ue_p->nh_ncc > 0 ? ue_p->nh : ue_p->kgnb;
|
||||
nr_derive_key_ng_ran_star(cell_info->nr_pci, ssb_arfcn, base_key, ue_p->kgnb);
|
||||
int size = do_RRCReestablishment(ue_context_pP->ue_context.nh_ncc, buffer, NR_RRC_BUF_SIZE, xid);
|
||||
|
||||
LOG_A(NR_RRC, "Send RRCReestablishment [%d bytes] to RNTI %04x\n", size, ue_p->rnti);
|
||||
|
||||
Reference in New Issue
Block a user