]> wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - CMakeLists.txt
WIP: Made changes to be able to build gost-engine as static library. Added gost-engin...
[openssl-gost/engine.git] / CMakeLists.txt
index 4c069700e334a14526f36050097444044f44abcb..2af32486ff43b7dec27e6e77b3152e24e97429f8 100644 (file)
@@ -25,6 +25,7 @@ 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
@@ -65,6 +66,18 @@ if (ADDCARRY_U64)
   add_definitions(-DHAVE_ADDCARRY_U64)
 endif()
 
+check_c_source_runs("
+  int main(void) {
+    char buf[16] = { 0, 1, 2 };
+    int *p = (int *)(buf + 1);
+    int *q = (int *)(buf + 2);
+    return (*p == *q);
+  }
+  " RELAXED_ALIGNMENT)
+if (NOT RELAXED_ALIGNMENT)
+  add_definitions(-DSTRICT_ALIGNMENT)
+endif()
+
 set(BIN_DIRECTORY bin)
 
 # Same soversion as OpenSSL
@@ -125,16 +138,21 @@ set(GOST_CORE_SOURCE_FILES
         gost_crypt.c
         gost_ctl.c
         gost_eng.c
-        gost_keywrap.c
-        gost_keywrap.h
         gost_lcl.h
         gost_params.c
-        gost_keyexpimp.c
         )
 
 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
@@ -149,6 +167,9 @@ set(GOST_LIB_SOURCE_FILES
         ${GOST_GRASSHOPPER_SOURCE_FILES}
         ${GOST_EC_SOURCE_FILES}
         ${GOST_OMAC_SOURCE_FILES}
+        gost_keyexpimp.c
+        gost_keywrap.c
+        gost_keywrap.h
         )
 
 set(GOST_ENGINE_SOURCE_FILES
@@ -162,61 +183,67 @@ set(GOST_ENGINE_SOURCE_FILES
         )
 
 add_executable(test_digest test_digest.c)
-target_link_libraries(test_digest gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+target_link_libraries(test_digest gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} dl z pthread)
 add_test(NAME digest
        COMMAND test_digest)
 
 add_executable(test_curves test_curves.c)
-target_link_libraries(test_curves gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+target_link_libraries(test_curves gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} dl z pthread)
 add_test(NAME curves
        COMMAND test_curves)
 
 add_executable(test_params test_params.c)
-target_link_libraries(test_params gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+target_link_libraries(test_params gost_engine gost_core dl z pthread)
 add_test(NAME parameters
        COMMAND test_params)
 
 add_executable(test_sign test_sign.c)
-target_link_libraries(test_sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+target_link_libraries(test_sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} dl z pthread)
 add_test(NAME sign/verify
        COMMAND test_sign)
 
 add_executable(test_tls test_tls.c)
-target_link_libraries(test_tls gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})
+target_link_libraries(test_tls ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY} dl z pthread gost_engine gost_core)
 add_test(NAME TLS
        COMMAND test_tls)
 
 add_executable(test_context test_context.c)
-target_link_libraries(test_context gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+target_link_libraries(test_context gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} dl z pthread)
 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})
+target_link_libraries(test_grasshopper gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} dl z pthread)
 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})
+target_link_libraries(test_keyexpimp gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} dl z pthread)
 add_test(NAME keyexpimp
        COMMAND test_keyexpimp)
 
 add_executable(test_gost89 test_gost89.c)
-target_link_libraries(test_gost89 gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+target_link_libraries(test_gost89 gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} dl z pthread)
 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")
+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)
-target_link_libraries(sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${CLOCK_GETTIME_LIB})
+target_link_libraries(sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${CLOCK_GETTIME_LIB} dl z pthread)
 
 # All that may need to load just built engine will have path to it defined.
 set(BINARY_TESTS_TARGETS
@@ -240,12 +267,17 @@ set_target_properties(gost_engine PROPERTIES PREFIX "" OUTPUT_NAME "gost")
 set_target_properties(gost_engine PROPERTIES VERSION ${GOST_SOVERSION} SOVERSION ${GOST_SOVERSION})
 target_link_libraries(gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
 
+add_library(gost_engine_static STATIC ${GOST_ENGINE_SOURCE_FILES})
+set_target_properties(gost_engine_static PROPERTIES PREFIX "lib" PUBLIC_HEADER gost-engine.h OUTPUT_NAME "gost")
+target_link_libraries(gost_engine_static gost_core ${OPENSSL_CRYPTO_LIBRARY} dl pthread z)
+
+
 set(GOST_SUM_SOURCE_FILES
         gostsum.c
         )
 
 add_executable(gostsum ${GOST_SUM_SOURCE_FILES})
-target_link_libraries(gostsum gost_core ${OPENSSL_CRYPTO_LIBRARY})
+target_link_libraries(gostsum gost_core ${OPENSSL_CRYPTO_LIBRARY} dl z pthread)
 
 set(GOST_12_SUM_SOURCE_FILES
         gost12sum.c