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) |
Adam Vartanian | bfcf3a7 | 2018-08-10 14:55:24 +0100 | [diff] [blame] | 132 | if(OPENSSL_NO_ASM) |
| 133 | # If OPENSSL_NO_ASM was defined then ASM will not have been enabled, but in |
| 134 | # FIPS mode we have to have it because the module build requires going via |
| 135 | # textual assembly. |
| 136 | enable_language(ASM) |
| 137 | endif() |
| 138 | |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 139 | add_library( |
| 140 | bcm_c_generated_asm |
| 141 | |
| 142 | STATIC |
| 143 | |
| 144 | bcm.c |
| 145 | ) |
| 146 | |
Robert Sloan | 726e9d1 | 2018-09-11 11:45:04 -0700 | [diff] [blame] | 147 | add_dependencies(bcm_c_generated_asm global_target) |
| 148 | |
Robert Sloan | 2424d84 | 2017-05-01 07:46:28 -0700 | [diff] [blame] | 149 | set_target_properties(bcm_c_generated_asm PROPERTIES COMPILE_OPTIONS "-S") |
| 150 | set_target_properties(bcm_c_generated_asm PROPERTIES POSITION_INDEPENDENT_CODE ON) |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 151 | |
Robert Sloan | f573be7 | 2018-09-17 15:29:11 -0700 | [diff] [blame] | 152 | go_executable(delocate boringssl.googlesource.com/boringssl/util/fipstools/delocate) |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 153 | add_custom_command( |
| 154 | OUTPUT bcm-delocated.S |
Robert Sloan | f573be7 | 2018-09-17 15:29:11 -0700 | [diff] [blame] | 155 | COMMAND ./delocate -a $<TARGET_FILE:bcm_c_generated_asm> -o bcm-delocated.S ${BCM_ASM_SOURCES} |
| 156 | DEPENDS bcm_c_generated_asm delocate ${BCM_ASM_SOURCES} |
| 157 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 158 | ) |
| 159 | |
| 160 | add_library( |
| 161 | bcm_hashunset |
| 162 | |
| 163 | STATIC |
| 164 | |
| 165 | bcm-delocated.S |
| 166 | ) |
| 167 | |
Robert Sloan | 726e9d1 | 2018-09-11 11:45:04 -0700 | [diff] [blame] | 168 | add_dependencies(bcm_hashunset global_target) |
| 169 | |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 170 | set_target_properties(bcm_hashunset PROPERTIES POSITION_INDEPENDENT_CODE ON) |
| 171 | set_target_properties(bcm_hashunset PROPERTIES LINKER_LANGUAGE C) |
| 172 | |
Robert Sloan | f068def | 2018-10-10 18:45:40 -0700 | [diff] [blame] | 173 | go_executable(inject_hash |
| 174 | boringssl.googlesource.com/boringssl/util/fipstools/inject_hash) |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 175 | add_custom_command( |
| 176 | OUTPUT bcm.o |
Robert Sloan | f068def | 2018-10-10 18:45:40 -0700 | [diff] [blame] | 177 | COMMAND ./inject_hash -o bcm.o -in-archive $<TARGET_FILE:bcm_hashunset> |
| 178 | DEPENDS bcm_hashunset inject_hash |
Robert Sloan | f573be7 | 2018-09-17 15:29:11 -0700 | [diff] [blame] | 179 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 180 | ) |
| 181 | |
| 182 | # The outputs of add_custom_command cannot be referenced outside of the |
| 183 | # CMakeLists.txt that defines it. Thus we have to wrap bcm.o in a custom target |
| 184 | # so that crypto can depend on it. |
| 185 | add_custom_target(bcm_o_target DEPENDS bcm.o) |
| 186 | |
| 187 | add_library( |
| 188 | fipsmodule |
| 189 | |
| 190 | OBJECT |
| 191 | |
| 192 | is_fips.c |
| 193 | ) |
| 194 | |
Robert Sloan | 726e9d1 | 2018-09-11 11:45:04 -0700 | [diff] [blame] | 195 | add_dependencies(fipsmodule global_target) |
| 196 | |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 197 | set_target_properties(fipsmodule PROPERTIES LINKER_LANGUAGE C) |
| 198 | else() |
| 199 | add_library( |
| 200 | fipsmodule |
| 201 | |
| 202 | OBJECT |
| 203 | |
| 204 | bcm.c |
| 205 | is_fips.c |
| 206 | |
| 207 | ${BCM_ASM_SOURCES} |
| 208 | ) |
Robert Sloan | 726e9d1 | 2018-09-11 11:45:04 -0700 | [diff] [blame] | 209 | |
| 210 | add_dependencies(fipsmodule global_target) |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 211 | endif() |