From 91a7dc806fc0756c53a96d7ecfc093c1a7983a4c Mon Sep 17 00:00:00 2001 From: mir Date: Mon, 17 Jul 2023 12:47:30 +0200 Subject: [PATCH 1/5] First commit to remove crypt dependency --- CMakeLists.txt | 4 ---- openair3/NGAP/ngap_gNB.c | 23 +++++++++++++---------- openair3/S1AP/s1ap_eNB.c | 23 +++++++++++++---------- openair3/SECU/kdf.h | 2 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bef6278246..eb6707c418 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,10 +300,6 @@ target_link_libraries(lte_rrc PRIVATE nr_rrc) add_library(nr_rrc ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c) target_link_libraries(nr_rrc PUBLIC asn1_nr_rrc asn1_lte_rrc) - -# S1AP and NGAP need crypt library -pkg_check_modules(libcrypt REQUIRED libcrypt) - # S1AP ############## set(S1AP_DIR ${OPENAIR3_DIR}/S1AP) diff --git a/openair3/NGAP/ngap_gNB.c b/openair3/NGAP/ngap_gNB.c index f877e9d4ba..09dc9321a1 100644 --- a/openair3/NGAP/ngap_gNB.c +++ b/openair3/NGAP/ngap_gNB.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include "openair3/SECU/kdf.h" #include "tree.h" #include "queue.h" @@ -71,17 +71,20 @@ void ngap_gNB_handle_register_gNB(instance_t instance, ngap_register_gnb_req_t * void ngap_gNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp); -uint32_t ngap_generate_gNB_id(void) { - char *out; - char hostname[50]; - int ret; - uint32_t gNB_id; +uint32_t ngap_generate_gNB_id(void) +{ /* Retrieve the host name */ - ret = gethostname(hostname, sizeof(hostname)); + char hostname[32] = {0}; + int const ret = gethostname(hostname, sizeof(hostname)); DevAssert(ret == 0); - out = crypt(hostname, "eurecom"); - DevAssert(out != NULL); - gNB_id = ((out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3]); + + uint8_t key[32] = {"eurecom"}; + byte_array_t data = {.len = 32, .buf = (uint8_t *)hostname}; + + uint8_t out[32] = {0}; + kdf(key, data, 32, out); + + uint32_t const gNB_id = ((out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3]); return gNB_id; } diff --git a/openair3/S1AP/s1ap_eNB.c b/openair3/S1AP/s1ap_eNB.c index 700148f05e..2baf315599 100644 --- a/openair3/S1AP/s1ap_eNB.c +++ b/openair3/S1AP/s1ap_eNB.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include "openair3/SECU/kdf.h" #include "tree.h" #include "queue.h" @@ -108,17 +108,20 @@ int s1ap_timer_remove(long timer_id) return ret; } -uint32_t s1ap_generate_eNB_id(void) { - char *out; - char hostname[50]; - int ret; - uint32_t eNB_id; +uint32_t s1ap_generate_eNB_id(void) +{ /* Retrieve the host name */ - ret = gethostname(hostname, sizeof(hostname)); + char hostname[32] = {0}; + int const ret = gethostname(hostname, sizeof(hostname)); DevAssert(ret == 0); - out = crypt(hostname, "eurecom"); - DevAssert(out != NULL); - eNB_id = ((out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3]); + + uint8_t key[32] = {"eurecom"}; + byte_array_t data = {.len = 32, .buf = (uint8_t *)hostname}; + + uint8_t out[32] = {0}; + kdf(key, data, 32, out); + + uint32_t const eNB_id = ((out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3]); return eNB_id; } diff --git a/openair3/SECU/kdf.h b/openair3/SECU/kdf.h index 9567296bd2..ad8a842fad 100644 --- a/openair3/SECU/kdf.h +++ b/openair3/SECU/kdf.h @@ -24,7 +24,7 @@ #include #include -#include "byte_array.h" +#include "common/utils/ds/byte_array.h" void kdf(const uint8_t key[32], byte_array_t data, size_t len, uint8_t out[len]); From 10383fcafeec6a80694f0ab696027006a768c53b Mon Sep 17 00:00:00 2001 From: mir Date: Mon, 17 Jul 2023 18:18:34 +0200 Subject: [PATCH 2/5] Crypt library dependencies removed --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb6707c418..0ae2cd3417 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -321,8 +321,6 @@ add_library(s1ap ) target_link_libraries(s1ap PUBLIC asn1_s1ap) target_link_libraries(s1ap PRIVATE nr_rrc asn1_nr_rrc_hdrs lte_rrc) -target_include_directories(s1ap PRIVATE ${libcrypt_INCLUDE_DIRS}) -target_link_libraries(s1ap PUBLIC ${libcrypt_LIBRARIES}) # NGAP ############## @@ -344,8 +342,6 @@ add_library(ngap ) target_link_libraries(ngap PUBLIC asn1_ngap) target_link_libraries(ngap PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) -target_include_directories(ngap PRIVATE ${libcrypt_INCLUDE_DIRS}) -target_link_libraries(ngap PRIVATE ${libcrypt_LIBRARIES}) #M2AP ############## @@ -1442,7 +1438,7 @@ add_library(e1_if ${NR_RRC_DIR}/cucp_cuup_e1ap.c ) -target_link_libraries(e1_if PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs asn1_f1ap SECURITY ${OPENSSL_LIBRARIES} crypt e1ap GTPV1U) +target_link_libraries(e1_if PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs asn1_f1ap SECURITY ${OPENSSL_LIBRARIES} e1ap GTPV1U) add_library(e1_pdcp_if ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_e1_api.c From 86563e8058ad30f375f57070b425f37636f6372e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 18 Jul 2023 10:48:47 +0200 Subject: [PATCH 3/5] Remove unused libgcrypt dependency --- cmake_targets/tools/MODULES/FindGcrypt.cmake | 36 -------------------- cmake_targets/tools/build_helper | 3 +- 2 files changed, 1 insertion(+), 38 deletions(-) delete mode 100755 cmake_targets/tools/MODULES/FindGcrypt.cmake diff --git a/cmake_targets/tools/MODULES/FindGcrypt.cmake b/cmake_targets/tools/MODULES/FindGcrypt.cmake deleted file mode 100755 index fd4517dafb..0000000000 --- a/cmake_targets/tools/MODULES/FindGcrypt.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# - Find gnutls -# Find the native GCRYPT includes and library -# -# GCRYPT_FOUND - True if gnutls found. -# GCRYPT_INCLUDE_DIR - where to find gnutls.h, etc. -# GCRYPT_LIBRARIES - List of libraries when using gnutls. - -if (GCRYPT_INCLUDE_DIR AND GCRYPT_LIBRARIES) - set(GCRYPT_FIND_QUIETLY TRUE) -endif (GCRYPT_INCLUDE_DIR AND GCRYPT_LIBRARIES) - -# Include dir -find_path(GCRYPT_INCLUDE_DIR - NAMES - gcrypt.h -) - -# Library -find_library(GCRYPT_LIBRARY - NAMES gcrypt -) - -# handle the QUIETLY and REQUIRED arguments and set GCRYPT_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GCRYPT DEFAULT_MSG GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR) - -IF(GCRYPT_FOUND) - SET( GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} ) -ELSE(GCRYPT_FOUND) - SET( GCRYPT_LIBRARIES ) -ENDIF(GCRYPT_FOUND) - -# Lastly make it so that the GCRYPT_LIBRARY and GCRYPT_INCLUDE_DIR variables -# only show up under the advanced options in the gui cmake applications. -MARK_AS_ADVANCED( GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR ) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 88f84538ef..2d5537bbdd 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -595,7 +595,7 @@ check_install_oai_software() { case "$(get_distribution_release)" in "ubuntu18.04") add_cmake_repo - specific_packages="libgcrypt11-dev" + specific_packages="" ;; "debian11") specific_packages="libz-dev" @@ -645,7 +645,6 @@ check_install_oai_software() { pkgconfig \ libconfig-devel \ libffi-devel \ - libgcrypt-devel \ lksctp-tools \ lksctp-tools-devel \ libtool \ From 6050c5db66cb8e527efc826b3ea7e60497347167 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 18 Jul 2023 10:50:38 +0200 Subject: [PATCH 4/5] GnuTLS: only used by webserver, so move it to additional packages --- cmake_targets/tools/build_helper | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 2d5537bbdd..6108efbfcc 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -554,11 +554,12 @@ check_install_additional_tools (){ ;; esac PACKAGE_LIST="\ - doxygen \ - libpthread-stubs0-dev \ - libqt5charts5-dev \ - tshark \ - uml-utilities \ + doxygen \ + libgnutls28-dev \ + libpthread-stubs0-dev \ + libqt5charts5-dev \ + tshark \ + uml-utilities \ iperf3 \ libforms-bin \ libforms-dev \ @@ -568,6 +569,7 @@ check_install_additional_tools (){ doxygen \ ctags \ iperf3 \ + gnutls-devel \ xforms \ xforms-devel \ xmlstarlet" @@ -576,6 +578,7 @@ check_install_additional_tools (){ doxygen \ ctags \ iperf3 \ + gnutls-devel \ xforms \ xforms-devel \ xmlstarlet" @@ -614,7 +617,6 @@ check_install_oai_software() { liblapack-dev \ liblapacke-dev \ libreadline-dev \ - libgnutls28-dev \ libconfig-dev \ libsctp-dev \ libssl-dev \ @@ -655,7 +657,6 @@ check_install_oai_software() { openssl-devel \ patch \ readline-devel \ - gnutls-devel \ lapack \ lapack-devel \ blas \ From 08069035416b68abb79db99cb6fb92f3d491050e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 18 Jul 2023 10:51:57 +0200 Subject: [PATCH 5/5] Harmonize additional packages installer: RHEL/Fedora are identical --- cmake_targets/tools/build_helper | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 6108efbfcc..d50b62c389 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -564,7 +564,7 @@ check_install_additional_tools (){ libforms-bin \ libforms-dev \ xmlstarlet" - elif [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]] || [[ "$OS_DISTRO" == "rocky" ]]; then + elif [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]] || [[ "$OS_DISTRO" == "rocky" ]] || [[ "$OS_DISTRO" == "fedora" ]]; then PACKAGE_LIST="\ doxygen \ ctags \ @@ -573,15 +573,6 @@ check_install_additional_tools (){ xforms \ xforms-devel \ xmlstarlet" - elif [[ "$OS_DISTRO" == "fedora" ]]; then - PACKAGE_LIST=" \ - doxygen \ - ctags \ - iperf3 \ - gnutls-devel \ - xforms \ - xforms-devel \ - xmlstarlet" fi $SUDO $INSTALLER install -y $PACKAGE_LIST $optional_packages }