From 5830f921fa8fdce205b80e7e658fe27ce7ff9d75 Mon Sep 17 00:00:00 2001 From: gojimmypi Date: Tue, 19 Sep 2023 10:57:02 -0700 Subject: [PATCH] ARIA cipher cmake (#6600) * ARIA Cipher CMake support --- .gitignore | 4 + CMakeLists.txt | 81 +++++++++++++ INSTALL | 49 +++++++- cmake/README.md | 7 ++ cmake/functions.cmake | 18 ++- cmake/include.am | 2 + cmake/modules/FindARIA.cmake | 108 +++++++++++++++++ scripts/aria-cmake-build-test.sh | 201 +++++++++++++++++++++++++++++++ scripts/include.am | 3 +- 9 files changed, 467 insertions(+), 6 deletions(-) create mode 100644 cmake/README.md create mode 100644 cmake/modules/FindARIA.cmake create mode 100644 scripts/aria-cmake-build-test.sh diff --git a/.gitignore b/.gitignore index 3c526f6eb8..dd950c04cc 100644 --- a/.gitignore +++ b/.gitignore @@ -427,6 +427,10 @@ user_settings_asm.h # MagicCrypto (ARIA Cipher) MagicCrypto +# CMake build directory +/out +/out_temp + # debian packaging debian/changelog debian/control diff --git a/CMakeLists.txt b/CMakeLists.txt index c55da9222b..bbe4d2f1e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,17 @@ endif() project(wolfssl VERSION 5.6.3 LANGUAGES C ASM) +# Set WOLFSSL_ROOT if not already defined +if ("${WOLFSSL_ROOT}" STREQUAL "") + # we'll assume this CMakeLists.txt is in the root of wolfSSL + if (EXISTS "${CMAKE_SOURCE_DIR}/wolfcrypt/src/") + get_filename_component(WOLFSSL_ROOT "${CMAKE_SOURCE_DIR}" ABSOLUTE) + message(STATUS "Found WOLFSSL_ROOT = ${WOLFSSL_ROOT}") + endif() +else() + message(STATUS "Using predefined WOLFSSL_ROOT = ${WOLFSSL_ROOT}") +endif() + # shared library versioning # increment if interfaces have been added, removed or changed set(LIBTOOL_CURRENT 40) @@ -531,6 +542,11 @@ if(WOLFSSL_AESCTR AND NOT WOLFSSL_FORTRESS) "-DWOLFSSL_AES_DIRECT") endif() +# ARIA +add_option("WOLFSSL_ARIA" + "Enable wolfSSL ARIA support (default: disabled)" + "no" "yes;no") + # AES-CCM add_option("WOLFSSL_AESCCM" "Enable wolfSSL AES-CCM support (default: disabled)" @@ -1877,6 +1893,9 @@ if (WOLFSSL_CAAM) list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CAAM") endif() +if (WOLFSSL_ARIA) + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ARIA") +endif() # Generates the BUILD_* flags. These control what source files are included in # the library. A series of AM_CONDITIONALs handle this in configure.ac. @@ -2001,13 +2020,69 @@ set(LIB_SOURCES "") # in the *.am files. generate_lib_src_list("${LIB_SOURCES}") if(BUILD_SHARED_LIBS) + message(STATUS "BUILD_SHARED_LIBS enabled: ${LIB_SOURCES}") add_library(wolfssl SHARED ${LIB_SOURCES}) else() + message(STATUS "Static Libs: ${LIB_SOURCES}") add_library(wolfssl STATIC ${LIB_SOURCES}) endif() add_library(wolfssl::wolfssl ALIAS wolfssl) +if (NOT "$ENV{ARIA_DIR}" STREQUAL "") + message(STATUS "Found Environment variable ARIA_DIR=$ENV{ARIA_DIR}") + if(WOLFSSL_ARIA) + message(STATUS "wolfSSL WOLFSSL_ARIA is enabled") + else() + message(STATUS "wolfSSL WOLFSSL_ARIA is not enabled. To enable, specify a user_settings.h file or run: cmake .. -DWOLFSSL_ARIA=yes") + message(STATUS "Clear the ARIA_DIR environment variable to otherwise suppress this message when not using ARIA ciphers.") + endif() +endif() + +# ARIA Check +if(WOLFSSL_ARIA) + message(STATUS "WOLFSSL_ARIA is enabled") + + find_package(ARIA) + + if(ARIA_FOUND) + message(STATUS "ARIA find_package() success.") + else() + message(FATAL_ERROR "WOLFSSL_ARIA is enabled, but find_package() did not find ARIA MagicCrypto.\n" + "Check ARIA_DIR environment variable and/or copy MagicCrypto directory locally.") + endif() + + list(APPEND WOLFSSL_LINK_LIBS "${ARIA_LIB_FILE}") + + # The cmake target_include_directories() will complain about local directories, + # so we'll handle MagicCrypto differently when found in wolfssl. + # see below to use include_directories() instead. + if(ARIA_IS_LOCAL) + # there's also a wolfssl port API to include, plus local ARIA include + include_directories("wolfssl/wolfcrypt/port/aria" "MagicCrypto/include") + else() + # see below for target_include_directories() instead + include_directories("wolfssl/wolfcrypt/port/aria") + message(STATUS "ARIA_IS_LOCAL is false, appending ${ARIA_INCLUDE_DIR} to WOLFSSL_INCLUDE_DIRS") + list(APPEND WOLFSSL_INCLUDE_DIRS "${ARIA_INCLUDE_DIR}") + endif() + + add_library(MagicCrypto_lib + ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/src/port/aria/aria-crypt.c + ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/src/port/aria/aria-cryptocb.c + ) + + set_target_properties(MagicCrypto_lib PROPERTIES OUTPUT_NAME "MagicCrypto") + target_link_libraries(MagicCrypto_lib wolfssl) + target_compile_options(MagicCrypto_lib PRIVATE "-DHAVE_ARIA") + + # ARIA was enabled and we successfully found it. + set(HAVE_ARIA 1) + list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ARIA") + + message(STATUS "ARIA Check: WOLFSSL_LINK_LIBS = ${WOLFSSL_LINK_LIBS}") +endif() + set_target_properties(wolfssl PROPERTIES SOVERSION ${LIBTOOL_SO_VERSION} @@ -2024,6 +2099,12 @@ target_compile_definitions(wolfssl PUBLIC ${WOLFSSL_DEFINITIONS}) # Include Directories #################################################### +if("${WOLFSSL_INCLUDE_DIRS}" STREQUAL "") + message(STATUS "WOLFSSL_INCLUDE_DIRS is blank. No additional directories will be added.") +else() + message(STATUS "WOLFSSL_INCLUDE_DIRS = ${WOLFSSL_INCLUDE_DIRS}") +endif() + target_include_directories(wolfssl PUBLIC $ diff --git a/INSTALL b/INSTALL index 1ad6cde17d..e8f4c39be9 100644 --- a/INSTALL +++ b/INSTALL @@ -110,6 +110,53 @@ To build with debugging use: `cmake .. -DCMAKE_BUILD_TYPE=Debug`. + In the simplest form: + + # create a root directory for wolfssl repo + git clone https://github.com/wolfSSL/wolfssl.git + cd wolfssl + + + # From the root of the wolfSSL repo: + + mkdir -p out + pushd out + cmake .. + cmake --build . + + # View the available ciphers with: + ./examples/client/client -e + popd + + + ARIA Ciper Suite. + + The ARIA cipher needs a 3rd party source binary, typically called + `MagicCrypto.tar.gz`. + + The MagicCrypto files can be either copied to the local `wolfssl` directory, + or an environment variable `ARIA_DIR` can be set to point to the location. + + Simply having the environment variable or local `MagicCrypto` directory + will not automatically enable the ARIA Ciphers. + + To enable ARIA Ciphers in wolfSSL for `CMake`: + + # From the root of the wolfSSL repo: + + # set to your path + export ARIA_DIR=~/workspace/MagicCrypto + + mkdir -p out + pushd out + cmake .. -DWOLFSSL_ARIA=yes + cmake --build . + + # View the available ciphers with: + ./examples/client/client -e + popd + + Windows (Visual Studio) --- 1) Go to this page, download the appropriate Windows installer, and install @@ -132,7 +179,7 @@ Windows (command line) --- 1) Open Command Prompt - 2) Run the Visual Studio batch to setup command line variables, e.g. C:\Program Files (x86)\Microsoft Visual + 2) Run the Visual Studio batch to setup command line variables, e.g. C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat 3) Follow steps in "Unix-based Platforms" above. diff --git a/cmake/README.md b/cmake/README.md new file mode 100644 index 0000000000..f3d9a52699 --- /dev/null +++ b/cmake/README.md @@ -0,0 +1,7 @@ +# wolfSSL CMake + +This directory contains some supplementary functions for the [CMakeLists.txt](../CMakeLists.txt) in the root. + +See also cmake notes in the [INSTALL](../INSTALL) documentation file. + + diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 51c1e84108..47ab832653 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -199,6 +199,11 @@ function(generate_build_flags) set(BUILD_DILITHIUM "yes" PARENT_SCOPE) set(BUILD_EXT_KYBER "yes" PARENT_SCOPE) endif() + if(WOLFSSL_ARIA OR WOLFSSL_USER_SETTINGS) + message(STATUS "ARIA functions.cmake found WOLFSSL_ARIA") + # we cannot actually build, as we only have pre-compiled bin + set(BUILD_ARIA "yes" PARENT_SCOPE) + endif() set(BUILD_INLINE ${WOLFSSL_INLINE} PARENT_SCOPE) if(WOLFSSL_OCSP OR WOLFSSL_USER_SETTINGS) set(BUILD_OCSP "yes" PARENT_SCOPE) @@ -581,12 +586,17 @@ function(generate_lib_src_list LIB_SOURCES) wolfcrypt/src/wc_port.c wolfcrypt/src/error.c) + if(BUILD_ARIA) + list(APPEND LIB_SOURCES + wolfcrypt/src/port/aria/aria-crypt.c + wolfcrypt/src/port/aria/aria-cryptocb.c) + endif() if(NOT BUILD_FIPS_RAND) - list(APPEND LIB_SOURCES - wolfcrypt/src/wc_encrypt.c - wolfcrypt/src/signature.c - wolfcrypt/src/wolfmath.c) + list(APPEND LIB_SOURCES + wolfcrypt/src/wc_encrypt.c + wolfcrypt/src/signature.c + wolfcrypt/src/wolfmath.c) endif() if(BUILD_MEMORY) diff --git a/cmake/include.am b/cmake/include.am index 52ecdd0e23..f1af70fcde 100644 --- a/cmake/include.am +++ b/cmake/include.am @@ -1,4 +1,6 @@ +EXTRA_DIST += cmake/README.md EXTRA_DIST += cmake/Config.cmake.in EXTRA_DIST += cmake/config.in EXTRA_DIST += cmake/functions.cmake +EXTRA_DIST += cmake/modules/FindARIA.cmake EXTRA_DIST += cmake/modules/FindOQS.cmake diff --git a/cmake/modules/FindARIA.cmake b/cmake/modules/FindARIA.cmake new file mode 100644 index 0000000000..8348f4d10e --- /dev/null +++ b/cmake/modules/FindARIA.cmake @@ -0,0 +1,108 @@ +# Filename: FindARIA.cmake +# +# Usage: +# find_package(ARIA [REQUIRED] [QUIET]) +# +# Once complete this will define: +# ARIA_FOUND - system has ARIA MagicCrypto +# ARIA_INCLUDE_DIR - the include directory containing ARIA +# ARIA_LIBRARY - the path to the libARIA library +# ARIA_IS_LOCAL - optionally indicate the MagicCrypto is found locally in ./MagicCrypto + +set(ARIA_INCLUDE_DIR) +set(ARIA_LIB_FILE) +set(ARIA_IS_LOCAL) + +# when debugging cmake, ARIA_DIR environment variable can be manually set here: +# set(ENV{ARIA_DIR} "~/MagicCrypto") +# set(ENV{ARIA_DIR} "/mnt/c/workspace/MagicCrypto") +# set(ENV{ARIA_DIR} "c:\\workspace\\MagicCrypto") + +# Make sure we have a ARIA_DIR environment variable with the path to MagicCrypto +if ("$ENV{ARIA_DIR}" STREQUAL "") + message(STATUS "The ARIA_DIR environment variable is not defined. Looking for headers in wolfssl/MagicCrypto") + if (EXISTS "${WOLFSSL_ROOT}/MagicCrypto/") + set(ARIA_INCLUDE_DIR "${WOLFSSL_ROOT}/MagicCrypto/include") + message(STATUS "Found ARIA in local MagicCrypto directory ${ARIA_INCLUDE_DIR}") + set(ARIA_IS_LOCAL 1) + else() + message(ERROR "ERROR: FindARIA.cmake missing ARIA_DIR value") + message(STATUS "Please set ARIA_DIR environment variable path to your MagicCrypto or copy to wolfssl/MagicCrypto") + endif() +else() + # If an environment variable is defined, the library CANNOT be in the local wolfssl directory. + # See CMake documentation for target_include_directories() + set(ARIA_IS_LOCAL) + set(ARIA_INCLUDE_DIR "$ENV{ARIA_DIR}/include") + message(STATUS "FindARIA.cmake found ARIA_INCLUDE_DIR = $ENV{ARIA_DIR}") + + message(STATUS "Checking environment location: ${ARIA_INCLUDE_DIR} and wolfSSL: ${WOLFSSL_ROOT}") + get_filename_component(dir1 "${ARIA_INCLUDE_DIR}" REALPATH) + get_filename_component(dir2 "${WOLFSSL_ROOT}/MagicCrypto/include" REALPATH) + message(STATUS "Found location dir: ${dir1} and ${dir2}") + if("${dir1}" STREQUAL "${dir2}") + message(STATUS "${ARIA_INCLUDE_DIR} exists within ${WOLFSSL_ROOT}.") + message(STATUS "Setting ARIA_IS_LOCAL flag and using wolfSSL path.") + set(ARIA_IS_LOCAL 1) + set(ARIA_INCLUDE_DIR "${WOLFSSL_ROOT}/MagicCrypto/include") + else() + if(EXISTS "${ARIA_INCLUDE_DIR}") + message(STATUS "Confirmed directory exists: ${ARIA_INCLUDE_DIR}") + else() + message(FATAL_ERROR "Directory not found: ${ARIA_INCLUDE_DIR}") + endif() + + message(STATUS "Confirmed ${ARIA_INCLUDE_DIR} is not in local wolfSSL root.") + endif() +endif() + +# Check that the appropriate files exist +find_path(ARIA_INCLUDE_DIR NAMES "mcapi.h" ) + +if (NOT EXISTS "${ARIA_INCLUDE_DIR}/mcapi.h") + message(FATAL_ERROR "File does not exist at ${ARIA_INCLUDE_DIR}/mcapi.h") +endif() + +if(NOT EXISTS "${ARIA_INCLUDE_DIR}/mcapi_error.h") + message(FATAL_ERROR "File does not exist at ${ARIA_INCLUDE_DIR}/mcapi_error.h") +endif() + +if(NOT EXISTS "${ARIA_INCLUDE_DIR}/mcapi_type.h") + message(FATAL_ERROR "File does not exist at $ARIA_INCLUDE_DIR/mcapi_type.h") +endif() + +if(EXISTS "$ENV{ARIA_DIR}/lib/libMagicCrypto.so") + # Found ARIA binary via environment variable + set(ARIA_LIBRARY "MagicCrypto") + set(ARIA_LIB_FILE "$ENV{ARIA_DIR}/lib/libMagicCrypto.so") + message(STATUS "ARIA Check: found libMagicCrypto.so via environment variable.") + message(STATUS "Using ${ARIA_LIB_FILE}") +else() + # Did not find ARIA binary via environment variable, so let's look in the current wolfssl directory + if(EXISTS "${WOLFSSL_ROOT}/MagicCrypto/lib/libMagicCrypto.so") + # Found in the root of wolfssl, in ./MagicCrypto/lib + set(ARIA_LIBRARY "MagicCrypto") + set(ARIA_LIB_FILE "${WOLFSSL_ROOT}/MagicCrypto/lib/libMagicCrypto.so") + message(STATUS "ARIA Check: found libMagicCrypto.so via WOLFSSL_ROOT") + message(STATUS "Using ${ARIA_LIB_FILE}") + else() + # Could not find binary. Give up. + message(ERROR "ARIA Check: could not find libMagicCrypto.so via WOLFSSL_ROOT\n" + "Looked for ${WOLFSSL_ROOT}/MagicCrypto/lib/libMagicCrypto.so") + endif() +endif() + +mark_as_advanced(ARIA_INCLUDE_DIR ARIA_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ARIA DEFAULT_MSG ARIA_INCLUDE_DIR ARIA_LIBRARY) + +# Some additional optional debugging messages, set to (1) to enable +if(0) + message(STATUS "") + message(STATUS "ARIA Check: FindARIA.cmake") + message(STATUS "ARIA Check: ARIA_INCLUDE_DIR: ${ARIA_INCLUDE_DIR}") + message(STATUS "ARIA Check: ARIA_LIBRARY: ${ARIA_LIBRARY}") + message(STATUS "ARIA Check: ARIA_FOUND: ${ARIA_FOUND}") + message(STATUS "ARIA Check: CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}") +endif() diff --git a/scripts/aria-cmake-build-test.sh b/scripts/aria-cmake-build-test.sh new file mode 100644 index 0000000000..f919739c56 --- /dev/null +++ b/scripts/aria-cmake-build-test.sh @@ -0,0 +1,201 @@ +#!/bin/bash +# +# aria_cmake_build_test.sh +# +# This is a test script for building wolfSSL exaples with various settings +# for the ARIA Magic Crypto ciphers. +# +# See https://github.com/wolfSSL/wolfssl/pull/6400 and +# https://github.com/wolfSSL/wolfssl/pull/6600 +# +# The basic steps for building: +# +# # set to your path +# export ARIA_DIR=/mnt/c/workspace/MagicCrypto +# +# mkdir -p out +# pushd out +# cmake .. -DWOLFSSL_ARIA=yes +# cmake --build . +# +# # View the available ciphers with: +# ./examples/client/client -e +# +# or with grep: +# ./examples/client/client -e | grep -i ARIA +# +# Note the OPENSSL_EXTRA and WOLF_CRYPTOCB macros may need to be defined +# in certain circumstances. The LD_LIBRARY_PATH=$ARIA_DIR may also be needed. +# + +export ARIA_BUILD_DIR=./out_temp + +export ARIA_ERROR_RM_FAIL=1 +export ARIA_ERROR_MKDIR_FAIL=2 +export ARIA_ERROR_CMAKE_FAIL=3 +export ARIA_ERROR_BUILD_FAIL=4 +export ARIA_ERROR_CLIENT_FAIL=5 +export ARIA_ERROR_CIPHER_FAIL=6 +export ARIA_ERROR_CONFIG_FAIL=7 + +# +# function build_aria_test() +# +build_aria_test() { + local EXPECTED_ERROR=$1 # First parameter; 0, 1, 2, etc + local EXPECTED_ARIA=$2 # Second parameter: typically "Y" or "N" + local BUILD_MESSAGE=$3 # Third parameter; "some message" + local BUILD_DIR=$4 # Fourth parameter: "./someDirectory" + local BUILD_OPTION=$5 # Fifth parameter. Optional: "" + + echo "********************************************************************" + echo "Starting $BUILD_MESSAGE" + echo "********************************************************************" + if [[ -z "$BUILD_DIR" ]]; then + local BUILD_DIR=out + fi + + echo "BUILD_DIR=$BUILD_DIR" + echo "BUILD_OPTION=$BUILD_OPTION" + + # remove build directory + rm -rf $BUILD_DIR + if [ $? -eq 0 ]; then + echo "$BUILD_DIR removed." + else + echo "Failed to remove directory." + return $ARIA_ERROR_RM_FAIL + fi + + # create a fresh directory + mkdir -p $BUILD_DIR + if [ $? -eq 0 ]; then + echo "$BUILD_DIR created." + else + echo "Failed to create directory $BUILD_DIR" + return $ARIA_ERROR_MKDIR_FAIL + fi + + # change into build directory + pushd $BUILD_DIR + + # initial cmake + echo "********************************************************************" + echo "CMake for $BUILD_MESSAGE" + if [ -z "$BUILD_OPTION" ]; then + echo "(No additional build options)" + else + echo "Using build option: $BUILD_OPTION" + fi + echo "********************************************************************" + cmake .. $BUILD_OPTION + if [ $? -eq 0 ]; then + echo "cmake successful." + else + echo "ERROR: cmake failed" + return $ARIA_ERROR_CMAKE_FAIL + fi + + # build + echo "********************************************************************" + echo "Build for $BUILD_MESSAGE" + if [ -z "$BUILD_OPTION" ]; then + echo "(No additional build options)" + else + echo "Using build option: $BUILD_OPTION" + fi + echo "********************************************************************" + cmake --build . + if [ $? -eq 0 ]; then + echo "cmake build successful." + else + echo "ERROR: cmake build failed" + return $ARIA_ERROR_BUILD_FAIL + fi + + # View the available ciphers with: + echo "checking wolfsl client ssl version numbers SSLv3(0) - TLS1.3(4):" + ./examples/client/client -V + if [ $? -eq 0 ]; then + echo "Confirmed ./examples/client/client operational." + else + echo "ERROR ./examples/client/client error = $?" + return $ARIA_ERROR_CLIENT_FAIL + fi + + # now see if we have ARIA ciphers + if ./examples/client/client -e | awk '/ARIA/{found=1} END{exit !found}'; then + if [ "$EXPECTED_ARIA" == "Y" ]; then + echo "Found ARIA ciphers as expected." + else + echo "ERROR: Found ARIA ciphers when NOT expected." + return $ARIA_ERROR_CIPHER_FAIL + fi + else + if [ "$EXPECTED_ARIA" == "N" ]; then + echo "No ARIA ciphers found as expected with ./examples/client/client -e" + else + echo "ERROR: No ARIA ciphers found, EXPECTED_ARIA parameter = \"$EXPECTED_ARIA\"; expected \"N\"." + return $ARIA_ERROR_CONFIG_FAIL + fi + fi + ./examples/client/client -e + + echo "Return to working directory." + popd + + echo "********************************************************************" + echo "Completed $BUILD_MESSAGE" + echo "********************************************************************" + echo "" +} + +set -e + +# No ARIA Environment Variable +export ARIA_DIR= +export THIS_MESSAGE="No ARIA Environment Variable, ARIA not enabled." +build_aria_test 0 N "$THIS_MESSAGE" "$ARIA_BUILD_DIR" + +export ARIA_DIR= +export THIS_MESSAGE="No ARIA Environment Variable, ARIA Enabled" +build_aria_test 0 Y "$THIS_MESSAGE" "$ARIA_BUILD_DIR" "-DWOLFSSL_ARIA=yes" + +# ARIA Environment Variable with MagicCrypto in local user directory +export ARIA_DIR=~/MagicCrypto +export THIS_MESSAGE="ARIA Environment Variable with MagicCrypto in local user directory, ARIA not enabled." +build_aria_test 0 N "$THIS_MESSAGE" "$ARIA_BUILD_DIR" + +export ARIA_DIR=~/MagicCrypto +export THIS_MESSAGE="ARIA Environment Variable with MagicCrypto in local user directory, ARIA Enabled" +build_aria_test 0 Y "$THIS_MESSAGE" "$ARIA_BUILD_DIR" "-DWOLFSSL_ARIA=yes" + +# ARIA Environment Variable with MagicCrypto in wolfssl directory +export ARIA_DIR=~/MagicCrypto +export THIS_MESSAGE="ARIA Environment Variable with MagicCrypto in wolfssl directory, ARIA not enabled." +build_aria_test 0 N "$THIS_MESSAGE" "$ARIA_BUILD_DIR" + +export ARIA_DIR=./MagicCrypto +export THIS_MESSAGE="ARIA Environment Variable with MagicCrypto in wolfssl, ARIA Enabled" +build_aria_test 0 Y "$THIS_MESSAGE" "$ARIA_BUILD_DIR" "-DWOLFSSL_ARIA=yes" + +# ARIA Environment Variable with bad directory, ARIA not enabled so bad directory ignored +export ARIA_DIR=./UnknownDirectory +export THIS_MESSAGE="ARIA Environment Variable with bad directory, ARIA not enabled." +build_aria_test 0 N "$THIS_MESSAGE" "$ARIA_BUILD_DIR" + +# ARIA Environment Variable with bad directory, ARIA enabled so bad directory should fail +set +e +export ARIA_DIR=./UnknownDirectory +export THIS_MESSAGE="ARIA Environment Variable with bad directory, ARIA Enabled" +build_aria_test $ARIA_ERROR_CMAKE_FAIL N "$THIS_MESSAGE" "$ARIA_BUILD_DIR" "-DWOLFSSL_ARIA=yes" +if [ $? -eq $ARIA_ERROR_CMAKE_FAIL ]; then + echo "Properly detected bad directory and failed as expected." +else + echo "Error: expected failure not detected." + exit 1 +fi + +echo "Done. aria_cmake_build_test completed successfully!" + +exit 0 diff --git a/scripts/include.am b/scripts/include.am index 2ee03e41c5..eab99c611e 100644 --- a/scripts/include.am +++ b/scripts/include.am @@ -103,7 +103,8 @@ EXTRA_DIST += scripts/sniffer-static-rsa.pcap \ scripts/benchmark.test \ scripts/memtest.sh \ scripts/makedistsmall.sh \ - scripts/openssl_srtp.test + scripts/openssl_srtp.test \ + scripts/aria-cmake-build-test.sh # leave openssl.test as extra until non bash works