]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - CMakeLists.txt
Delete .travis.yml
[openssl-gost/engine.git] / CMakeLists.txt
index ea6920e7af2528ae0fa115f7b974c5761cebe158..a83d19ddfd139c57b6a1765afe740fad07f0e765 100644 (file)
@@ -4,6 +4,7 @@ project(gost-engine LANGUAGES C)
 include(GNUInstallDirs)
 include(CheckLibraryExists)
 include(CheckFunctionExists)
+include(CheckCSourceRuns)
 
 enable_testing()
 
@@ -11,9 +12,9 @@ find_package(OpenSSL 1.1.1 REQUIRED)
 include_directories(${OPENSSL_INCLUDE_DIR})
 
 if (CMAKE_C_COMPILER_ID MATCHES "Clang")
- add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb -Qunused-arguments)
+ add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -Qunused-arguments -Wno-deprecated-declarations)
 elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
- add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb)
+ add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -Wno-error=unknown-pragmas -Wno-deprecated-declarations)
 elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS)
@@ -21,9 +22,16 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
  add_compile_options(/MP /WX /W4 /wd4100 /wd4267 /wd4206 /wd4706 /wd4244 /wd4115)
 endif()
 
+string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type)
+if (build_type STREQUAL debug)
+ message(STATUS "Debug build")
+ add_compile_options(-ggdb)
+endif()
+
 if (ASAN)
   message(STATUS "address sanitizer enabled")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g3 -fno-omit-frame-pointer")
+  set(SKIP_PERL_TESTS 1)
 endif()
 
 # DEPRECATEDIN_3_0 CMAC
@@ -47,6 +55,35 @@ else()
  add_definitions(-DL_ENDIAN)
 endif()
 
