Commit fcb3de6b authored by Cedric Roux's avatar Cedric Roux

Merge branch 'develop' into feature-15-carrier_aggregation

parents 25bdc142 3e41d992
......@@ -146,8 +146,16 @@ else (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -mssse3")
endif()
endif()
set(C_FLAGS_PROCESSOR " ${C_FLAGS_PROCESSOR} ${CFLAGS_PROCESSOR_USER}")
Message("C_FLAGS_PROCESSOR is ${C_FLAGS_PROCESSOR}")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86")
if ( (NOT( C_FLAGS_PROCESSOR MATCHES "ssse3")) OR (NOT( C_FLAGS_PROCESSOR MATCHES "msse4.1")) OR (NOT( C_FLAGS_PROCESSOR MATCHES "msse4.2")) )
Message(FATAL_ERROR "For x86 Architecture, you must have following flags: -mssse3 -msse4.1 -msse4.2. The current detected flags are: ${C_FLAGS_PROCESSOR}. You can pass the flags manually in build script, for example: ./build_oai --cflags_processor \"-mssse3 -msse4.1 -msse4.2\" ")
endif()
endif()
#
set(CMAKE_C_FLAGS
......@@ -1644,7 +1652,7 @@ foreach(myExe s1ap
${OPENAIR3_DIR}/TEST/test_${myExe}.c
)
target_link_libraries (test_${myExe}
-Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} fdproto fdcore
-Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES}
)
endforeach(myExe)
......
......@@ -49,6 +49,7 @@ REL="Rel10"
HW="EXMIMO"
EPC=0
VERBOSE_COMPILE=0
CFLAGS_PROCESSOR_USER=""
function print_help() {
echo_info '
......@@ -105,6 +106,9 @@ Options
Compiles oaisim or lte-softmodem without S1 interface, using direct link to IP instead
--verbose-compile
Shows detailed compilation instructions in makefile
--cflags_processor
Manually Add CFLAGS of processor if they are not detected correctly by script. Only add these flags if you know your processor supports them. Example flags: -msse3 -msse4.1 -msse4.2 -mavx2
Usage (first build):
oaisim (eNB + UE): ./build_oai -I -g --oaisim -x --install-system-files
Eurecom EXMIMO + COTS UE : ./build_oai -I -g --eNB --EPC -x --install-system-files
......@@ -211,6 +215,10 @@ function main() {
VERBOSE_COMPILE=1
echo_info "Will compile with verbose instructions"
shift;;
--cflags_processor)
CFLAGS_PROCESSOR_USER=$2
echo_info "setting CPU FLAGS from USER to: $CFLAGS_PROCESSOR_USER"
shift 2;;
-h | --help)
print_help
exit 1;;
......@@ -254,8 +262,6 @@ function main() {
if [ "$INSTALL_EXTERNAL" = "1" ] ; then
echo_info "Installing packages"
check_install_oai_software
echo_info "Making X.509 certificates"
make_certs eur
if [ "$HW" == "OAI_USRP" ] ; then
echo_info "installing packages for USRP support"
check_install_usrp_uhd_driver
......@@ -264,7 +270,6 @@ function main() {
echo_info "installing packages for BALDERF support"
check_install_bladerf_driver
fi
fi
if [ "$INSTALL_OPTIONAL" = "1" ] ; then
......@@ -304,6 +309,7 @@ function main() {
if [ "$NOS1" = "1" ] ; then
cat $DIR/$lte_build_dir/CMakeLists.template >> $cmake_file
fi
echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file
echo "set ( XFORMS $XFORMS )" >> $cmake_file
echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file
echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file
......@@ -432,6 +438,7 @@ function main() {
echo_info "Compiling $oaisim_exec ($oaisim_build_dir)"
cmake_file=$DIR/$oaisim_build_dir/CMakeLists.txt
cp $DIR/$oaisim_build_dir/CMakeLists.template $cmake_file
echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file
echo "set ( XFORMS $XFORMS )" >> $cmake_file
echo "set ( PRINT_STATS $PRINT_STATS )" >> $cmake_file
echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file
......
......@@ -262,7 +262,6 @@ check_install_oai_software() {
else
$SUDO apt-get install -y libgnutls-dev nettle-dev nettle-bin
fi
install_freediameter_from_source
install_asn1c_from_source
}
......@@ -311,13 +310,11 @@ set_openair_env(){
[ -f "/.$fullpath" ] || fullpath=`readlink -f $PWD/$fullpath`
openair_path=${fullpath%/cmake_targets/*}
openair_path=${openair_path%/targets/*}
openair_path=${openair_path%/openair3/*}
openair_path=${openair_path%/openair[123]/*}
export OPENAIR_DIR=$openair_path
export OPENAIR1_DIR=$openair_path/openair1
export OPENAIR2_DIR=$openair_path/openair2
export OPENAIR3_DIR=$openair_path/openair3
export OPENAIR3_DIR=$openair_path/openair3
export OPENAIR_TARGETS=$openair_path/targets
}
......@@ -42,9 +42,9 @@ static
void do_kdf(uint8_t *key, unsigned key_length, uint8_t *data, unsigned data_length,
uint8_t *exp, unsigned exp_length)
{
uint8_t *result;
uint8_t result[32];
kdf(key, key_length, data, data_length, &result, 32);
kdf(key, key_length, data, data_length, result, 32);
if (compare_buffer(result, exp_length, exp, exp_length) != 0) {
fail("Fail: kdf\n");
......
......@@ -39,15 +39,15 @@ static
void do_derive_kenb(uint32_t nas_count, const uint8_t *kasme, const unsigned length,
const uint8_t *kenb_exp)
{
uint8_t *kenb;
uint8_t kenb[32];
derive_keNB(kasme, nas_count, &kenb);
memset(kenb, 0, sizeof(kenb));
derive_keNB(kasme, nas_count, kenb);
if (compare_buffer(kenb_exp, length, kenb, length) != 0) {
fail("Fail: kenb derivation\n");
}
free(kenb);
}
void doit (void)
......
......@@ -39,21 +39,23 @@ static
void derive_knas_keys(algorithm_type_dist_t atd, uint8_t *kasme, unsigned length,
uint8_t *knas_enc_exp, uint8_t *knas_int_exp)
{
uint8_t *knas_enc;
uint8_t *knas_int;
uint8_t *knas_enc = NULL;
uint8_t *knas_int = NULL;
derive_key_nas_enc(atd, kasme, &knas_enc);
derive_key_nas_int(atd, kasme, &knas_int);
knas_enc = calloc(1, 32);
knas_int = calloc(1, 32);
derive_key_nas_enc(atd, kasme, knas_enc);
derive_key_nas_int(atd, kasme, knas_int);
/* Compare both keys with expected */
if (compare_buffer(knas_enc, 32, knas_enc_exp, 32) != 0) {
if (compare_buffer(knas_enc, 16, &knas_enc_exp[16], 16) != 0) {
fail("Fail: knas_enc derivation\n");
}
if (compare_buffer(knas_int, 32, knas_int_exp, 32) != 0) {
if (compare_buffer(knas_int, 16, &knas_int_exp[16], 16) != 0) {
fail("Fail: knas_int derivation\n");
}
free(knas_enc);
free(knas_int);
}
......
......@@ -40,14 +40,15 @@ void eea1_encrypt(uint8_t direction, uint32_t count,
uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
uint32_t length, uint8_t *expected)
{
nas_stream_cipher_t *nas_cipher;
uint8_t *result;
nas_stream_cipher_t *nas_cipher = NULL;
uint8_t *result = NULL;
uint32_t zero_bits = length & 7;
uint32_t byte_length = length >> 3;
if (zero_bits > 0)
byte_length += 1;
result = calloc(1, byte_length);
nas_cipher = calloc(1, sizeof(nas_stream_cipher_t));
nas_cipher->direction = direction;
......@@ -58,7 +59,7 @@ void eea1_encrypt(uint8_t direction, uint32_t count,
nas_cipher->blength = length;
nas_cipher->message = message;
if (nas_stream_encrypt_eea1(nas_cipher, &result) != 0)
if (nas_stream_encrypt_eea1(nas_cipher, result) != 0)
fail("Fail: nas_stream_encrypt_eea1\n");
if (compare_buffer(result, byte_length, expected, byte_length) != 0) {
......
......@@ -40,14 +40,15 @@ void eea2_encrypt(uint8_t direction, uint32_t count,
uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
uint32_t length, uint8_t *expected)
{
nas_stream_cipher_t *nas_cipher;
uint8_t *result;
nas_stream_cipher_t *nas_cipher = NULL;
uint8_t *result = NULL;
uint32_t zero_bits = length & 7;
uint32_t byte_length = length >> 3;
if (zero_bits > 0)
byte_length += 1;
result = calloc(1, byte_length);
nas_cipher = calloc(1, sizeof(nas_stream_cipher_t));
nas_cipher->direction = direction;
......@@ -58,7 +59,7 @@ void eea2_encrypt(uint8_t direction, uint32_t count,
nas_cipher->blength = length;
nas_cipher->message = message;
if (nas_stream_encrypt_eea2(nas_cipher, &result) != 0)
if (nas_stream_encrypt_eea2(nas_cipher, result) != 0)
fail("Fail: nas_stream_encrypt_eea2\n");
if (compare_buffer(result, byte_length, expected, byte_length) != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment