• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include_directories(../../include)
2
3if(${ARCH} STREQUAL "x86_64")
4  set(
5    BCM_ASM_SOURCES
6
7    aesni-gcm-x86_64.${ASM_EXT}
8    aesni-x86_64.${ASM_EXT}
9    aes-x86_64.${ASM_EXT}
10    ghash-ssse3-x86_64.${ASM_EXT}
11    ghash-x86_64.${ASM_EXT}
12    md5-x86_64.${ASM_EXT}
13    p256-x86_64-asm.${ASM_EXT}
14    p256_beeu-x86_64-asm.${ASM_EXT}
15    rdrand-x86_64.${ASM_EXT}
16    rsaz-avx2.${ASM_EXT}
17    sha1-x86_64.${ASM_EXT}
18    sha256-x86_64.${ASM_EXT}
19    sha512-x86_64.${ASM_EXT}
20    vpaes-x86_64.${ASM_EXT}
21    x86_64-mont5.${ASM_EXT}
22    x86_64-mont.${ASM_EXT}
23  )
24endif()
25
26if(${ARCH} STREQUAL "x86")
27  set(
28    BCM_ASM_SOURCES
29
30    aes-586.${ASM_EXT}
31    aesni-x86.${ASM_EXT}
32    bn-586.${ASM_EXT}
33    co-586.${ASM_EXT}
34    ghash-ssse3-x86.${ASM_EXT}
35    ghash-x86.${ASM_EXT}
36    md5-586.${ASM_EXT}
37    sha1-586.${ASM_EXT}
38    sha256-586.${ASM_EXT}
39    sha512-586.${ASM_EXT}
40    vpaes-x86.${ASM_EXT}
41    x86-mont.${ASM_EXT}
42  )
43endif()
44
45if(${ARCH} STREQUAL "arm")
46  set(
47    BCM_ASM_SOURCES
48
49    aes-armv4.${ASM_EXT}
50    aesv8-armx.${ASM_EXT}
51    armv4-mont.${ASM_EXT}
52    bsaes-armv7.${ASM_EXT}
53    ghash-armv4.${ASM_EXT}
54    ghashv8-armx.${ASM_EXT}
55    sha1-armv4-large.${ASM_EXT}
56    sha256-armv4.${ASM_EXT}
57    sha512-armv4.${ASM_EXT}
58    vpaes-armv7.${ASM_EXT}
59  )
60endif()
61
62if(${ARCH} STREQUAL "aarch64")
63  set(
64    BCM_ASM_SOURCES
65
66    aesv8-armx.${ASM_EXT}
67    armv8-mont.${ASM_EXT}
68    ghash-neon-armv8.${ASM_EXT}
69    ghashv8-armx.${ASM_EXT}
70    sha1-armv8.${ASM_EXT}
71    sha256-armv8.${ASM_EXT}
72    sha512-armv8.${ASM_EXT}
73    vpaes-armv8.${ASM_EXT}
74  )
75endif()
76
77if(${ARCH} STREQUAL "ppc64le")
78  set(
79    BCM_ASM_SOURCES
80
81    aesp8-ppc.${ASM_EXT}
82    ghashp8-ppc.${ASM_EXT}
83  )
84endif()
85
86perlasm(aes-586.${ASM_EXT} aes/asm/aes-586.pl)
87perlasm(aes-armv4.${ASM_EXT} aes/asm/aes-armv4.pl)
88perlasm(aesni-gcm-x86_64.${ASM_EXT} modes/asm/aesni-gcm-x86_64.pl)
89perlasm(aesni-x86_64.${ASM_EXT} aes/asm/aesni-x86_64.pl)
90perlasm(aesni-x86.${ASM_EXT} aes/asm/aesni-x86.pl)
91perlasm(aesp8-ppc.${ASM_EXT} aes/asm/aesp8-ppc.pl)
92perlasm(aesv8-armx.${ASM_EXT} aes/asm/aesv8-armx.pl)
93perlasm(aes-x86_64.${ASM_EXT} aes/asm/aes-x86_64.pl)
94perlasm(armv4-mont.${ASM_EXT} bn/asm/armv4-mont.pl)
95perlasm(armv8-mont.${ASM_EXT} bn/asm/armv8-mont.pl)
96perlasm(bn-586.${ASM_EXT} bn/asm/bn-586.pl)
97perlasm(bsaes-armv7.${ASM_EXT} aes/asm/bsaes-armv7.pl)
98perlasm(co-586.${ASM_EXT} bn/asm/co-586.pl)
99perlasm(ghash-armv4.${ASM_EXT} modes/asm/ghash-armv4.pl)
100perlasm(ghashp8-ppc.${ASM_EXT} modes/asm/ghashp8-ppc.pl)
101perlasm(ghashv8-armx.${ASM_EXT} modes/asm/ghashv8-armx.pl)
102perlasm(ghash-neon-armv8.${ASM_EXT} modes/asm/ghash-neon-armv8.pl)
103perlasm(ghash-ssse3-x86_64.${ASM_EXT} modes/asm/ghash-ssse3-x86_64.pl)
104perlasm(ghash-ssse3-x86.${ASM_EXT} modes/asm/ghash-ssse3-x86.pl)
105perlasm(ghash-x86_64.${ASM_EXT} modes/asm/ghash-x86_64.pl)
106perlasm(ghash-x86.${ASM_EXT} modes/asm/ghash-x86.pl)
107perlasm(md5-586.${ASM_EXT} md5/asm/md5-586.pl)
108perlasm(md5-x86_64.${ASM_EXT} md5/asm/md5-x86_64.pl)
109perlasm(p256-x86_64-asm.${ASM_EXT} ec/asm/p256-x86_64-asm.pl)
110perlasm(p256_beeu-x86_64-asm.${ASM_EXT} ec/asm/p256_beeu-x86_64-asm.pl)
111perlasm(rdrand-x86_64.${ASM_EXT} rand/asm/rdrand-x86_64.pl)
112perlasm(rsaz-avx2.${ASM_EXT} bn/asm/rsaz-avx2.pl)
113perlasm(sha1-586.${ASM_EXT} sha/asm/sha1-586.pl)
114perlasm(sha1-armv4-large.${ASM_EXT} sha/asm/sha1-armv4-large.pl)
115perlasm(sha1-armv8.${ASM_EXT} sha/asm/sha1-armv8.pl)
116perlasm(sha1-x86_64.${ASM_EXT} sha/asm/sha1-x86_64.pl)
117perlasm(sha256-586.${ASM_EXT} sha/asm/sha256-586.pl)
118perlasm(sha256-armv4.${ASM_EXT} sha/asm/sha256-armv4.pl)
119perlasm(sha256-armv8.${ASM_EXT} sha/asm/sha512-armv8.pl)
120perlasm(sha256-x86_64.${ASM_EXT} sha/asm/sha512-x86_64.pl)
121perlasm(sha512-586.${ASM_EXT} sha/asm/sha512-586.pl)
122perlasm(sha512-armv4.${ASM_EXT} sha/asm/sha512-armv4.pl)
123perlasm(sha512-armv8.${ASM_EXT} sha/asm/sha512-armv8.pl)
124perlasm(sha512-x86_64.${ASM_EXT} sha/asm/sha512-x86_64.pl)
125perlasm(vpaes-armv7.${ASM_EXT} aes/asm/vpaes-armv7.pl)
126perlasm(vpaes-armv8.${ASM_EXT} aes/asm/vpaes-armv8.pl)
127perlasm(vpaes-x86_64.${ASM_EXT} aes/asm/vpaes-x86_64.pl)
128perlasm(vpaes-x86.${ASM_EXT} aes/asm/vpaes-x86.pl)
129perlasm(x86_64-mont5.${ASM_EXT} bn/asm/x86_64-mont5.pl)
130perlasm(x86_64-mont.${ASM_EXT} bn/asm/x86_64-mont.pl)
131perlasm(x86-mont.${ASM_EXT} bn/asm/x86-mont.pl)
132
133if(FIPS_DELOCATE)
134  if(FIPS_SHARED)
135    error("Can't set both delocate and shared mode for FIPS build")
136  endif()
137
138  if(OPENSSL_NO_ASM)
139    # If OPENSSL_NO_ASM was defined then ASM will not have been enabled, but in
140    # FIPS mode we have to have it because the module build requires going via
141    # textual assembly.
142    enable_language(ASM)
143  endif()
144
145  add_library(
146    bcm_c_generated_asm
147
148    STATIC
149
150    bcm.c
151  )
152
153  add_dependencies(bcm_c_generated_asm global_target)
154
155  set_target_properties(bcm_c_generated_asm PROPERTIES COMPILE_OPTIONS "-S")
156  set_target_properties(bcm_c_generated_asm PROPERTIES POSITION_INDEPENDENT_CODE ON)
157
158  go_executable(delocate boringssl.googlesource.com/boringssl/util/fipstools/delocate)
159  add_custom_command(
160    OUTPUT bcm-delocated.S
161    COMMAND ./delocate -a $<TARGET_FILE:bcm_c_generated_asm> -o bcm-delocated.S ${BCM_ASM_SOURCES}
162    DEPENDS bcm_c_generated_asm delocate ${BCM_ASM_SOURCES}
163    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
164  )
165
166  add_library(
167    bcm_hashunset
168
169    STATIC
170
171    bcm-delocated.S
172  )
173
174  add_dependencies(bcm_hashunset global_target)
175
176  set_target_properties(bcm_hashunset PROPERTIES POSITION_INDEPENDENT_CODE ON)
177  set_target_properties(bcm_hashunset PROPERTIES LINKER_LANGUAGE C)
178
179  go_executable(inject_hash
180	        boringssl.googlesource.com/boringssl/util/fipstools/inject_hash)
181  add_custom_command(
182    OUTPUT bcm.o
183    COMMAND ./inject_hash -o bcm.o -in-archive $<TARGET_FILE:bcm_hashunset>
184    DEPENDS bcm_hashunset inject_hash
185    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
186  )
187
188  # The outputs of add_custom_command cannot be referenced outside of the
189  # CMakeLists.txt that defines it. Thus we have to wrap bcm.o in a custom target
190  # so that crypto can depend on it.
191  add_custom_target(bcm_o_target DEPENDS bcm.o)
192
193  add_library(
194    fipsmodule
195
196    OBJECT
197
198    fips_shared_support.c
199    is_fips.c
200  )
201
202  add_dependencies(fipsmodule global_target)
203
204  set_target_properties(fipsmodule PROPERTIES LINKER_LANGUAGE C)
205elseif(FIPS_SHARED)
206  if(NOT BUILD_SHARED_LIBS)
207    error("FIPS_SHARED set but not BUILD_SHARED_LIBS")
208  endif()
209
210  add_library(
211    fipsmodule
212
213    OBJECT
214
215    fips_shared_support.c
216    is_fips.c
217  )
218
219  add_dependencies(fipsmodule global_target)
220
221  add_library(
222    bcm_library
223
224    STATIC
225
226    bcm.c
227
228    ${BCM_ASM_SOURCES}
229  )
230
231  add_dependencies(bcm_library global_target)
232
233  add_custom_command(
234    OUTPUT bcm.o
235    COMMAND ${CMAKE_LINKER} -r -T ${CMAKE_CURRENT_SOURCE_DIR}/fips_shared.lds -o bcm.o --whole-archive $<TARGET_FILE:bcm_library>
236    DEPENDS bcm_library fips_shared.lds
237    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
238  )
239
240  add_custom_target(bcm_o_target DEPENDS bcm.o)
241else()
242  add_library(
243    fipsmodule
244
245    OBJECT
246
247    bcm.c
248    fips_shared_support.c
249    is_fips.c
250
251    ${BCM_ASM_SOURCES}
252  )
253
254  add_dependencies(fipsmodule global_target)
255endif()
256