Added helper function for replayed security capabilities

master
Bedran Karakoc 3 years ago committed by Bedran Karakoc
parent 193ec4abfa
commit de750fad09

@ -134,10 +134,11 @@ private:
int send_deregistration_request_ue_originating(bool switch_off); int send_deregistration_request_ue_originating(bool switch_off);
int send_identity_response(srsran::nas_5g::identity_type_5gs_t::identity_types_::options requested_identity_type); int send_identity_response(srsran::nas_5g::identity_type_5gs_t::identity_types_::options requested_identity_type);
// Helper functions
void fill_security_caps(srsran::nas_5g::ue_security_capability_t& sec_caps); void fill_security_caps(srsran::nas_5g::ue_security_capability_t& sec_caps);
int apply_security_config(srsran::unique_byte_buffer_t& pdu, uint8_t sec_hdr_type); int apply_security_config(srsran::unique_byte_buffer_t& pdu, uint8_t sec_hdr_type);
int handle_deregistration_accept_ue_originating( bool check_replayed_ue_security_capabilities(srsran::nas_5g::ue_security_capability_t& caps);
srsran::nas_5g::deregistration_accept_ue_originating_t& deregistration_accept_ue_originating);
// message handler // message handler
int handle_registration_accept(srsran::nas_5g::registration_accept_t& registration_accept); int handle_registration_accept(srsran::nas_5g::registration_accept_t& registration_accept);
int handle_registration_reject(srsran::nas_5g::registration_reject_t& registration_reject); int handle_registration_reject(srsran::nas_5g::registration_reject_t& registration_reject);
@ -150,6 +151,8 @@ private:
srsran::unique_byte_buffer_t pdu); srsran::unique_byte_buffer_t pdu);
int handle_deregistration_accept_ue_terminated( int handle_deregistration_accept_ue_terminated(
srsran::nas_5g::deregistration_accept_ue_terminated_t& deregistration_accept_ue_terminated); srsran::nas_5g::deregistration_accept_ue_terminated_t& deregistration_accept_ue_terminated);
int handle_deregistration_accept_ue_originating(
srsran::nas_5g::deregistration_accept_ue_originating_t& deregistration_accept_ue_originating);
int handle_deregistration_request_ue_terminated( int handle_deregistration_request_ue_terminated(
srsran::nas_5g::deregistration_request_ue_terminated_t& deregistration_request_ue_terminated); srsran::nas_5g::deregistration_request_ue_terminated_t& deregistration_request_ue_terminated);
int handle_configuration_update_command(srsran::nas_5g::configuration_update_command_t& configuration_update_command); int handle_configuration_update_command(srsran::nas_5g::configuration_update_command_t& configuration_update_command);

@ -836,11 +836,10 @@ int nas_5g::handle_security_mode_command(security_mode_command_t& security_m
ctxt.integ_algo = (INTEGRITY_ALGORITHM_ID_ENUM) ctxt.integ_algo = (INTEGRITY_ALGORITHM_ID_ENUM)
security_mode_command.selected_nas_security_algorithms.integrity_protection_algorithm.value; security_mode_command.selected_nas_security_algorithms.integrity_protection_algorithm.value;
// Check capabilities // Check replayed ue security capabilities
// TODO: Check replayed sec capabilities if (!check_replayed_ue_security_capabilities(security_mode_command.replayed_ue_security_capabilities)) {
if (!ea5g_caps[ctxt.cipher_algo] || !ia5g_caps[ctxt.integ_algo]) {
logger.warning("Sending Security Mode Reject due to security capabilities mismatch"); logger.warning("Sending Security Mode Reject due to security capabilities mismatch");
send_security_mode_reject(cause_5gmm_t::cause_5gmm_type_::options::ue_security_capabilities_mismatch); send_security_mode_reject(cause_5gmm_t::cause_5gmm_type_::ue_security_capabilities_mismatch);
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
@ -1056,6 +1055,36 @@ void nas_5g::fill_security_caps(srsran::nas_5g::ue_security_capability_t& sec_ca
} }
} }
bool nas_5g::check_replayed_ue_security_capabilities(srsran::nas_5g::ue_security_capability_t& caps)
{
if (caps.ia0_5g_supported != ia5g_caps[0] || caps.ea0_5g_supported != ea5g_caps[0]) {
return false;
}
if (caps.ia1_128_5g_supported != ia5g_caps[1] || caps.ea1_128_5g_supported != ea5g_caps[1]) {
return false;
}
if (caps.ia2_128_5g_supported != ia5g_caps[2] || caps.ea2_128_5g_supported != ea5g_caps[2]) {
return false;
}
if (caps.ia3_128_5g_supported != ia5g_caps[3] || caps.ea3_128_5g_supported != ea5g_caps[3]) {
return false;
}
if (caps.ia4_5g_supported != ia5g_caps[4] || caps.ea4_5g_supported != ea5g_caps[4]) {
return false;
}
if (caps.ia5_5g_supported != ia5g_caps[5] || caps.ea5_5g_supported != ea5g_caps[5]) {
return false;
}
if (caps.ia6_5g_supported != ia5g_caps[6] || caps.ea6_5g_supported != ea5g_caps[6]) {
return false;
}
if (caps.ia7_5g_supported != ia5g_caps[7] || caps.ea7_5g_supported != ea5g_caps[7]) {
return false;
}
return true;
}
/******************************************************************************* /*******************************************************************************
* Helpers for Session Management * Helpers for Session Management
******************************************************************************/ ******************************************************************************/

Loading…
Cancel
Save