diff --git a/CMakeLists.txt b/CMakeLists.txt index bef6278246..0ae2cd3417 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) @@ -325,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 ############## @@ -348,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 ############## @@ -1446,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 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..d50b62c389 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -554,28 +554,22 @@ 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 \ 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 \ iperf3 \ - xforms \ - xforms-devel \ - xmlstarlet" - elif [[ "$OS_DISTRO" == "fedora" ]]; then - PACKAGE_LIST=" \ - doxygen \ - ctags \ - iperf3 \ + gnutls-devel \ xforms \ xforms-devel \ xmlstarlet" @@ -595,7 +589,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" @@ -614,7 +608,6 @@ check_install_oai_software() { liblapack-dev \ liblapacke-dev \ libreadline-dev \ - libgnutls28-dev \ libconfig-dev \ libsctp-dev \ libssl-dev \ @@ -645,7 +638,6 @@ check_install_oai_software() { pkgconfig \ libconfig-devel \ libffi-devel \ - libgcrypt-devel \ lksctp-tools \ lksctp-tools-devel \ libtool \ @@ -656,7 +648,6 @@ check_install_oai_software() { openssl-devel \ patch \ readline-devel \ - gnutls-devel \ lapack \ lapack-devel \ blas \ 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]);