Commit 8c14bf49 authored by Robert Schmidt's avatar Robert Schmidt

Simplify rrc_gNB_process_security()

rrc_gNB_process_security() does not only set (process) the security
algorithms, but also checks for those. However, we don't use the check.
Simplify the function, to reintroduce the check later. Rename to
set_UE_security_algos() to better reflect what the functions do.
parent 0cea0395
...@@ -93,7 +93,7 @@ static const uint16_t NGAP_INTEGRITY_NIA3_MASK = 0x2000; ...@@ -93,7 +93,7 @@ static const uint16_t NGAP_INTEGRITY_NIA3_MASK = 0x2000;
#define INTEGRITY_ALGORITHM_NONE NR_IntegrityProtAlgorithm_nia0 #define INTEGRITY_ALGORITHM_NONE NR_IntegrityProtAlgorithm_nia0
static bool rrc_gNB_process_security(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, ngap_security_capabilities_t *security_capabilities_pP); static void set_UE_security_algos(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const ngap_security_capabilities_t *cap);
/*! /*!
*\brief save security key. *\brief save security key.
...@@ -458,7 +458,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t ...@@ -458,7 +458,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t
UE->nas_pdu = req->nas_pdu; UE->nas_pdu = req->nas_pdu;
/* security */ /* security */
rrc_gNB_process_security(rrc, UE, &req->security_capabilities); set_UE_security_algos(rrc, UE, &req->security_capabilities);
set_UE_security_key(UE, req->security_key); set_UE_security_key(UE, req->security_key);
/* configure only integrity, ciphering comes after receiving SecurityModeComplete */ /* configure only integrity, ciphering comes after receiving SecurityModeComplete */
...@@ -591,44 +591,29 @@ static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity(const gNB_RRC_INST * ...@@ -591,44 +591,29 @@ static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity(const gNB_RRC_INST *
return ret; return ret;
} }
static bool rrc_gNB_process_security(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, ngap_security_capabilities_t *security_capabilities_pP) /*
* \brief set security algorithms
* \param rrc pointer to RRC context
* \param UE UE context
* \param cap security capabilities for this UE
*/
static void set_UE_security_algos(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const ngap_security_capabilities_t *cap)
{ {
bool changed = false;
NR_CipheringAlgorithm_t cipheringAlgorithm;
e_NR_IntegrityProtAlgorithm integrityProtAlgorithm;
/* Save security parameters */ /* Save security parameters */
UE->security_capabilities = *security_capabilities_pP; UE->security_capabilities = *cap;
// translation
LOG_D(NR_RRC,
"NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n",
UE->security_capabilities.nRencryption_algorithms,
(unsigned long)UE->ciphering_algorithm,
UE->security_capabilities.nRintegrity_algorithms,
UE->integrity_algorithm);
/* Select relevant algorithms */
cipheringAlgorithm = rrc_gNB_select_ciphering(rrc, UE->security_capabilities.nRencryption_algorithms);
if (UE->ciphering_algorithm != cipheringAlgorithm) { /* Select relevant algorithms */
UE->ciphering_algorithm = cipheringAlgorithm; NR_CipheringAlgorithm_t cipheringAlgorithm = rrc_gNB_select_ciphering(rrc, cap->nRencryption_algorithms);
changed = true; e_NR_IntegrityProtAlgorithm integrityProtAlgorithm = rrc_gNB_select_integrity(rrc, cap->nRintegrity_algorithms);
}
integrityProtAlgorithm = rrc_gNB_select_integrity(rrc, UE->security_capabilities.nRintegrity_algorithms);
if (UE->integrity_algorithm != integrityProtAlgorithm) { UE->ciphering_algorithm = cipheringAlgorithm;
UE->integrity_algorithm = integrityProtAlgorithm; UE->integrity_algorithm = integrityProtAlgorithm;
changed = true;
}
LOG_I(NR_RRC, LOG_I(NR_RRC,
"[UE %d] Selected security algorithms (%p): ciphering %lx, integrity %x (algorithms %s)\n", "[UE %d] Selected security algorithms: ciphering %lx, integrity %x\n",
UE->rrc_ue_id, UE->rrc_ue_id,
security_capabilities_pP,
cipheringAlgorithm, cipheringAlgorithm,
integrityProtAlgorithm, integrityProtAlgorithm);
changed ? "changed" : "are the same");
return changed;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
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