security: remove polarssl dependency

master
Robert Falkenberg 2 years ago
parent 57c986d54a
commit 44783030c4

@ -168,29 +168,17 @@ else(USE_MKL)
endif(USE_MKL) endif(USE_MKL)
# Crypto # Crypto
find_package(Polarssl) find_package(MbedTLS REQUIRED)
if (POLARSSL_FOUND) if (MBEDTLS_FOUND)
set(SEC_INCLUDE_DIRS "${POLARSSL_INCLUDE_DIRS}")
if(BUILD_STATIC)
set(SEC_LIBRARIES "${POLARSSL_STATIC_LIBRARIES}")
else(BUILD_STATIC)
set(SEC_LIBRARIES "${POLARSSL_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}") set(SEC_INCLUDE_DIRS "${MBEDTLS_INCLUDE_DIRS}")
if(BUILD_STATIC) if(BUILD_STATIC)
set(SEC_LIBRARIES "${MBEDTLS_STATIC_LIBRARIES}") set(SEC_LIBRARIES "${MBEDTLS_STATIC_LIBRARIES}")
else(BUILD_STATIC) else(BUILD_STATIC)
set(SEC_LIBRARIES "${MBEDTLS_LIBRARIES}") set(SEC_LIBRARIES "${MBEDTLS_LIBRARIES}")
endif(BUILD_STATIC) endif(BUILD_STATIC)
add_definitions(-DHAVE_MBEDTLS) else(MBEDTLS_FOUND)
else(MBEDTLS_FOUND) message(FATAL_ERROR "mbedTLS is required to build srsRAN")
message(FATAL_ERROR "Either PolarSSL or mbedTLS are required to build srsRAN") endif (MBEDTLS_FOUND)
endif (MBEDTLS_FOUND)
endif(POLARSSL_FOUND)
# Hard-SIM support # Hard-SIM support
if(ENABLE_HARDSIM) if(ENABLE_HARDSIM)

@ -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)

@ -13,25 +13,6 @@
#ifndef SRSRAN_SSL_H #ifndef SRSRAN_SSL_H
#define 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/aes.h"
#include "mbedtls/md.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); mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), key, keylen, input, ilen, output);
} }
#endif // HAVE_MBEDTLS
#endif // SRSRAN_SSL_H #endif // SRSRAN_SSL_H

@ -11,19 +11,13 @@
*/ */
#include "srsran/common/security.h" #include "srsran/common/security.h"
#include "mbedtls/md5.h"
#include "srsran/common/liblte_security.h" #include "srsran/common/liblte_security.h"
#include "srsran/common/s3g.h" #include "srsran/common/s3g.h"
#include "srsran/common/ssl.h" #include "srsran/common/ssl.h"
#include "srsran/config.h" #include "srsran/config.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#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_ASME_DERIVATION 0x10
#define FC_EPS_K_ENB_DERIVATION 0x11 #define FC_EPS_K_ENB_DERIVATION 0x11
#define FC_EPS_NH_DERIVATION 0x12 #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) uint8_t security_md5(const uint8_t* input, size_t len, uint8_t* output)
{ {
memset(output, 0x00, 16); memset(output, 0x00, 16);
#ifdef HAVE_MBEDTLS
mbedtls_md5(input, len, output); mbedtls_md5(input, len, output);
#endif // HAVE_MBEDTLS
#ifdef HAVE_POLARSSL
md5(input, len, output);
#endif
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }

Loading…
Cancel
Save