1 include_directories(../include) 2 3 if(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 "-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() 62 endif() 63 64 function(perlasm dest src) 65 add_custom_command( 66 OUTPUT ${dest} 67 COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} ${dest} 68 DEPENDS 69 ${src} 70 ${PROJECT_SOURCE_DIR}/crypto/perlasm/arm-xlate.pl 71 ${PROJECT_SOURCE_DIR}/crypto/perlasm/ppc-xlate.pl 72 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86_64-xlate.pl 73 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86asm.pl 74 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86gas.pl 75 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86masm.pl 76 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86nasm.pl 77 WORKING_DIRECTORY . 78 ) 79 endfunction() 80 81 # Level 0.1 - depends on nothing outside this set. 82 add_subdirectory(stack) 83 add_subdirectory(lhash) 84 add_subdirectory(err) 85 add_subdirectory(buf) 86 add_subdirectory(base64) 87 add_subdirectory(bytestring) 88 add_subdirectory(pool) 89 90 # Level 0.2 - depends on nothing but itself 91 add_subdirectory(rc4) 92 add_subdirectory(conf) 93 add_subdirectory(chacha) 94 add_subdirectory(poly1305) 95 add_subdirectory(curve25519) 96 97 # Level 1, depends only on 0.* 98 add_subdirectory(digest_extra) 99 add_subdirectory(cipher_extra) 100 add_subdirectory(rand_extra) 101 add_subdirectory(bio) 102 add_subdirectory(bn_extra) 103 add_subdirectory(obj) 104 add_subdirectory(asn1) 105 106 # Level 2 107 add_subdirectory(engine) 108 add_subdirectory(dh) 109 add_subdirectory(dsa) 110 add_subdirectory(rsa_extra) 111 add_subdirectory(ec_extra) 112 add_subdirectory(ecdh) 113 add_subdirectory(ecdsa_extra) 114 115 # Level 3 116 add_subdirectory(cmac) 117 add_subdirectory(evp) 118 add_subdirectory(hkdf) 119 add_subdirectory(pem) 120 add_subdirectory(x509) 121 add_subdirectory(x509v3) 122 123 # Level 4 124 add_subdirectory(pkcs7) 125 add_subdirectory(pkcs8) 126 127 # Test support code 128 add_subdirectory(test) 129 130 add_subdirectory(fipsmodule) 131 132 add_library( 133 crypto_base 134 135 OBJECT 136 137 cpu-aarch64-linux.c 138 cpu-arm.c 139 cpu-arm-linux.c 140 cpu-intel.c 141 cpu-ppc64le.c 142 crypto.c 143 ex_data.c 144 mem.c 145 refcount_c11.c 146 refcount_lock.c 147 thread.c 148 thread_none.c 149 thread_pthread.c 150 thread_win.c 151 ) 152 153 if(FIPS_DELOCATE) 154 SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES EXTERNAL_OBJECT true) 155 SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES GENERATED true) 156 157 set( 158 CRYPTO_FIPS_OBJECTS 159 160 fipsmodule/bcm.o 161 ) 162 endif() 163 164 add_library( 165 crypto 166 167 $<TARGET_OBJECTS:crypto_base> 168 $<TARGET_OBJECTS:stack> 169 $<TARGET_OBJECTS:lhash> 170 $<TARGET_OBJECTS:err> 171 $<TARGET_OBJECTS:base64> 172 $<TARGET_OBJECTS:bytestring> 173 $<TARGET_OBJECTS:pool> 174 $<TARGET_OBJECTS:fipsmodule> 175 $<TARGET_OBJECTS:digest_extra> 176 $<TARGET_OBJECTS:cipher_extra> 177 $<TARGET_OBJECTS:rc4> 178 $<TARGET_OBJECTS:conf> 179 $<TARGET_OBJECTS:chacha> 180 $<TARGET_OBJECTS:poly1305> 181 $<TARGET_OBJECTS:curve25519> 182 $<TARGET_OBJECTS:fiat> 183 $<TARGET_OBJECTS:buf> 184 $<TARGET_OBJECTS:bn_extra> 185 $<TARGET_OBJECTS:bio> 186 $<TARGET_OBJECTS:rand_extra> 187 $<TARGET_OBJECTS:obj> 188 $<TARGET_OBJECTS:asn1> 189 $<TARGET_OBJECTS:engine> 190 $<TARGET_OBJECTS:dh> 191 $<TARGET_OBJECTS:dsa> 192 $<TARGET_OBJECTS:rsa_extra> 193 $<TARGET_OBJECTS:ec_extra> 194 $<TARGET_OBJECTS:ecdh> 195 $<TARGET_OBJECTS:ecdsa_extra> 196 $<TARGET_OBJECTS:cmac> 197 $<TARGET_OBJECTS:evp> 198 $<TARGET_OBJECTS:hkdf> 199 $<TARGET_OBJECTS:pem> 200 $<TARGET_OBJECTS:x509> 201 $<TARGET_OBJECTS:x509v3> 202 $<TARGET_OBJECTS:pkcs7> 203 $<TARGET_OBJECTS:pkcs8_lib> 204 205 ${CRYPTO_FIPS_OBJECTS} 206 ) 207 208 if(FIPS_DELOCATE) 209 add_dependencies(crypto bcm_o_target) 210 endif() 211 212 SET_TARGET_PROPERTIES(crypto PROPERTIES LINKER_LANGUAGE C) 213 214 if(NOT MSVC AND NOT ANDROID) 215 target_link_libraries(crypto pthread) 216 endif() 217 218 # TODO(davidben): Convert the remaining tests to GTest. 219 add_executable( 220 crypto_test 221 222 asn1/asn1_test.cc 223 base64/base64_test.cc 224 buf/buf_test.cc 225 bio/bio_test.cc 226 bytestring/bytestring_test.cc 227 chacha/chacha_test.cc 228 cipher_extra/aead_test.cc 229 cipher_extra/cipher_test.cc 230 cmac/cmac_test.cc 231 compiler_test.cc 232 constant_time_test.cc 233 curve25519/ed25519_test.cc 234 curve25519/spake25519_test.cc 235 curve25519/x25519_test.cc 236 ecdh/ecdh_test.cc 237 dh/dh_test.cc 238 digest_extra/digest_test.cc 239 dsa/dsa_test.cc 240 err/err_test.cc 241 evp/evp_extra_test.cc 242 evp/evp_test.cc 243 evp/pbkdf_test.cc 244 evp/scrypt_test.cc 245 fipsmodule/aes/aes_test.cc 246 fipsmodule/bn/bn_test.cc 247 fipsmodule/ec/ec_test.cc 248 fipsmodule/ec/p256-x86_64_test.cc 249 fipsmodule/ecdsa/ecdsa_test.cc 250 fipsmodule/modes/gcm_test.cc 251 fipsmodule/rand/ctrdrbg_test.cc 252 hkdf/hkdf_test.cc 253 hmac_extra/hmac_test.cc 254 lhash/lhash_test.cc 255 obj/obj_test.cc 256 pkcs7/pkcs7_test.cc 257 pkcs8/pkcs8_test.cc 258 pkcs8/pkcs12_test.cc 259 poly1305/poly1305_test.cc 260 pool/pool_test.cc 261 refcount_test.cc 262 rsa_extra/rsa_test.cc 263 self_test.cc 264 test/file_test_gtest.cc 265 thread_test.cc 266 x509/x509_test.cc 267 x509v3/tab_test.cc 268 x509v3/v3name_test.cc 269 270 $<TARGET_OBJECTS:crypto_test_data> 271 $<TARGET_OBJECTS:boringssl_gtest_main> 272 $<TARGET_OBJECTS:test_support> 273 ) 274 275 target_link_libraries(crypto_test crypto boringssl_gtest) 276 if (WIN32) 277 target_link_libraries(crypto_test ws2_32) 278 endif() 279 add_dependencies(all_tests crypto_test) 280