blob: f24f26c1d26f94e78131ae7c1eb9f8908c25ba1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(gost-engine LANGUAGES C)
include(GNUInstallDirs)
enable_testing()
find_package(OpenSSL 1.1.1 REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Qunused-arguments)
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb)
elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
add_compile_options(/MP /WX /W4 /wd4100 /wd4267 /wd4206 /wd4706 /wd4244 /wd4115)
endif()
set(CMAKE_C_STANDARD 90)
include (TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
message(STATUS "BIG_ENDIAN")
else()
message(STATUS "LITTLE_ENDIAN")
add_definitions(-DL_ENDIAN)
endif()
set(BIN_DIRECTORY bin)
set(OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/${BIN_DIRECTORY})
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
set(GOST_89_SOURCE_FILES
gost89.c
gost89.h
)
set(GOST_HASH_SOURCE_FILES
gosthash.c
gosthash.h
)
set(GOST_HASH_2012_SOURCE_FILES
gosthash2012.c
gosthash2012.h
gosthash2012_const.h
gosthash2012_precalc.h
gosthash2012_ref.h
gosthash2012_sse2.h
)
set(GOST_GRASSHOPPER_SOURCE_FILES
gost_grasshopper.h
gost_grasshopper_core.h
gost_grasshopper_core.c
gost_grasshopper_defines.h
gost_grasshopper_defines.c
gost_grasshopper_math.h
gost_grasshopper_galois_precompiled.c
gost_grasshopper_precompiled.c
gost_grasshopper_cipher.h
gost_grasshopper_cipher.c
)
set(GOST_CORE_SOURCE_FILES
e_gost_err.c
e_gost_err.h
gost_asn1.c
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
)
set (GOST_OMAC_SOURCE_FILES
gost_omac.c
gost_omac_acpkm.c
)
set(GOST_LIB_SOURCE_FILES
${GOST_89_SOURCE_FILES}
${GOST_HASH_SOURCE_FILES}
${GOST_HASH_2012_SOURCE_FILES}
${GOST_GRASSHOPPER_SOURCE_FILES}
${GOST_EC_SOURCE_FILES}
${GOST_OMAC_SOURCE_FILES}
)
set(GOST_ENGINE_SOURCE_FILES
${GOST_CORE_SOURCE_FILES}
gost_ameth.c
gost_md.c
gost_md2012.c
gost_pmeth.c
gost_omac.c
gost_omac_acpkm.c
)
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)
add_library(gost_core STATIC ${GOST_LIB_SOURCE_FILES})
set_target_properties(gost_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(gost_engine MODULE ${GOST_ENGINE_SOURCE_FILES})
set_target_properties(gost_engine PROPERTIES PREFIX "" OUTPUT_NAME "gost")
target_link_libraries(gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
set(GOST_SUM_SOURCE_FILES
gostsum.c
)
add_executable(gostsum ${GOST_SUM_SOURCE_FILES})
target_link_libraries(gostsum gost_core)
set(GOST_12_SUM_SOURCE_FILES
gost12sum.c
)
add_executable(gost12sum ${GOST_12_SUM_SOURCE_FILES})
target_link_libraries(gost12sum gost_core)
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}
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:gostsum> $<TARGET_PDB_FILE:gost12sum> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
endif()
|