• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include_directories(../include)
2
3if(NOT OPENSSL_NO_ASM)
4  if(UNIX)
5    if(${ARCH} STREQUAL "aarch64")
6      # The "armx" Perl scripts look for "64" in the style argument
7      # in order to decide whether to generate 32- or 64-bit asm.
8      if(APPLE)
9        set(PERLASM_STYLE ios64)
10      else()
11        set(PERLASM_STYLE linux64)
12      endif()
13    elseif(${ARCH} STREQUAL "arm")
14      if(APPLE)
15        set(PERLASM_STYLE ios32)
16      else()
17        set(PERLASM_STYLE linux32)
18      endif()
19    elseif(${ARCH} STREQUAL "ppc64le")
20      set(PERLASM_STYLE linux64le)
21    else()
22      if(${ARCH} STREQUAL "x86")
23        set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
24      endif()
25      if(APPLE)
26        set(PERLASM_STYLE macosx)
27      else()
28        set(PERLASM_STYLE elf)
29      endif()
30    endif()
31    set(ASM_EXT S)
32    enable_language(ASM)
33    set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
34
35    # Clang's integerated assembler does not support debug symbols.
36    if(NOT CMAKE_ASM_COMPILER_ID MATCHES "Clang")
37      set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,-g")
38    endif()
39
40    # CMake does not add -isysroot and -arch flags to assembly.
41    if(APPLE)
42      if(CMAKE_OSX_SYSROOT)
43        set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot \"${CMAKE_OSX_SYSROOT}\"")
44      endif()
45      foreach(arch ${CMAKE_OSX_ARCHITECTURES})
46        set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${arch}")
47      endforeach()
48    endif()
49  else()
50    if(${ARCH} STREQUAL "x86_64")
51      set(PERLASM_STYLE nasm)
52    else()
53      set(PERLASM_STYLE win32n)
54      set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
55    endif()
56    set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -gcv8")
57
58    # On Windows, we use the NASM output, specifically built with Yasm.
59    set(ASM_EXT asm)
60    enable_language(ASM_NASM)
61  endif()
62endif()
63
64function(perlasm dest src)
65  get_filename_component(dir ${dest} DIRECTORY)
66  if ("${dir}" STREQUAL "")
67    set(dir ".")
68  endif()
69
70  add_custom_command(
71    OUTPUT ${dest}
72    COMMAND ${CMAKE_COMMAND} -E make_directory ${dir}
73    COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} ${dest}
74    DEPENDS
75    ${src}
76    ${PROJECT_SOURCE_DIR}/crypto/perlasm/arm-xlate.pl
77    ${PROJECT_SOURCE_DIR}/crypto/perlasm/ppc-xlate.pl
78    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86_64-xlate.pl
79    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86asm.pl
80    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86gas.pl
81    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86masm.pl
82    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86nasm.pl
83    WORKING_DIRECTORY .
84  )
85endfunction()
86
87add_subdirectory(fipsmodule)
88add_subdirectory(test)
89
90if(FIPS_DELOCATE)
91  SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES EXTERNAL_OBJECT true)
92  SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES GENERATED true)
93
94  set(
95    CRYPTO_FIPS_OBJECTS
96
97    fipsmodule/bcm.o
98  )
99endif()
100
101if(${ARCH} STREQUAL "arm")
102  set(
103    CRYPTO_ARCH_SOURCES
104
105    chacha/chacha-armv4.${ASM_EXT}
106    curve25519/asm/x25519-asm-arm.S
107    poly1305/poly1305_arm_asm.S
108    test/trampoline-armv4.${ASM_EXT}
109  )
110endif()
111
112if(${ARCH} STREQUAL "aarch64")
113  set(
114    CRYPTO_ARCH_SOURCES
115
116    chacha/chacha-armv8.${ASM_EXT}
117    test/trampoline-armv8.${ASM_EXT}
118  )
119endif()
120
121if(${ARCH} STREQUAL "x86")
122  set(
123    CRYPTO_ARCH_SOURCES
124
125    chacha/chacha-x86.${ASM_EXT}
126    test/trampoline-x86.${ASM_EXT}
127  )
128endif()
129
130if(${ARCH} STREQUAL "x86_64")
131  set(
132    CRYPTO_ARCH_SOURCES
133
134    chacha/chacha-x86_64.${ASM_EXT}
135    cipher_extra/aes128gcmsiv-x86_64.${ASM_EXT}
136    cipher_extra/chacha20_poly1305_x86_64.${ASM_EXT}
137    hrss/asm/poly_rq_mul.S
138    test/trampoline-x86_64.${ASM_EXT}
139  )
140endif()
141
142perlasm(chacha/chacha-armv4.${ASM_EXT} chacha/asm/chacha-armv4.pl)
143perlasm(chacha/chacha-armv8.${ASM_EXT} chacha/asm/chacha-armv8.pl)
144perlasm(chacha/chacha-x86.${ASM_EXT} chacha/asm/chacha-x86.pl)
145perlasm(chacha/chacha-x86_64.${ASM_EXT} chacha/asm/chacha-x86_64.pl)
146perlasm(cipher_extra/aes128gcmsiv-x86_64.${ASM_EXT} cipher_extra/asm/aes128gcmsiv-x86_64.pl)
147perlasm(cipher_extra/chacha20_poly1305_x86_64.${ASM_EXT} cipher_extra/asm/chacha20_poly1305_x86_64.pl)
148perlasm(test/trampoline-armv4.${ASM_EXT} test/asm/trampoline-armv4.pl)
149perlasm(test/trampoline-armv8.${ASM_EXT} test/asm/trampoline-armv8.pl)
150perlasm(test/trampoline-x86.${ASM_EXT} test/asm/trampoline-x86.pl)
151perlasm(test/trampoline-x86_64.${ASM_EXT} test/asm/trampoline-x86_64.pl)
152
153add_custom_command(
154  OUTPUT err_data.c
155  COMMAND ${GO_EXECUTABLE} run err_data_generate.go > ${CMAKE_CURRENT_BINARY_DIR}/err_data.c
156  DEPENDS
157  err/err_data_generate.go
158  err/asn1.errordata
159  err/bio.errordata
160  err/bn.errordata
161  err/cipher.errordata
162  err/conf.errordata
163  err/dh.errordata
164  err/digest.errordata
165  err/dsa.errordata
166  err/ecdh.errordata
167  err/ecdsa.errordata
168  err/ec.errordata
169  err/engine.errordata
170  err/evp.errordata
171  err/hkdf.errordata
172  err/obj.errordata
173  err/pem.errordata
174  err/pkcs7.errordata
175  err/pkcs8.errordata
176  err/rsa.errordata
177  err/ssl.errordata
178  err/x509.errordata
179  err/x509v3.errordata
180  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/err
181)
182
183add_library(
184  crypto
185
186  asn1/a_bitstr.c
187  asn1/a_bool.c
188  asn1/a_d2i_fp.c
189  asn1/a_dup.c
190  asn1/a_enum.c
191  asn1/a_gentm.c
192  asn1/a_i2d_fp.c
193  asn1/a_int.c
194  asn1/a_mbstr.c
195  asn1/a_object.c
196  asn1/a_octet.c
197  asn1/a_print.c
198  asn1/a_strnid.c
199  asn1/a_time.c
200  asn1/a_type.c
201  asn1/a_utctm.c
202  asn1/a_utf8.c
203  asn1/asn1_lib.c
204  asn1/asn1_par.c
205  asn1/asn_pack.c
206  asn1/f_enum.c
207  asn1/f_int.c
208  asn1/f_string.c
209  asn1/tasn_dec.c
210  asn1/tasn_enc.c
211  asn1/tasn_fre.c
212  asn1/tasn_new.c
213  asn1/tasn_typ.c
214  asn1/tasn_utl.c
215  asn1/time_support.c
216  base64/base64.c
217  bio/bio.c
218  bio/bio_mem.c
219  bio/connect.c
220  bio/fd.c
221  bio/file.c
222  bio/hexdump.c
223  bio/pair.c
224  bio/printf.c
225  bio/socket.c
226  bio/socket_helper.c
227  bn_extra/bn_asn1.c
228  bn_extra/convert.c
229  buf/buf.c
230  bytestring/asn1_compat.c
231  bytestring/ber.c
232  bytestring/cbb.c
233  bytestring/cbs.c
234  bytestring/unicode.c
235  chacha/chacha.c
236  cipher_extra/cipher_extra.c
237  cipher_extra/derive_key.c
238  cipher_extra/e_aesccm.c
239  cipher_extra/e_aesctrhmac.c
240  cipher_extra/e_aesgcmsiv.c
241  cipher_extra/e_chacha20poly1305.c
242  cipher_extra/e_null.c
243  cipher_extra/e_rc2.c
244  cipher_extra/e_rc4.c
245  cipher_extra/e_tls.c
246  cipher_extra/tls_cbc.c
247  cmac/cmac.c
248  conf/conf.c
249  cpu-aarch64-fuchsia.c
250  cpu-aarch64-linux.c
251  cpu-arm-linux.c
252  cpu-arm.c
253  cpu-intel.c
254  cpu-ppc64le.c
255  crypto.c
256  curve25519/spake25519.c
257  dh/dh.c
258  dh/params.c
259  dh/check.c
260  dh/dh_asn1.c
261  digest_extra/digest_extra.c
262  dsa/dsa.c
263  dsa/dsa_asn1.c
264  ecdh_extra/ecdh_extra.c
265  ecdsa_extra/ecdsa_asn1.c
266  ec_extra/ec_asn1.c
267  err/err.c
268  err_data.c
269  engine/engine.c
270  evp/digestsign.c
271  evp/evp.c
272  evp/evp_asn1.c
273  evp/evp_ctx.c
274  evp/p_dsa_asn1.c
275  evp/p_ec.c
276  evp/p_ec_asn1.c
277  evp/p_ed25519.c
278  evp/p_ed25519_asn1.c
279  evp/p_rsa.c
280  evp/p_rsa_asn1.c
281  evp/pbkdf.c
282  evp/print.c
283  evp/scrypt.c
284  evp/sign.c
285  ex_data.c
286  hkdf/hkdf.c
287  hrss/hrss.c
288  lhash/lhash.c
289  mem.c
290  obj/obj.c
291  obj/obj_xref.c
292  pem/pem_all.c
293  pem/pem_info.c
294  pem/pem_lib.c
295  pem/pem_oth.c
296  pem/pem_pk8.c
297  pem/pem_pkey.c
298  pem/pem_x509.c
299  pem/pem_xaux.c
300  pkcs7/pkcs7.c
301  pkcs7/pkcs7_x509.c
302  pkcs8/pkcs8.c
303  pkcs8/pkcs8_x509.c
304  pkcs8/p5_pbev2.c
305  poly1305/poly1305.c
306  poly1305/poly1305_arm.c
307  poly1305/poly1305_vec.c
308  pool/pool.c
309  rand_extra/deterministic.c
310  rand_extra/forkunsafe.c
311  rand_extra/fuchsia.c
312  rand_extra/rand_extra.c
313  rand_extra/windows.c
314  rc4/rc4.c
315  refcount_c11.c
316  refcount_lock.c
317  rsa_extra/rsa_asn1.c
318  rsa_extra/rsa_print.c
319  stack/stack.c
320  thread.c
321  thread_none.c
322  thread_pthread.c
323  thread_win.c
324  x509/a_digest.c
325  x509/a_sign.c
326  x509/a_strex.c
327  x509/a_verify.c
328  x509/algorithm.c
329  x509/asn1_gen.c
330  x509/by_dir.c
331  x509/by_file.c
332  x509/i2d_pr.c
333  x509/rsa_pss.c
334  x509/t_crl.c
335  x509/t_req.c
336  x509/t_x509.c
337  x509/t_x509a.c
338  x509/x509.c
339  x509/x509_att.c
340  x509/x509_cmp.c
341  x509/x509_d2.c
342  x509/x509_def.c
343  x509/x509_ext.c
344  x509/x509_lu.c
345  x509/x509_obj.c
346  x509/x509_r2x.c
347  x509/x509_req.c
348  x509/x509_set.c
349  x509/x509_trs.c
350  x509/x509_txt.c
351  x509/x509_v3.c
352  x509/x509_vfy.c
353  x509/x509_vpm.c
354  x509/x509cset.c
355  x509/x509name.c
356  x509/x509rset.c
357  x509/x509spki.c
358  x509/x_algor.c
359  x509/x_all.c
360  x509/x_attrib.c
361  x509/x_crl.c
362  x509/x_exten.c
363  x509/x_info.c
364  x509/x_name.c
365  x509/x_pkey.c
366  x509/x_pubkey.c
367  x509/x_req.c
368  x509/x_sig.c
369  x509/x_spki.c
370  x509/x_val.c
371  x509/x_x509.c
372  x509/x_x509a.c
373  x509v3/pcy_cache.c
374  x509v3/pcy_data.c
375  x509v3/pcy_lib.c
376  x509v3/pcy_map.c
377  x509v3/pcy_node.c
378  x509v3/pcy_tree.c
379  x509v3/v3_akey.c
380  x509v3/v3_akeya.c
381  x509v3/v3_alt.c
382  x509v3/v3_bcons.c
383  x509v3/v3_bitst.c
384  x509v3/v3_conf.c
385  x509v3/v3_cpols.c
386  x509v3/v3_crld.c
387  x509v3/v3_enum.c
388  x509v3/v3_extku.c
389  x509v3/v3_genn.c
390  x509v3/v3_ia5.c
391  x509v3/v3_info.c
392  x509v3/v3_int.c
393  x509v3/v3_lib.c
394  x509v3/v3_ncons.c
395  x509v3/v3_ocsp.c
396  x509v3/v3_pci.c
397  x509v3/v3_pcia.c
398  x509v3/v3_pcons.c
399  x509v3/v3_pku.c
400  x509v3/v3_pmaps.c
401  x509v3/v3_prn.c
402  x509v3/v3_purp.c
403  x509v3/v3_skey.c
404  x509v3/v3_sxnet.c
405  x509v3/v3_utl.c
406  ../third_party/fiat/curve25519.c
407
408  $<TARGET_OBJECTS:fipsmodule>
409
410  ${CRYPTO_ARCH_SOURCES}
411  ${CRYPTO_FIPS_OBJECTS}
412)
413
414add_dependencies(crypto global_target)
415
416if(FIPS_DELOCATE)
417  add_dependencies(crypto bcm_o_target)
418endif()
419
420SET_TARGET_PROPERTIES(crypto PROPERTIES LINKER_LANGUAGE C)
421
422if(NOT MSVC AND NOT ANDROID)
423  target_link_libraries(crypto pthread)
424endif()
425
426# Every target depends on crypto, so we add libcxx as a dependency here to
427# simplify injecting it everywhere.
428if(USE_CUSTOM_LIBCXX)
429  target_link_libraries(crypto libcxx)
430endif()
431
432add_executable(
433  crypto_test
434
435  abi_self_test.cc
436  asn1/asn1_test.cc
437  base64/base64_test.cc
438  buf/buf_test.cc
439  bio/bio_test.cc
440  bytestring/bytestring_test.cc
441  chacha/chacha_test.cc
442  cipher_extra/aead_test.cc
443  cipher_extra/cipher_test.cc
444  cmac/cmac_test.cc
445  compiler_test.cc
446  constant_time_test.cc
447  cpu-arm-linux_test.cc
448  curve25519/ed25519_test.cc
449  curve25519/spake25519_test.cc
450  curve25519/x25519_test.cc
451  ecdh_extra/ecdh_test.cc
452  dh/dh_test.cc
453  digest_extra/digest_test.cc
454  dsa/dsa_test.cc
455  err/err_test.cc
456  evp/evp_extra_test.cc
457  evp/evp_test.cc
458  evp/pbkdf_test.cc
459  evp/scrypt_test.cc
460  fipsmodule/aes/aes_test.cc
461  fipsmodule/bn/bn_test.cc
462  fipsmodule/ec/ec_test.cc
463  fipsmodule/ec/p256-x86_64_test.cc
464  fipsmodule/ecdsa/ecdsa_test.cc
465  fipsmodule/md5/md5_test.cc
466  fipsmodule/modes/gcm_test.cc
467  fipsmodule/rand/ctrdrbg_test.cc
468  fipsmodule/sha/sha_test.cc
469  hkdf/hkdf_test.cc
470  hmac_extra/hmac_test.cc
471  hrss/hrss_test.cc
472  impl_dispatch_test.cc
473  lhash/lhash_test.cc
474  obj/obj_test.cc
475  pem/pem_test.cc
476  pkcs7/pkcs7_test.cc
477  pkcs8/pkcs8_test.cc
478  pkcs8/pkcs12_test.cc
479  poly1305/poly1305_test.cc
480  pool/pool_test.cc
481  rand_extra/rand_test.cc
482  refcount_test.cc
483  rsa_extra/rsa_test.cc
484  self_test.cc
485  stack/stack_test.cc
486  test/file_test_gtest.cc
487  thread_test.cc
488  x509/x509_test.cc
489  x509/x509_time_test.cc
490  x509v3/tab_test.cc
491  x509v3/v3name_test.cc
492
493  $<TARGET_OBJECTS:crypto_test_data>
494  $<TARGET_OBJECTS:boringssl_gtest_main>
495)
496
497add_dependencies(crypto_test global_target)
498
499target_link_libraries(crypto_test test_support_lib boringssl_gtest crypto)
500if(WIN32)
501  target_link_libraries(crypto_test ws2_32)
502endif()
503add_dependencies(all_tests crypto_test)
504