mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
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:
@@ -150,8 +150,23 @@ void nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id, const uint8_t
|
||||
* NOTE: knas is dynamically allocated by the KDF function
|
||||
*/
|
||||
|
||||
/** @brief KgNB derivation (A.9 3GPP TS 33.501) */
|
||||
void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb)
|
||||
/** @brief KgNB derivation function (Annex A.9 3GPP TS 33.501)
|
||||
*
|
||||
* Derives KgNB from K_AMF and the uplink NAS COUNT.
|
||||
* This function is applied when cryptographically protected 5G radio bearers are
|
||||
* established and when a key change on-the-fly is performed.
|
||||
*
|
||||
* KDF input S structure (per Annex A.9):
|
||||
* - FC = 0x6E
|
||||
* - P0 = Uplink NAS COUNT (count parameter)
|
||||
* - L0 = length of uplink NAS COUNT (0x00 0x04)
|
||||
* - P1 = Access type distinguisher (0x01 for 3GPP access)
|
||||
* - L1 = length of Access type distinguisher (0x00 0x01)
|
||||
*
|
||||
* @param[in] kamf 256-bit K_AMF key (input key KEY to KDF)
|
||||
* @param[in] count Uplink NAS COUNT value (P0 in KDF input S)
|
||||
* @param[out] kgnb Derived 256-bit KgNB key */
|
||||
void derive_kgnb(const uint8_t kamf[32], const uint32_t count, uint8_t *kgnb)
|
||||
{
|
||||
/* Compute the KDF input parameter
|
||||
* S = FC(0x6E) || UL NAS Count || 0x00 0x04 || 0x01 || 0x00 0x01
|
||||
|
||||
@@ -16,7 +16,7 @@ typedef enum {
|
||||
UP_INT_ALG = 0x06
|
||||
} algorithm_type_dist_t;
|
||||
|
||||
void derive_kgnb(uint8_t kamf[32], uint32_t count, uint8_t *kgnb);
|
||||
void derive_kgnb(const uint8_t kamf[32], const uint32_t count, uint8_t *kgnb);
|
||||
|
||||
void derive_keNB(const uint8_t kasme[32], const uint32_t nas_count, uint8_t *keNB);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user