diff --git a/CMakeLists.txt b/CMakeLists.txt index c4efa229d..c0e53cddc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,29 +168,17 @@ else(USE_MKL) endif(USE_MKL) # Crypto -find_package(Polarssl) -if (POLARSSL_FOUND) - set(SEC_INCLUDE_DIRS "${POLARSSL_INCLUDE_DIRS}") +find_package(MbedTLS REQUIRED) +if (MBEDTLS_FOUND) + set(SEC_INCLUDE_DIRS "${MBEDTLS_INCLUDE_DIRS}") if(BUILD_STATIC) - set(SEC_LIBRARIES "${POLARSSL_STATIC_LIBRARIES}") + set(SEC_LIBRARIES "${MBEDTLS_STATIC_LIBRARIES}") else(BUILD_STATIC) - set(SEC_LIBRARIES "${POLARSSL_LIBRARIES}") + set(SEC_LIBRARIES "${MBEDTLS_LIBRARIES}") endif(BUILD_STATIC) - add_definitions(-DHAVE_POLARSSL) -else(POLARSSL_FOUND) - find_package(MbedTLS REQUIRED) - if (MBEDTLS_FOUND) - set(SEC_INCLUDE_DIRS "${MBEDTLS_INCLUDE_DIRS}") - if(BUILD_STATIC) - set(SEC_LIBRARIES "${MBEDTLS_STATIC_LIBRARIES}") - else(BUILD_STATIC) - set(SEC_LIBRARIES "${MBEDTLS_LIBRARIES}") - endif(BUILD_STATIC) - add_definitions(-DHAVE_MBEDTLS) - else(MBEDTLS_FOUND) - message(FATAL_ERROR "Either PolarSSL or mbedTLS are required to build srsRAN") - endif (MBEDTLS_FOUND) -endif(POLARSSL_FOUND) +else(MBEDTLS_FOUND) + message(FATAL_ERROR "mbedTLS is required to build srsRAN") +endif (MBEDTLS_FOUND) # Hard-SIM support if(ENABLE_HARDSIM) diff --git a/cmake/modules/FindPolarssl.cmake b/cmake/modules/FindPolarssl.cmake deleted file mode 100644 index 54fa89aa1..000000000 --- a/cmake/modules/FindPolarssl.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# -# Copyright 2013-2021 Software Radio Systems Limited -# -# By using this file, you agree to the terms and conditions set -# forth in the LICENSE file which can be found at the top level of -# the distribution. -# - -# - Try to find polarssl -# -# Once done this will define -# POLARSSL_FOUND - System has polarssl -# POLARSSL_INCLUDE_DIRS - The polarssl include directories -# POLARSSL_LIBRARIES - The polarssl library - -FIND_PACKAGE(PkgConfig REQUIRED) -PKG_CHECK_MODULES(PC_POLARSSL polarssl) - -FIND_PATH( - POLARSSL_INCLUDE_DIRS - NAMES polarssl/version.h - HINTS $ENV{POLARSSL_DIR}/include - ${PC_POLARSSL_INCLUDEDIR} - ${CMAKE_INSTALL_PREFIX}/include - PATHS /usr/local/include - /usr/include -) - -FIND_LIBRARY( - POLARSSL_LIBRARIES - NAMES polarssl - HINTS $ENV{POLARSSL_DIR}/lib - ${PC_POLARSSL_LIBDIR} - ${CMAKE_INSTALL_PREFIX}/lib - ${CMAKE_INSTALL_PREFIX}/lib64 - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -FIND_LIBRARY( - POLARSSL_STATIC_LIBRARIES - NAMES libpolarssl.a - HINTS $ENV{POLARSSL_DIR}/lib - ${PC_POLARSSL_LIBDIR} - ${CMAKE_INSTALL_PREFIX}/lib - ${CMAKE_INSTALL_PREFIX}/lib64 - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -message(STATUS "POLARSSL LIBRARIES: " ${POLARSSL_LIBRARIES}) -message(STATUS "POLARSSL STATIC LIBRARIES: " ${POLARSSL_STATIC_LIBRARIES}) -message(STATUS "POLARSSL INCLUDE DIRS: " ${POLARSSL_INCLUDE_DIRS}) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Polarssl DEFAULT_MSG POLARSSL_LIBRARIES POLARSSL_INCLUDE_DIRS) -MARK_AS_ADVANCED(POLARSSL_STATIC_LIBRARIES POLARSSL_LIBRARIES POLARSSL_INCLUDE_DIRS) diff --git a/lib/include/srsran/common/ssl.h b/lib/include/srsran/common/ssl.h index 38b6e6b5a..1d167c068 100644 --- a/lib/include/srsran/common/ssl.h +++ b/lib/include/srsran/common/ssl.h @@ -13,25 +13,6 @@ #ifndef SRSRAN_SSL_H #define SRSRAN_SSL_H -#ifdef HAVE_POLARSSL - -#include "polarssl/aes.h" -#include "polarssl/sha256.h" - -inline void sha256(const unsigned char* key, - size_t keylen, - const unsigned char* input, - size_t ilen, - unsigned char output[32], - int is224) -{ - sha256_hmac(key, keylen, input, ilen, output, is224); -} - -#endif // HAVE_POLARSSL - -#ifdef HAVE_MBEDTLS - #include "mbedtls/aes.h" #include "mbedtls/md.h" @@ -71,6 +52,4 @@ inline void sha256(const unsigned char* key, mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), key, keylen, input, ilen, output); } -#endif // HAVE_MBEDTLS - #endif // SRSRAN_SSL_H diff --git a/lib/src/common/security.cc b/lib/src/common/security.cc index 82d7f0088..a37073e33 100644 --- a/lib/src/common/security.cc +++ b/lib/src/common/security.cc @@ -11,19 +11,13 @@ */ #include "srsran/common/security.h" +#include "mbedtls/md5.h" #include "srsran/common/liblte_security.h" #include "srsran/common/s3g.h" #include "srsran/common/ssl.h" #include "srsran/config.h" #include -#ifdef HAVE_MBEDTLS -#include "mbedtls/md5.h" -#endif -#ifdef HAVE_POLARSSL -#include "polarssl/md5.h" -#endif - #define FC_EPS_K_ASME_DERIVATION 0x10 #define FC_EPS_K_ENB_DERIVATION 0x11 #define FC_EPS_NH_DERIVATION 0x12 @@ -841,12 +835,7 @@ uint8_t security_128_eia3(const uint8_t* key, uint8_t security_md5(const uint8_t* input, size_t len, uint8_t* output) { memset(output, 0x00, 16); -#ifdef HAVE_MBEDTLS mbedtls_md5(input, len, output); -#endif // HAVE_MBEDTLS -#ifdef HAVE_POLARSSL - md5(input, len, output); -#endif return SRSRAN_SUCCESS; }