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