+check_c_source_runs("
+  #ifdef _MSC_VER
+  # include <intrin.h>
+  #else
+  # include <x86intrin.h>
+  #endif
+  int main(void) {
+    unsigned long long x = -1, y = 1, r;
+    unsigned char cf;
+    cf = _addcarry_u64(1, x, y, &r);
+    return !(cf == 1 && r == 1);
+  }
+  " ADDCARRY_U64)
+if (ADDCARRY_U64)
+  add_definitions(-DHAVE_ADDCARRY_U64)
+endif()
+
+check_c_source_runs("
+  int main(void) {
+    char buf[16] = { 0, 1, 2 };
+    int *p = buf + 1;
+    int *q = buf + 2;
+    return (*p == *q);
+  }
+  " RELAXED_ALIGNMENT)
+if (NOT RELAXED_ALIGNMENT)
+  add_definitions(-DSTRICT_ALIGNMENT)
+endif()
+
 set(BIN_DIRECTORY bin)
 
 # Same soversion as OpenSSL
@@ -117,6 +154,14 @@ set(GOST_CORE_SOURCE_FILES
 set(GOST_EC_SOURCE_FILES
         gost_ec_keyx.c
         gost_ec_sign.c
+        ecp_id_GostR3410_2001_CryptoPro_A_ParamSet.c
+        ecp_id_GostR3410_2001_CryptoPro_B_ParamSet.c
+        ecp_id_GostR3410_2001_CryptoPro_C_ParamSet.c
+        ecp_id_GostR3410_2001_TestParamSet.c
+        ecp_id_tc26_gost_3410_2012_256_paramSetA.c
+        ecp_id_tc26_gost_3410_2012_512_paramSetA.c
+        ecp_id_tc26_gost_3410_2012_512_paramSetB.c
+        ecp_id_tc26_gost_3410_2012_512_paramSetC.c
         )
 
 set (GOST_OMAC_SOURCE_FILES
@@ -141,6 +186,7 @@ set(GOST_ENGINE_SOURCE_FILES
         gost_pmeth.c
         gost_omac.c
         gost_omac_acpkm.c
+        gost_gost2015.c
         )
 
 add_executable(test_digest test_digest.c)
@@ -148,6 +194,11 @@ target_link_libraries(test_digest gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY
 add_test(NAME digest
        COMMAND test_digest)
 
+add_executable(test_ciphers test_ciphers.c)
+target_link_libraries(test_ciphers gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME ciphers
+       COMMAND test_ciphers)
+
 add_executable(test_curves test_curves.c)
 target_link_libraries(test_curves gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
 add_test(NAME curves
@@ -158,6 +209,11 @@ target_link_libraries(test_params gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY
 add_test(NAME parameters
        COMMAND test_params)
 
+add_executable(test_derive test_derive.c)
+target_link_libraries(test_derive gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME derive
+       COMMAND test_derive)
+
 add_executable(test_sign test_sign.c)
 target_link_libraries(test_sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
 add_test(NAME sign/verify
@@ -173,11 +229,6 @@ target_link_libraries(test_context gost_engine gost_core ${OPENSSL_CRYPTO_LIBRAR
 add_test(NAME context
        COMMAND test_context)
 
-add_executable(test_grasshopper test_grasshopper.c)
-target_link_libraries(test_grasshopper gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
-add_test(NAME grasshopper
-       COMMAND test_grasshopper)
-
 add_executable(test_keyexpimp test_keyexpimp.c)
 #target_compile_definitions(test_keyexpimp PUBLIC -DOPENSSL_LOAD_CONF)
 target_link_libraries(test_keyexpimp gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
@@ -189,12 +240,23 @@ target_link_libraries(test_gost89 gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY
 add_test(NAME gost89
        COMMAND test_gost89)
 
-if(NOT ASAN)
-add_test(NAME engine
-       COMMAND perl run_tests
-       WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
-set_tests_properties(engine PROPERTIES ENVIRONMENT
-       "OPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR};OPENSSL_ENGINES=${OUTPUT_DIRECTORY};OPENSSL_CONF=${CMAKE_SOURCE_DIR}/test/empty.cnf")
+add_executable(test_mgm test_mgm.c)
+target_link_libraries(test_mgm gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME mgm
+        COMMAND test_mgm)
+
+if(NOT SKIP_PERL_TESTS)
+    execute_process(COMMAND perl -MTest2::V0 -e ""
+       ERROR_QUIET RESULT_VARIABLE HAVE_TEST2_V0)
+    if(NOT HAVE_TEST2_V0)
+       add_test(NAME engine
+           COMMAND perl run_tests
+           WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
+       set_tests_properties(engine PROPERTIES ENVIRONMENT
+           "OPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR};OPENSSL_ENGINES=${OUTPUT_DIRECTORY};OPENSSL_CONF=${CMAKE_SOURCE_DIR}/test/empty.cnf")
+    else()
+      message(STATUS "No Test2::V0 perl module (engine tests skipped)")
+    endif()
 endif()
 
 add_executable(sign benchmark/sign.c)
@@ -203,14 +265,16 @@ target_link_libraries(sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${CLO
 # All that may need to load just built engine will have path to it defined.
 set(BINARY_TESTS_TARGETS
         test_digest
+        test_ciphers
         test_curves
         test_params
+        test_derive
         test_sign
         test_context
-        test_grasshopper
         test_keyexpimp
         test_gost89
        test_tls
+        test_mgm
         )
 set_property(TARGET ${BINARY_TESTS_TARGETS} APPEND PROPERTY COMPILE_DEFINITIONS ENGINE_DIR="${OUTPUT_DIRECTORY}")
 
@@ -227,7 +291,7 @@ set(GOST_SUM_SOURCE_FILES
         )
 
 add_executable(gostsum ${GOST_SUM_SOURCE_FILES})
-target_link_libraries(gostsum gost_core)
+target_link_libraries(gostsum gost_core ${OPENSSL_CRYPTO_LIBRARY})
 
 set(GOST_12_SUM_SOURCE_FILES
         gost12sum.c