From ac07f4cfafb78fefb51a8ce79c004d40e1e4ebb6 Mon Sep 17 00:00:00 2001 From: Fabian Eckermann Date: Thu, 13 Jun 2024 16:25:37 +0200 Subject: [PATCH] cu_cp,security: make getter function const --- include/srsran/security/security.h | 6 +++--- .../ue_security_manager_impl.cpp | 12 ++++++------ .../ue_security_manager_impl.h | 18 +++++++++--------- lib/security/security.cpp | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/srsran/security/security.h b/include/srsran/security/security.h index cbbd80099c..f9ace67f96 100644 --- a/include/srsran/security/security.h +++ b/include/srsran/security/security.h @@ -210,9 +210,9 @@ struct security_context { bool select_algorithms(preferred_integrity_algorithms pref_inte_list, preferred_ciphering_algorithms pref_ciph_list); void generate_as_keys(); - sec_as_config get_as_config(sec_domain domain); - sec_128_as_config get_128_as_config(sec_domain domain); - void horizontal_key_derivation(pci_t target_pci, unsigned target_ssb_arfcn); + [[nodiscard]] sec_as_config get_as_config(sec_domain domain) const; + [[nodiscard]] sec_128_as_config get_128_as_config(sec_domain domain) const; + void horizontal_key_derivation(pci_t target_pci, unsigned target_ssb_arfcn); }; /****************************************************************************** diff --git a/lib/cu_cp/ue_security_manager/ue_security_manager_impl.cpp b/lib/cu_cp/ue_security_manager/ue_security_manager_impl.cpp index ad782e4160..12163cca29 100644 --- a/lib/cu_cp/ue_security_manager/ue_security_manager_impl.cpp +++ b/lib/cu_cp/ue_security_manager/ue_security_manager_impl.cpp @@ -19,12 +19,12 @@ ue_security_manager::ue_security_manager(const security_manager_config& cfg_) : } // up_ue_security_manager -security::sec_as_config ue_security_manager::get_up_as_config() +security::sec_as_config ue_security_manager::get_up_as_config() const { return sec_context.get_as_config(security::sec_domain::up); } -security::sec_128_as_config ue_security_manager::get_up_128_as_config() +security::sec_128_as_config ue_security_manager::get_up_128_as_config() const { return sec_context.get_128_as_config(security::sec_domain::up); } @@ -66,22 +66,22 @@ void ue_security_manager::enable_security() security_enabled = true; } -security::security_context ue_security_manager::get_security_context() +security::security_context ue_security_manager::get_security_context() const { return sec_context; } -security::sec_selected_algos ue_security_manager::get_security_algos() +security::sec_selected_algos ue_security_manager::get_security_algos() const { return sec_context.sel_algos; } -security::sec_as_config ue_security_manager::get_rrc_as_config() +security::sec_as_config ue_security_manager::get_rrc_as_config() const { return sec_context.get_as_config(security::sec_domain::rrc); } -security::sec_128_as_config ue_security_manager::get_rrc_128_as_config() +security::sec_128_as_config ue_security_manager::get_rrc_128_as_config() const { return sec_context.get_128_as_config(security::sec_domain::rrc); } diff --git a/lib/cu_cp/ue_security_manager/ue_security_manager_impl.h b/lib/cu_cp/ue_security_manager/ue_security_manager_impl.h index ec1cefe998..2d26a08621 100644 --- a/lib/cu_cp/ue_security_manager/ue_security_manager_impl.h +++ b/lib/cu_cp/ue_security_manager/ue_security_manager_impl.h @@ -23,21 +23,21 @@ class ue_security_manager ~ue_security_manager() = default; // up_ue_security_manager - security::sec_as_config get_up_as_config(); - security::sec_128_as_config get_up_128_as_config(); + [[nodiscard]] security::sec_as_config get_up_as_config() const; + [[nodiscard]] security::sec_128_as_config get_up_128_as_config() const; // ngap_ue_security_manager bool init_security_context(security::security_context sec_ctxt); [[nodiscard]] bool is_security_enabled() const; // rrc_ue_security_manager - void enable_security(); - security::security_context get_security_context(); - security::sec_selected_algos get_security_algos(); - security::sec_as_config get_rrc_as_config(); - security::sec_128_as_config get_rrc_128_as_config(); - void update_security_context(security::security_context sec_ctxt); - void horizontal_key_derivation(pci_t target_pci, unsigned target_ssb_arfcn); + void enable_security(); + [[nodiscard]] security::security_context get_security_context() const; + [[nodiscard]] security::sec_selected_algos get_security_algos() const; + [[nodiscard]] security::sec_as_config get_rrc_as_config() const; + [[nodiscard]] security::sec_128_as_config get_rrc_128_as_config() const; + void update_security_context(security::security_context sec_ctxt); + void horizontal_key_derivation(pci_t target_pci, unsigned target_ssb_arfcn); private: security_manager_config cfg; diff --git a/lib/security/security.cpp b/lib/security/security.cpp index b5191536cc..35a73d2960 100644 --- a/lib/security/security.cpp +++ b/lib/security/security.cpp @@ -96,12 +96,12 @@ void security_context::horizontal_key_derivation(pci_t target_pci, unsigned targ generate_as_keys(); } -sec_128_as_config security_context::get_128_as_config(sec_domain domain) +sec_128_as_config security_context::get_128_as_config(sec_domain domain) const { return truncate_config(get_as_config(domain)); } -sec_as_config security_context::get_as_config(sec_domain domain) +sec_as_config security_context::get_as_config(sec_domain domain) const { srsran_sanity_check(sel_algos.algos_selected, "Tried to get AS config, but no algorithms are selected"); sec_as_config as_cfg;