]> wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - CMakeLists.txt
Merge branch 'master' of https://github.com/gost-engine/engine
[openssl-gost/engine.git] / CMakeLists.txt
index 76a7d7972cebb4b4c1a68e3c31dc34d049a2c38b..26d2a406d35af488e2d46fc2be36755f78580068 100644 (file)
@@ -5,7 +5,7 @@ include(GNUInstallDirs)
 
 enable_testing()
 
-find_package(OpenSSL 1.0.2 REQUIRED)
+find_package(OpenSSL 1.1.1 REQUIRED)
 include_directories(${OPENSSL_INCLUDE_DIR})
 
 if (CMAKE_C_COMPILER_ID MATCHES "Clang")
@@ -32,12 +32,22 @@ endif()
 
 set(BIN_DIRECTORY bin)
 
-set(OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/${BIN_DIRECTORY})
+set(OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BIN_DIRECTORY})
 
 #set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
 
+# Remove when https://gitlab.kitware.com/cmake/cmake/issues/18525 is addressed
+set(OPENSSL_ENGINES_DIR "" CACHE PATH "OpenSSL Engines Directory")
+if ("${OPENSSL_ENGINES_DIR}" STREQUAL "")
+       include(FindPkgConfig)
+       pkg_get_variable(OPENSSL_ENGINES_DIR libcrypto enginesdir)
+       if ("${OPENSSL_ENGINES_DIR}" STREQUAL "")
+               message( FATAL_ERROR "Unable to discover the OpenSSL engines directory. Provide the path using -DOPENSSL_ENGINES_DIR" )
+       endif()
+endif()
+
 set(GOST_89_SOURCE_FILES
         gost89.c
         gost89.h
@@ -68,8 +78,6 @@ set(GOST_GRASSHOPPER_SOURCE_FILES
         gost_grasshopper_precompiled.c
         gost_grasshopper_cipher.h
         gost_grasshopper_cipher.c
-        gost_grasshopper_mac.h
-        gost_grasshopper_mac.c
         )
 
 set(GOST_CORE_SOURCE_FILES
@@ -83,6 +91,7 @@ set(GOST_CORE_SOURCE_FILES
         gost_keywrap.h
         gost_lcl.h
         gost_params.c
+        gost_keyexpimp.c
         )
 
 set(GOST_EC_SOURCE_FILES
@@ -92,6 +101,7 @@ set(GOST_EC_SOURCE_FILES
 
 set (GOST_OMAC_SOURCE_FILES
         gost_omac.c
+        gost_omac_acpkm.c
         )
 
 set(GOST_LIB_SOURCE_FILES
@@ -110,13 +120,29 @@ set(GOST_ENGINE_SOURCE_FILES
         gost_md2012.c
         gost_pmeth.c
         gost_omac.c
+        gost_omac_acpkm.c
         )
 
+add_executable(test_curves test_curves.c)
+target_link_libraries(test_curves gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME curves
+       COMMAND test_curves)
+
+add_executable(test_context test_context.c)
+target_link_libraries(test_context gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+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_test(NAME engine
+        COMMAND perl run_tests
+        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
+set_tests_properties(engine PROPERTIES ENVIRONMENT OPENSSL_ENGINES=${OUTPUT_DIRECTORY})
+
 add_library(gost_core STATIC ${GOST_LIB_SOURCE_FILES})
 set_target_properties(gost_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
 
@@ -138,20 +164,24 @@ set(GOST_12_SUM_SOURCE_FILES
 add_executable(gost12sum ${GOST_12_SUM_SOURCE_FILES})
 target_link_libraries(gost12sum gost_core)
 
+add_executable(unit_expimp gost_keyexpimp.c e_gost_err.c)
+target_compile_definitions(unit_expimp PUBLIC -DENABLE_UNIT_TESTS)
+target_compile_definitions(unit_expimp PUBLIC -DOPENSSL_LOAD_CONF)
+target_link_libraries(unit_expimp PUBLIC ${OPENSSL_CRYPTO_LIBRARY})
+
 set_source_files_properties(tags PROPERTIES GENERATED true)
 add_custom_target(tags
     COMMAND ctags -R . ${OPENSSL_ROOT_DIR}
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
 # install
-set(OPENSSL_ENGINES_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/engines-${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR})
 set(OPENSSL_MAN_INSTALL_DIR ${CMAKE_INSTALL_MANDIR}/man1)
 
 install(TARGETS gost_engine gostsum gost12sum EXPORT GostEngineConfig
-        LIBRARY  DESTINATION ${OPENSSL_ENGINES_INSTALL_DIR}
+        LIBRARY  DESTINATION ${OPENSSL_ENGINES_DIR}
         RUNTIME  DESTINATION ${CMAKE_INSTALL_BINDIR})
 install(FILES gostsum.1 gost12sum.1 DESTINATION ${OPENSSL_MAN_INSTALL_DIR})
 if (MSVC)
- install(FILES $<TARGET_PDB_FILE:gost_engine> DESTINATION ${OPENSSL_ENGINES_INSTALL_DIR} OPTIONAL)
+ install(FILES $<TARGET_PDB_FILE:gost_engine> DESTINATION ${OPENSSL_ENGINES_DIR} OPTIONAL)
  install(FILES $<TARGET_PDB_FILE:gostsum> $<TARGET_PDB_FILE:gost12sum> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
 endif()