Section: 6.9.2.3.4 UE handling
Content: The UE behaviour is the same regardless if the handover is intra-gNB-CU, intra ng-eNB, Xn, or N2 with the exception that during intra-gNB-CU handover, the UE may retain the same key based on an indication from the gNB. The UE behaviour is also same in case of conditional handover, as specified in TS 38.300[ NR; NR and NG-RAN Overall description; Stage-2 ]  [52], i.e., the UE shall use the parameters of the selected target cell in KNG-RAN* derivations. If the UE also receives a NASC (NAS Container) in the HO Command message, the UE shall update its NAS security context as follows: NOTE 1: The purpose of this NASC could be compared to a NAS SMC message. - The UE shall verify the freshness of the downlink NAS COUNT in the NASC. - If the NASC indicates a new KAMF has been calculated (i.e., K_AMF_change_flag is one), - The UE shall compute the horizontally derived KAMF using the KAMF from the current 5G NAS security context identified by the ngKSI included in the NASC and the downlink NAS COUNT in the NASC, as specified in Annex A.13. - The UE shall assign the ngKSI included in the NASC to the ngKSI of the new derived KAMF. The UE shall further configure NAS security based on the horizontally derived KAMF and the selected NAS security algorithms in the NASC. - The UE shall further verify the NAS MAC in the NASC as described in Clause 6.9.2.3.3 and if the verification is successful, the UE shall further set the NAS COUNTs to zero. - If KAMF change is not indicated, - If the verification is successful, the UE shall configure the NAS security based on the parameters included in the NASC but shall not set the NAS COUNTs to zero. - The UE shall verify the NAS MAC in the NASC. - The UE shall further set the downlink NAS COUNT value of the currently active NAS security context to the received downlink NAS COUNT value in the NASC. If verification of the NASC fails, the UE shall abort the handover procedure. Furthermore, the UE shall discard the new NAS security context if it was derived and continue to use the existing NAS and AS security contexts. If keySetChangeIndicator in the HO command is true - If the HO Command message contained a NASC parameter with the K_AMF_change_flag set to one: - The UE shall use the horizontally derived KAMF and the NAS COUNT value of 232-1 in the derivation of the temporary KgNB. The UE shall further process this temporary key as described in subclause 6.9.4.4. - Else: - The UE handling related to key derivation shall be done as defined in clause 6.9.4.4. Else - If the NCC value the UE received in the HO Command message from target ng-eNB/gNB via source ng-eNB/gNB is equal to the NCC value associated with the currently active KgNB/KeNB, the UE shall derive the KNG-RAN* from the currently active KgNB/KeNB and the target PCI and its frequency ARFCN-DL/EARFCN-DL using the function defined in Annex A.11 and A.12. - If the UE received an NCC value that was different from the NCC associated with the currently active KgNB/KeNB, the UE shall first synchronize the locally kept NH parameter by computing the function defined in Annex A.10 iteratively (and increasing the NCC value until it matches the NCC value received from the source ng-eNB/gNB via the HO command message. When the NCC values match, the UE shall compute the KNG-RAN* from the synchronized NH parameter and the target PCI and its frequency ARFCN-DL/EARFCN-DL using the function defined in Annex A.11 and A.12. The UE shall use the KNG-RAN* as the KgNB when communicating with the target gNB and as the KeNB when communicating with the target ng-eNB.