Commit 47d5dd89 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue for UE Security Capability

parent a08e27af
...@@ -1009,14 +1009,22 @@ void amf_n1::registration_request_handle( ...@@ -1009,14 +1009,22 @@ void amf_n1::registration_request_handle(
// Get UE Security Capability IE (optional), not included for periodic // Get UE Security Capability IE (optional), not included for periodic
// registration updating procedure // registration updating procedure
uint8_t encrypt_alg = {0}; uint8_t encrypt_alg = {0};
uint8_t integrity_alg = {0}; uint8_t integrity_alg = {0};
if (!regReq->getUeSecurityCapability(encrypt_alg, integrity_alg)) { uint8_t security_cap_eea = {0};
uint8_t security_cap_eia = {0};
if (!regReq->getUeSecurityCapability(
encrypt_alg, integrity_alg, security_cap_eea, security_cap_eia)) {
Logger::amf_n1().warn("No Optional IE UESecurityCapability available"); Logger::amf_n1().warn("No Optional IE UESecurityCapability available");
} }
nc.get()->ueSecurityCapEnc = encrypt_alg; nc.get()->ueSecurityCapEnc = encrypt_alg;
nc.get()->ueSecurityCapInt = integrity_alg; nc.get()->ueSecurityCapInt = integrity_alg;
nc.get()->ueSecurityCaplen = regReq->ie_ue_security_capability->getLenght();
nc.get()->ueSecurityCapEEA = security_cap_eea;
nc.get()->ueSecurityCapEIA = security_cap_eia;
nc.get()->ueSecurityCaplen = regReq->ie_ue_security_capability->getLength();
// Get Requested NSSAI (Optional IE), if provided // Get Requested NSSAI (Optional IE), if provided
std::vector<SNSSAI_t> requestedNssai = {}; std::vector<SNSSAI_t> requestedNssai = {};
...@@ -1938,10 +1946,17 @@ bool amf_n1::start_security_mode_control_procedure( ...@@ -1938,10 +1946,17 @@ bool amf_n1::start_security_mode_control_procedure(
smc->setNAS_Security_Algorithms(amf_nea, amf_nia); smc->setNAS_Security_Algorithms(amf_nea, amf_nia);
Logger::amf_n1().debug("Encoded ngKSI 0x%x", nc.get()->ngKsi); Logger::amf_n1().debug("Encoded ngKSI 0x%x", nc.get()->ngKsi);
smc->setngKSI(NAS_KEY_SET_IDENTIFIER_NATIVE, nc.get()->ngKsi & 0x07); smc->setngKSI(NAS_KEY_SET_IDENTIFIER_NATIVE, nc.get()->ngKsi & 0x07);
smc->setUE_Security_Capability( if (nc.get()->ueSecurityCaplen >= 4) {
nc.get()->ueSecurityCapEnc, nc.get()->ueSecurityCapInt); smc->setUE_Security_Capability(
nc.get()->ueSecurityCapEnc, nc.get()->ueSecurityCapInt,
nc.get()->ueSecurityCapEEA, nc.get()->ueSecurityCapEIA);
} else {
smc->setUE_Security_Capability(
nc.get()->ueSecurityCapEnc, nc.get()->ueSecurityCapInt);
}
if (smc->ie_ue_security_capability != NULL) { if (smc->ie_ue_security_capability != NULL) {
smc->ie_ue_security_capability->setLenght(nc.get()->ueSecurityCaplen); smc->ie_ue_security_capability->setLength(nc.get()->ueSecurityCaplen);
} else { } else {
Logger::amf_n1().error("smc->ie_ue_security_capability is NULL"); Logger::amf_n1().error("smc->ie_ue_security_capability is NULL");
} }
......
...@@ -45,6 +45,8 @@ nas_context::nas_context() : _vector(), _5g_he_av(), _5g_av(), kamf() { ...@@ -45,6 +45,8 @@ nas_context::nas_context() : _vector(), _5g_he_av(), _5g_av(), kamf() {
mmCapability = 0; mmCapability = 0;
ueSecurityCapEnc = 0; ueSecurityCapEnc = 0;
ueSecurityCapInt = 0; ueSecurityCapInt = 0;
ueSecurityCapEEA = 0;
ueSecurityCapEIA = 0;
requestedNssai = {}; requestedNssai = {};
is_specific_procedure_for_registration_running = false; is_specific_procedure_for_registration_running = false;
is_specific_procedure_for_deregistration_running = false; is_specific_procedure_for_deregistration_running = false;
......
...@@ -77,6 +77,10 @@ class nas_context { ...@@ -77,6 +77,10 @@ class nas_context {
uint8_t ueSecurityCaplen; uint8_t ueSecurityCaplen;
uint8_t ueSecurityCapEnc; uint8_t ueSecurityCapEnc;
uint8_t ueSecurityCapInt; uint8_t ueSecurityCapInt;
uint8_t ueSecurityCapEEA;
uint8_t ueSecurityCapEIA;
std::vector<nas::SNSSAI_t> requestedNssai; std::vector<nas::SNSSAI_t> requestedNssai;
std::string serving_network; std::string serving_network;
bstring auts; bstring auts;
......
...@@ -59,6 +59,18 @@ UESecurityCapability::UESecurityCapability( ...@@ -59,6 +59,18 @@ UESecurityCapability::UESecurityCapability(
length = 2; length = 2;
} }
//------------------------------------------------------------------------------
UESecurityCapability::UESecurityCapability(
const uint8_t iei, uint8_t _5gg_EASel, uint8_t _5gg_IASel, uint8_t _EEASel,
uint8_t _EIASel) {
_iei = iei;
_5g_EASel = _5gg_EASel;
_5g_IASel = _5gg_IASel;
EEASel = _EEASel;
EIASel = _EIASel;
length = 4;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void UESecurityCapability::setEASel(uint8_t sel) { void UESecurityCapability::setEASel(uint8_t sel) {
_5g_EASel = sel; _5g_EASel = sel;
...@@ -69,6 +81,16 @@ void UESecurityCapability::setIASel(uint8_t sel) { ...@@ -69,6 +81,16 @@ void UESecurityCapability::setIASel(uint8_t sel) {
_5g_IASel = sel; _5g_IASel = sel;
} }
//------------------------------------------------------------------------------
void UESecurityCapability::setEEASel(uint8_t sel) {
EEASel = sel;
}
//------------------------------------------------------------------------------
void UESecurityCapability::setEIASel(uint8_t sel) {
EIASel = sel;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t UESecurityCapability::getEASel() { uint8_t UESecurityCapability::getEASel() {
return _5g_EASel; return _5g_EASel;
...@@ -80,18 +102,28 @@ uint8_t UESecurityCapability::getIASel() { ...@@ -80,18 +102,28 @@ uint8_t UESecurityCapability::getIASel() {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void UESecurityCapability::setLenght(uint8_t len) { uint8_t UESecurityCapability::getEEASel() {
return EEASel;
}
//------------------------------------------------------------------------------
uint8_t UESecurityCapability::getEIASel() {
return EIASel;
}
//------------------------------------------------------------------------------
void UESecurityCapability::setLength(uint8_t len) {
if ((len > 0) && (len <= 4)) { if ((len > 0) && (len <= 4)) {
length = len; length = len;
} else { } else {
Logger::nas_mm().debug("Set UESecurityCapability Lenght faile %d", len); Logger::nas_mm().debug("Set UESecurityCapability Length fail %d", len);
Logger::nas_mm().debug( Logger::nas_mm().debug(
"UESecurityCapability Lenght is set to the default value %d", length); "UESecurityCapability Length is set to the default value %d", length);
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t UESecurityCapability::getLenght() { uint8_t UESecurityCapability::getLength() {
return length; return length;
} }
...@@ -113,9 +145,9 @@ int UESecurityCapability::encode2buffer(uint8_t* buf, int len) { ...@@ -113,9 +145,9 @@ int UESecurityCapability::encode2buffer(uint8_t* buf, int len) {
*(buf + encoded_size) = _5g_IASel; *(buf + encoded_size) = _5g_IASel;
encoded_size++; encoded_size++;
if (length == 4) { if (length == 4) {
*(buf + encoded_size) = 0xf0; *(buf + encoded_size) = EEASel; // 0xf0; //TODO: remove hardcoded value
encoded_size++; encoded_size++;
*(buf + encoded_size) = 0xf0; *(buf + encoded_size) = EIASel; // 0x70; //TODO: remove hardcoded value
encoded_size++; encoded_size++;
} }
...@@ -127,9 +159,9 @@ int UESecurityCapability::encode2buffer(uint8_t* buf, int len) { ...@@ -127,9 +159,9 @@ int UESecurityCapability::encode2buffer(uint8_t* buf, int len) {
*(buf + encoded_size) = _5g_IASel; *(buf + encoded_size) = _5g_IASel;
encoded_size++; encoded_size++;
if (length == 4) { if (length == 4) {
*(buf + encoded_size) = 0xf0; *(buf + encoded_size) = EEASel; // 0xf0; //TODO: remove hardcoded value
encoded_size++; encoded_size++;
*(buf + encoded_size) = 0xf0; *(buf + encoded_size) = EIASel; // 0x70; //TODO: remove hardcoded value
encoded_size++; encoded_size++;
} }
} }
...@@ -151,9 +183,16 @@ int UESecurityCapability::decodefrombuffer( ...@@ -151,9 +183,16 @@ int UESecurityCapability::decodefrombuffer(
decoded_size++; decoded_size++;
_5g_IASel = *(buf + decoded_size); _5g_IASel = *(buf + decoded_size);
decoded_size++; decoded_size++;
if (length >= 4) decoded_size += (length - 2); // TODO: decoding EEA EIA
if (length >= 4) {
EEASel = *(buf + decoded_size);
decoded_size++;
EIASel = *(buf + decoded_size);
decoded_size++;
decoded_size += (length - 4); // TODO: decoding EEA EIA
}
Logger::nas_mm().debug( Logger::nas_mm().debug(
"UESecurityCapability (length %d) EA 0x%x,IA 0x%x", length, _5g_EASel, "UESecurityCapability (length %d) EA 0x%x,IA 0x%x, EEA 0x%x, EIA 0x%x,",
_5g_IASel); length, _5g_EASel, _5g_IASel, EEASel, EIASel);
return decoded_size; return decoded_size;
} }
...@@ -40,12 +40,21 @@ class UESecurityCapability { ...@@ -40,12 +40,21 @@ class UESecurityCapability {
~UESecurityCapability(); ~UESecurityCapability();
UESecurityCapability( UESecurityCapability(
const uint8_t iei, uint8_t _5gg_EASel, uint8_t _5gg_IASel); const uint8_t iei, uint8_t _5gg_EASel, uint8_t _5gg_IASel);
UESecurityCapability(
const uint8_t iei, uint8_t _5gg_EASel, uint8_t _5gg_IASel, uint8_t EEASel,
uint8_t EIASel);
void setEASel(uint8_t sel); void setEASel(uint8_t sel);
void setIASel(uint8_t sel); void setIASel(uint8_t sel);
uint8_t getEASel(); uint8_t getEASel();
uint8_t getIASel(); uint8_t getIASel();
void setLenght(uint8_t len);
uint8_t getLenght(); void setEEASel(uint8_t sel);
void setEIASel(uint8_t sel);
uint8_t getEEASel();
uint8_t getEIASel();
void setLength(uint8_t len);
uint8_t getLength();
int encode2buffer(uint8_t* buf, int len); int encode2buffer(uint8_t* buf, int len);
int decodefrombuffer(uint8_t* buf, int len, bool is_option); int decodefrombuffer(uint8_t* buf, int len, bool is_option);
...@@ -54,6 +63,8 @@ class UESecurityCapability { ...@@ -54,6 +63,8 @@ class UESecurityCapability {
uint8_t length; uint8_t length;
uint8_t _5g_EASel; uint8_t _5g_EASel;
uint8_t _5g_IASel; uint8_t _5g_IASel;
uint8_t EEASel;
uint8_t EIASel;
}; };
} // namespace nas } // namespace nas
......
...@@ -226,6 +226,13 @@ void RegistrationRequest::setUE_Security_Capability( ...@@ -226,6 +226,13 @@ void RegistrationRequest::setUE_Security_Capability(
ie_ue_security_capability = new UESecurityCapability(0x2E, g_EASel, g_IASel); ie_ue_security_capability = new UESecurityCapability(0x2E, g_EASel, g_IASel);
} }
//------------------------------------------------------------------------------
void RegistrationRequest::setUE_Security_Capability(
uint8_t g_EASel, uint8_t g_IASel, uint8_t EEASel, uint8_t EIASel) {
ie_ue_security_capability =
new UESecurityCapability(0x2E, g_EASel, g_IASel, EEASel, EIASel);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) { bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) {
if (ie_ue_security_capability) { if (ie_ue_security_capability) {
...@@ -237,6 +244,22 @@ bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) { ...@@ -237,6 +244,22 @@ bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) {
return true; return true;
} }
//------------------------------------------------------------------------------
bool RegistrationRequest::getUeSecurityCapability(
uint8_t& ea, uint8_t& ia, uint8_t& eea, uint8_t& eia) {
if (ie_ue_security_capability) {
ea = ie_ue_security_capability->getEASel();
ia = ie_ue_security_capability->getIASel();
if (ie_ue_security_capability->getLength() >= 4) {
eea = ie_ue_security_capability->getEEASel();
eia = ie_ue_security_capability->getEIASel();
}
} else {
return -1;
}
return true;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RegistrationRequest::setRequested_NSSAI( void RegistrationRequest::setRequested_NSSAI(
std::vector<struct SNSSAI_s> nssai) { std::vector<struct SNSSAI_s> nssai) {
......
...@@ -67,6 +67,8 @@ class RegistrationRequest { ...@@ -67,6 +67,8 @@ class RegistrationRequest {
void setNon_current_native_nas_ksi(uint8_t tsc, uint8_t key_set_id); void setNon_current_native_nas_ksi(uint8_t tsc, uint8_t key_set_id);
void set5G_MM_capability(uint8_t value); void set5G_MM_capability(uint8_t value);
void setUE_Security_Capability(uint8_t g_EASel, uint8_t g_IASel); void setUE_Security_Capability(uint8_t g_EASel, uint8_t g_IASel);
void setUE_Security_Capability(
uint8_t g_EASel, uint8_t g_IASel, uint8_t EEASel, uint8_t EIASel);
void setRequested_NSSAI(std::vector<struct SNSSAI_s> nssai); void setRequested_NSSAI(std::vector<struct SNSSAI_s> nssai);
void setUENetworkCapability(uint8_t g_EEASel, uint8_t g_EIASel); void setUENetworkCapability(uint8_t g_EEASel, uint8_t g_EIASel);
...@@ -98,6 +100,8 @@ class RegistrationRequest { ...@@ -98,6 +100,8 @@ class RegistrationRequest {
uint8_t getNonCurrentNativeNasKSI(); uint8_t getNonCurrentNativeNasKSI();
uint8_t get5GMMCapability(); uint8_t get5GMMCapability();
bool getUeSecurityCapability(uint8_t& ea, uint8_t& ia); bool getUeSecurityCapability(uint8_t& ea, uint8_t& ia);
bool getUeSecurityCapability(
uint8_t& ea, uint8_t& ia, uint8_t& eea, uint8_t& eia);
bool getRequestedNssai(std::vector<struct SNSSAI_s>& nssai); bool getRequestedNssai(std::vector<struct SNSSAI_s>& nssai);
bool getS1UeNetworkCapability(uint8_t& eea, uint8_t& eia); bool getS1UeNetworkCapability(uint8_t& eea, uint8_t& eia);
uint16_t getUplinkDataStatus(); uint16_t getUplinkDataStatus();
......
...@@ -75,6 +75,13 @@ void SecurityModeCommand::setUE_Security_Capability( ...@@ -75,6 +75,13 @@ void SecurityModeCommand::setUE_Security_Capability(
ie_ue_security_capability = new UESecurityCapability(0x00, g_EASel, g_IASel); ie_ue_security_capability = new UESecurityCapability(0x00, g_EASel, g_IASel);
} }
//------------------------------------------------------------------------------
void SecurityModeCommand::setUE_Security_Capability(
uint8_t g_EASel, uint8_t g_IASel, uint8_t EEASel, uint8_t EIASel) {
ie_ue_security_capability =
new UESecurityCapability(0x00, g_EASel, g_IASel, EEASel, EIASel);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void SecurityModeCommand::setIMEISV_Request(uint8_t value) { void SecurityModeCommand::setIMEISV_Request(uint8_t value) {
ie_imeisv_request = new IMEISV_Request(0x0E, value); ie_imeisv_request = new IMEISV_Request(0x0E, value);
......
...@@ -43,6 +43,8 @@ class SecurityModeCommand { ...@@ -43,6 +43,8 @@ class SecurityModeCommand {
void setNAS_Security_Algorithms(uint8_t ciphering, uint8_t integrity); void setNAS_Security_Algorithms(uint8_t ciphering, uint8_t integrity);
void setngKSI(uint8_t tsc, uint8_t key_set_id); void setngKSI(uint8_t tsc, uint8_t key_set_id);
void setUE_Security_Capability(uint8_t g_EASel, uint8_t g_IASel); void setUE_Security_Capability(uint8_t g_EASel, uint8_t g_IASel);
void setUE_Security_Capability(
uint8_t g_EASel, uint8_t g_IASel, uint8_t EEASel, uint8_t EIASel);
void setIMEISV_Request(uint8_t value); void setIMEISV_Request(uint8_t value);
void setEPS_NAS_Security_Algorithms(uint8_t ciphering, uint8_t integrity); void setEPS_NAS_Security_Algorithms(uint8_t ciphering, uint8_t integrity);
void setAdditional_5G_Security_Information(bool rinmr, bool hdp); void setAdditional_5G_Security_Information(bool rinmr, bool hdp);
......
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