1add_subdirectory(fipsmodule) 2add_subdirectory(test) 3 4if(FIPS_DELOCATE OR FIPS_SHARED) 5 SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES EXTERNAL_OBJECT true) 6 SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES GENERATED true) 7 8 set( 9 CRYPTO_FIPS_OBJECTS 10 11 fipsmodule/bcm.o 12 ) 13endif() 14 15set( 16 CRYPTO_SOURCES_ASM 17 curve25519/asm/x25519-asm-arm.S 18 hrss/asm/poly_rq_mul.S 19 poly1305/poly1305_arm_asm.S 20) 21perlasm(CRYPTO_SOURCES aarch64 chacha/chacha-armv8 chacha/asm/chacha-armv8.pl) 22perlasm(CRYPTO_SOURCES aarch64 cipher_extra/chacha20_poly1305_armv8 cipher_extra/asm/chacha20_poly1305_armv8.pl) 23perlasm(CRYPTO_SOURCES aarch64 test/trampoline-armv8 test/asm/trampoline-armv8.pl) 24perlasm(CRYPTO_SOURCES arm chacha/chacha-armv4 chacha/asm/chacha-armv4.pl) 25perlasm(CRYPTO_SOURCES arm test/trampoline-armv4 test/asm/trampoline-armv4.pl) 26perlasm(CRYPTO_SOURCES x86 chacha/chacha-x86 chacha/asm/chacha-x86.pl) 27perlasm(CRYPTO_SOURCES x86 test/trampoline-x86 test/asm/trampoline-x86.pl) 28perlasm(CRYPTO_SOURCES x86_64 chacha/chacha-x86_64 chacha/asm/chacha-x86_64.pl) 29perlasm(CRYPTO_SOURCES x86_64 cipher_extra/aes128gcmsiv-x86_64 cipher_extra/asm/aes128gcmsiv-x86_64.pl) 30perlasm(CRYPTO_SOURCES x86_64 cipher_extra/chacha20_poly1305_x86_64 cipher_extra/asm/chacha20_poly1305_x86_64.pl) 31perlasm(CRYPTO_SOURCES x86_64 test/trampoline-x86_64 test/asm/trampoline-x86_64.pl) 32 33add_custom_command( 34 OUTPUT err_data.c 35 COMMAND ${GO_EXECUTABLE} run err_data_generate.go > ${CMAKE_CURRENT_BINARY_DIR}/err_data.c 36 DEPENDS 37 err/err_data_generate.go 38 err/asn1.errordata 39 err/bio.errordata 40 err/bn.errordata 41 err/cipher.errordata 42 err/conf.errordata 43 err/dh.errordata 44 err/digest.errordata 45 err/dsa.errordata 46 err/ecdh.errordata 47 err/ecdsa.errordata 48 err/ec.errordata 49 err/engine.errordata 50 err/evp.errordata 51 err/hkdf.errordata 52 err/obj.errordata 53 err/pem.errordata 54 err/pkcs7.errordata 55 err/pkcs8.errordata 56 err/rsa.errordata 57 err/ssl.errordata 58 err/trust_token.errordata 59 err/x509.errordata 60 err/x509v3.errordata 61 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/err 62) 63 64add_library( 65 crypto 66 67 asn1/a_bitstr.c 68 asn1/a_bool.c 69 asn1/a_d2i_fp.c 70 asn1/a_dup.c 71 asn1/a_gentm.c 72 asn1/a_i2d_fp.c 73 asn1/a_int.c 74 asn1/a_mbstr.c 75 asn1/a_object.c 76 asn1/a_octet.c 77 asn1/a_strex.c 78 asn1/a_strnid.c 79 asn1/a_time.c 80 asn1/a_type.c 81 asn1/a_utctm.c 82 asn1/asn1_lib.c 83 asn1/asn1_par.c 84 asn1/asn_pack.c 85 asn1/f_int.c 86 asn1/f_string.c 87 asn1/tasn_dec.c 88 asn1/tasn_enc.c 89 asn1/tasn_fre.c 90 asn1/tasn_new.c 91 asn1/tasn_typ.c 92 asn1/tasn_utl.c 93 asn1/posix_time.c 94 base64/base64.c 95 bio/bio.c 96 bio/bio_mem.c 97 bio/connect.c 98 bio/fd.c 99 bio/file.c 100 bio/hexdump.c 101 bio/pair.c 102 bio/printf.c 103 bio/socket.c 104 bio/socket_helper.c 105 blake2/blake2.c 106 bn_extra/bn_asn1.c 107 bn_extra/convert.c 108 buf/buf.c 109 bytestring/asn1_compat.c 110 bytestring/ber.c 111 bytestring/cbb.c 112 bytestring/cbs.c 113 bytestring/unicode.c 114 chacha/chacha.c 115 cipher_extra/cipher_extra.c 116 cipher_extra/derive_key.c 117 cipher_extra/e_aesctrhmac.c 118 cipher_extra/e_aesgcmsiv.c 119 cipher_extra/e_chacha20poly1305.c 120 cipher_extra/e_des.c 121 cipher_extra/e_null.c 122 cipher_extra/e_rc2.c 123 cipher_extra/e_rc4.c 124 cipher_extra/e_tls.c 125 cipher_extra/tls_cbc.c 126 conf/conf.c 127 cpu_aarch64_apple.c 128 cpu_aarch64_freebsd.c 129 cpu_aarch64_fuchsia.c 130 cpu_aarch64_linux.c 131 cpu_aarch64_win.c 132 cpu_arm_freebsd.c 133 cpu_arm_linux.c 134 cpu_arm.c 135 cpu_intel.c 136 crypto.c 137 curve25519/curve25519.c 138 curve25519/spake25519.c 139 des/des.c 140 dh_extra/params.c 141 dh_extra/dh_asn1.c 142 digest_extra/digest_extra.c 143 dsa/dsa.c 144 dsa/dsa_asn1.c 145 ecdh_extra/ecdh_extra.c 146 ecdsa_extra/ecdsa_asn1.c 147 ec_extra/ec_asn1.c 148 ec_extra/ec_derive.c 149 ec_extra/hash_to_curve.c 150 err/err.c 151 err_data.c 152 engine/engine.c 153 evp/evp.c 154 evp/evp_asn1.c 155 evp/evp_ctx.c 156 evp/p_dsa_asn1.c 157 evp/p_ec.c 158 evp/p_ec_asn1.c 159 evp/p_ed25519.c 160 evp/p_ed25519_asn1.c 161 evp/p_hkdf.c 162 evp/p_rsa.c 163 evp/p_rsa_asn1.c 164 evp/p_x25519.c 165 evp/p_x25519_asn1.c 166 evp/pbkdf.c 167 evp/print.c 168 evp/scrypt.c 169 evp/sign.c 170 ex_data.c 171 hpke/hpke.c 172 hrss/hrss.c 173 kyber/keccak.c 174 kyber/kyber.c 175 lhash/lhash.c 176 mem.c 177 obj/obj.c 178 obj/obj_xref.c 179 pem/pem_all.c 180 pem/pem_info.c 181 pem/pem_lib.c 182 pem/pem_oth.c 183 pem/pem_pk8.c 184 pem/pem_pkey.c 185 pem/pem_x509.c 186 pem/pem_xaux.c 187 pkcs7/pkcs7.c 188 pkcs7/pkcs7_x509.c 189 pkcs8/pkcs8.c 190 pkcs8/pkcs8_x509.c 191 pkcs8/p5_pbev2.c 192 poly1305/poly1305.c 193 poly1305/poly1305_arm.c 194 poly1305/poly1305_vec.c 195 pool/pool.c 196 rand_extra/deterministic.c 197 rand_extra/forkunsafe.c 198 rand_extra/fuchsia.c 199 rand_extra/passive.c 200 rand_extra/rand_extra.c 201 rand_extra/windows.c 202 rc4/rc4.c 203 refcount_c11.c 204 refcount_lock.c 205 rsa_extra/rsa_asn1.c 206 rsa_extra/rsa_crypt.c 207 rsa_extra/rsa_print.c 208 stack/stack.c 209 siphash/siphash.c 210 thread.c 211 thread_none.c 212 thread_pthread.c 213 thread_win.c 214 trust_token/pmbtoken.c 215 trust_token/trust_token.c 216 trust_token/voprf.c 217 x509/a_digest.c 218 x509/a_sign.c 219 x509/a_verify.c 220 x509/algorithm.c 221 x509/asn1_gen.c 222 x509/by_dir.c 223 x509/by_file.c 224 x509/i2d_pr.c 225 x509/name_print.c 226 x509/policy.c 227 x509/rsa_pss.c 228 x509/t_crl.c 229 x509/t_req.c 230 x509/t_x509.c 231 x509/t_x509a.c 232 x509/x509.c 233 x509/x509_att.c 234 x509/x509_cmp.c 235 x509/x509_d2.c 236 x509/x509_def.c 237 x509/x509_ext.c 238 x509/x509_lu.c 239 x509/x509_obj.c 240 x509/x509_req.c 241 x509/x509_set.c 242 x509/x509_trs.c 243 x509/x509_txt.c 244 x509/x509_v3.c 245 x509/x509_vfy.c 246 x509/x509_vpm.c 247 x509/x509cset.c 248 x509/x509name.c 249 x509/x509rset.c 250 x509/x509spki.c 251 x509/x_algor.c 252 x509/x_all.c 253 x509/x_attrib.c 254 x509/x_crl.c 255 x509/x_exten.c 256 x509/x_info.c 257 x509/x_name.c 258 x509/x_pkey.c 259 x509/x_pubkey.c 260 x509/x_req.c 261 x509/x_sig.c 262 x509/x_spki.c 263 x509/x_val.c 264 x509/x_x509.c 265 x509/x_x509a.c 266 x509v3/v3_akey.c 267 x509v3/v3_akeya.c 268 x509v3/v3_alt.c 269 x509v3/v3_bcons.c 270 x509v3/v3_bitst.c 271 x509v3/v3_conf.c 272 x509v3/v3_cpols.c 273 x509v3/v3_crld.c 274 x509v3/v3_enum.c 275 x509v3/v3_extku.c 276 x509v3/v3_genn.c 277 x509v3/v3_ia5.c 278 x509v3/v3_info.c 279 x509v3/v3_int.c 280 x509v3/v3_lib.c 281 x509v3/v3_ncons.c 282 x509v3/v3_ocsp.c 283 x509v3/v3_pcons.c 284 x509v3/v3_pmaps.c 285 x509v3/v3_prn.c 286 x509v3/v3_purp.c 287 x509v3/v3_skey.c 288 x509v3/v3_utl.c 289 290 $<TARGET_OBJECTS:fipsmodule> 291 ${CRYPTO_FIPS_OBJECTS} 292) 293if(OPENSSL_ASM) 294 target_sources(crypto PRIVATE ${CRYPTO_SOURCES_ASM}) 295endif() 296if(OPENSSL_NASM) 297 target_sources(crypto PRIVATE ${CRYPTO_SOURCES_NASM}) 298endif() 299target_include_directories(crypto PUBLIC 300 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> 301 $<INSTALL_INTERFACE:include> 302) 303install_if_enabled(TARGETS crypto EXPORT OpenSSLTargets ${INSTALL_DESTINATION_DEFAULT}) 304set_property(TARGET crypto PROPERTY EXPORT_NAME Crypto) 305 306if(FIPS_SHARED) 307 # Rewrite libcrypto.so to inject the correct module hash value. This assumes 308 # UNIX-style library naming, but we only support FIPS mode on Linux anyway. 309 add_custom_command( 310 TARGET crypto POST_BUILD 311 COMMAND ${GO_EXECUTABLE} run 312 ${CMAKE_CURRENT_SOURCE_DIR}/../util/fipstools/inject_hash/inject_hash.go 313 -o libcrypto.so -in-object libcrypto.so 314 # The DEPENDS argument to a POST_BUILD rule appears to be ignored. Thus 315 # go_executable isn't used (as it doesn't get built), but we list this 316 # dependency anyway in case it starts working in some CMake version. 317 DEPENDS ../util/fipstools/inject_hash/inject_hash.go 318 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 319 ) 320endif() 321 322add_dependencies(crypto boringssl_prefix_symbols) 323 324if(FIPS_DELOCATE OR FIPS_SHARED) 325 add_dependencies(crypto bcm_o_target) 326endif() 327 328set_target_properties(crypto PROPERTIES LINKER_LANGUAGE C) 329 330if(WIN32) 331 target_link_libraries(crypto ws2_32) 332endif() 333 334if(NOT ANDROID) 335 find_package(Threads REQUIRED) 336 target_link_libraries(crypto Threads::Threads) 337endif() 338 339# Every target depends on crypto, so we add libcxx as a dependency here to 340# simplify injecting it everywhere. 341if(USE_CUSTOM_LIBCXX) 342 target_link_libraries(crypto libcxx) 343endif() 344 345# urandom_test is a separate binary because it needs to be able to observe the 346# PRNG initialisation, which means that it can't have other tests running before 347# it does. 348add_executable( 349 urandom_test 350 351 fipsmodule/rand/urandom_test.cc 352) 353target_link_libraries(urandom_test test_support_lib boringssl_gtest crypto) 354add_dependencies(all_tests urandom_test) 355 356add_executable( 357 crypto_test 358 359 abi_self_test.cc 360 asn1/asn1_test.cc 361 base64/base64_test.cc 362 bio/bio_test.cc 363 blake2/blake2_test.cc 364 buf/buf_test.cc 365 bytestring/bytestring_test.cc 366 chacha/chacha_test.cc 367 cipher_extra/aead_test.cc 368 cipher_extra/cipher_test.cc 369 compiler_test.cc 370 conf/conf_test.cc 371 constant_time_test.cc 372 cpu_arm_linux_test.cc 373 crypto_test.cc 374 curve25519/ed25519_test.cc 375 curve25519/spake25519_test.cc 376 curve25519/x25519_test.cc 377 ecdh_extra/ecdh_test.cc 378 dh_extra/dh_test.cc 379 digest_extra/digest_test.cc 380 dsa/dsa_test.cc 381 err/err_test.cc 382 evp/evp_extra_test.cc 383 evp/evp_test.cc 384 evp/pbkdf_test.cc 385 evp/scrypt_test.cc 386 fipsmodule/aes/aes_test.cc 387 fipsmodule/bn/bn_test.cc 388 fipsmodule/cmac/cmac_test.cc 389 fipsmodule/ec/ec_test.cc 390 fipsmodule/ec/p256-nistz_test.cc 391 fipsmodule/ecdsa/ecdsa_test.cc 392 fipsmodule/hkdf/hkdf_test.cc 393 fipsmodule/md5/md5_test.cc 394 fipsmodule/modes/gcm_test.cc 395 fipsmodule/rand/ctrdrbg_test.cc 396 fipsmodule/rand/fork_detect_test.cc 397 fipsmodule/service_indicator/service_indicator_test.cc 398 fipsmodule/sha/sha_test.cc 399 hpke/hpke_test.cc 400 hmac_extra/hmac_test.cc 401 hrss/hrss_test.cc 402 impl_dispatch_test.cc 403 kyber/kyber_test.cc 404 lhash/lhash_test.cc 405 obj/obj_test.cc 406 pem/pem_test.cc 407 pkcs7/pkcs7_test.cc 408 pkcs8/pkcs8_test.cc 409 pkcs8/pkcs12_test.cc 410 poly1305/poly1305_test.cc 411 pool/pool_test.cc 412 rand_extra/rand_test.cc 413 refcount_test.cc 414 rsa_extra/rsa_test.cc 415 self_test.cc 416 stack/stack_test.cc 417 siphash/siphash_test.cc 418 test/file_test_gtest.cc 419 thread_test.cc 420 trust_token/trust_token_test.cc 421 x509/x509_test.cc 422 x509/x509_time_test.cc 423 x509v3/tab_test.cc 424 425 $<TARGET_OBJECTS:crypto_test_data> 426) 427target_link_libraries(crypto_test test_support_lib boringssl_gtest_main crypto) 428add_dependencies(all_tests crypto_test) 429