[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
[email protected] | 3ad0946b | 2014-02-24 21:29:49 | [diff] [blame] | 5 | import("//build/config/crypto.gni") |
qsr | fb5251d1 | 2015-01-21 15:57:22 | [diff] [blame] | 6 | import("//testing/test.gni") |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 7 | |
| 8 | component("crypto") { |
[email protected] | 6a0f277 | 2013-10-03 17:16:11 | [diff] [blame] | 9 | output_name = "crcrypto" # Avoid colliding with OpenSSL's libcrypto. |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 10 | sources = [ |
| 11 | "apple_keychain.h", |
| 12 | "apple_keychain_ios.mm", |
| 13 | "apple_keychain_mac.mm", |
| 14 | "capi_util.cc", |
| 15 | "capi_util.h", |
| 16 | "crypto_export.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 17 | "cssm_init.cc", |
| 18 | "cssm_init.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 19 | "curve25519-donna.c", |
scottmg | 7c7296f4 | 2015-02-28 02:23:09 | [diff] [blame] | 20 | "curve25519.cc", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 21 | "curve25519.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 22 | "ec_private_key.h", |
| 23 | "ec_private_key_nss.cc", |
| 24 | "ec_private_key_openssl.cc", |
| 25 | "ec_signature_creator.cc", |
| 26 | "ec_signature_creator.h", |
| 27 | "ec_signature_creator_impl.h", |
| 28 | "ec_signature_creator_nss.cc", |
| 29 | "ec_signature_creator_openssl.cc", |
| 30 | "encryptor.cc", |
| 31 | "encryptor.h", |
| 32 | "encryptor_nss.cc", |
| 33 | "encryptor_openssl.cc", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 34 | "ghash.cc", |
| 35 | "ghash.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 36 | "hkdf.cc", |
| 37 | "hkdf.h", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 38 | "hmac.cc", |
| 39 | "hmac.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 40 | "hmac_nss.cc", |
| 41 | "hmac_openssl.cc", |
| 42 | "mac_security_services_lock.cc", |
| 43 | "mac_security_services_lock.h", |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 44 | |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 45 | # TODO(brettw) these mocks should be moved to a test_support_crypto target |
| 46 | # if possible. |
| 47 | "mock_apple_keychain.cc", |
| 48 | "mock_apple_keychain.h", |
| 49 | "mock_apple_keychain_ios.cc", |
| 50 | "mock_apple_keychain_mac.cc", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 51 | "nss_util.cc", |
| 52 | "nss_util.h", |
| 53 | "nss_util_internal.h", |
pwestin | b8f385c6 | 2014-10-27 15:46:15 | [diff] [blame] | 54 | "openssl_bio_string.cc", |
| 55 | "openssl_bio_string.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 56 | "openssl_util.cc", |
| 57 | "openssl_util.h", |
| 58 | "p224.cc", |
| 59 | "p224.h", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 60 | "p224_spake.cc", |
| 61 | "p224_spake.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 62 | "random.cc", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 63 | "random.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 64 | "rsa_private_key.cc", |
| 65 | "rsa_private_key.h", |
| 66 | "rsa_private_key_nss.cc", |
| 67 | "rsa_private_key_openssl.cc", |
| 68 | "scoped_capi_types.h", |
| 69 | "scoped_nss_types.h", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 70 | "secure_hash.h", |
scottmg | 7c7296f4 | 2015-02-28 02:23:09 | [diff] [blame] | 71 | "secure_hash_default.cc", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 72 | "secure_hash_openssl.cc", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 73 | "secure_util.cc", |
| 74 | "secure_util.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 75 | "sha2.cc", |
| 76 | "sha2.h", |
| 77 | "signature_creator.h", |
| 78 | "signature_creator_nss.cc", |
| 79 | "signature_creator_openssl.cc", |
| 80 | "signature_verifier.h", |
| 81 | "signature_verifier_nss.cc", |
| 82 | "signature_verifier_openssl.cc", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 83 | "symmetric_key.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 84 | "symmetric_key_nss.cc", |
| 85 | "symmetric_key_openssl.cc", |
| 86 | "third_party/nss/chromium-blapi.h", |
| 87 | "third_party/nss/chromium-blapit.h", |
| 88 | "third_party/nss/chromium-nss.h", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 89 | "third_party/nss/chromium-sha256.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 90 | "third_party/nss/pk11akey.cc", |
| 91 | "third_party/nss/rsawrapr.c", |
| 92 | "third_party/nss/secsign.cc", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 93 | "third_party/nss/sha512.cc", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 94 | ] |
| 95 | |
brettw | d1c719a | 2015-02-19 23:17:04 | [diff] [blame] | 96 | # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. |
| 97 | configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] |
| 98 | |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 99 | deps = [ |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 100 | ":platform", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 101 | "//base", |
| 102 | "//base/third_party/dynamic_annotations", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 103 | ] |
| 104 | |
| 105 | if (!is_mac && !is_ios) { |
| 106 | sources -= [ |
| 107 | "apple_keychain.h", |
| 108 | "mock_apple_keychain.cc", |
| 109 | "mock_apple_keychain.h", |
| 110 | ] |
| 111 | } |
| 112 | |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 113 | if (!is_mac) { |
| 114 | sources -= [ |
| 115 | "cssm_init.cc", |
| 116 | "cssm_init.h", |
| 117 | "mac_security_services_lock.cc", |
| 118 | "mac_security_services_lock.h", |
| 119 | ] |
| 120 | } |
| 121 | if (!is_win) { |
| 122 | sources -= [ |
| 123 | "capi_util.cc", |
| 124 | "capi_util.h", |
| 125 | ] |
| 126 | } |
| 127 | |
[email protected] | ff6d096 | 2014-05-22 23:21:23 | [diff] [blame] | 128 | if (is_android) { |
| 129 | deps += [ "//third_party/android_tools:cpu_features" ] |
| 130 | } |
| 131 | |
[email protected] | ab9ce6e | 2014-04-17 20:33:19 | [diff] [blame] | 132 | if (use_openssl) { |
| 133 | # Remove NSS files when using OpenSSL |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 134 | sources -= [ |
| 135 | "ec_private_key_nss.cc", |
| 136 | "ec_signature_creator_nss.cc", |
| 137 | "encryptor_nss.cc", |
| 138 | "hmac_nss.cc", |
| 139 | "nss_util.cc", |
| 140 | "nss_util.h", |
[email protected] | 190933f | 2014-07-28 09:56:51 | [diff] [blame] | 141 | "nss_util_internal.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 142 | "rsa_private_key_nss.cc", |
| 143 | "secure_hash_default.cc", |
| 144 | "signature_creator_nss.cc", |
| 145 | "signature_verifier_nss.cc", |
| 146 | "symmetric_key_nss.cc", |
| 147 | "third_party/nss/chromium-blapi.h", |
| 148 | "third_party/nss/chromium-blapit.h", |
| 149 | "third_party/nss/chromium-nss.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 150 | "third_party/nss/pk11akey.cc", |
| 151 | "third_party/nss/rsawrapr.c", |
| 152 | "third_party/nss/secsign.cc", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 153 | ] |
[email protected] | ab9ce6e | 2014-04-17 20:33:19 | [diff] [blame] | 154 | } else { |
| 155 | # Remove OpenSSL when using NSS. |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 156 | sources -= [ |
| 157 | "ec_private_key_openssl.cc", |
| 158 | "ec_signature_creator_openssl.cc", |
| 159 | "encryptor_openssl.cc", |
| 160 | "hmac_openssl.cc", |
pwestin | b8f385c6 | 2014-10-27 15:46:15 | [diff] [blame] | 161 | "openssl_bio_string.cc", |
| 162 | "openssl_bio_string.h", |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 163 | "openssl_util.cc", |
| 164 | "openssl_util.h", |
| 165 | "rsa_private_key_openssl.cc", |
| 166 | "secure_hash_openssl.cc", |
| 167 | "signature_creator_openssl.cc", |
| 168 | "signature_verifier_openssl.cc", |
| 169 | "symmetric_key_openssl.cc", |
| 170 | ] |
| 171 | } |
| 172 | |
| 173 | defines = [ "CRYPTO_IMPLEMENTATION" ] |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 174 | } |
| 175 | |
dpranke | 4376059 | 2014-11-08 02:59:57 | [diff] [blame] | 176 | # TODO(GYP): TODO(dpranke), fix the compile errors for this stuff |
| 177 | # and make it work. |
| 178 | if (false && is_win) { |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 179 | # A minimal crypto subset for hmac-related stuff that small standalone |
| 180 | # targets can use to reduce code size on Windows. This does not depend on |
| 181 | # OpenSSL/NSS but will use Windows APIs for that functionality. |
| 182 | source_set("crypto_minimal_win") { |
| 183 | sources = [ |
[email protected] | 59ff2d4 | 2014-04-22 22:25:23 | [diff] [blame] | 184 | "crypto_export.h", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 185 | "hmac.cc", |
| 186 | "hmac.h", |
| 187 | "hmac_win.cc", |
[email protected] | 59ff2d4 | 2014-04-22 22:25:23 | [diff] [blame] | 188 | "scoped_capi_types.h", |
| 189 | "scoped_nss_types.h", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 190 | "secure_util.cc", |
| 191 | "secure_util.h", |
| 192 | "symmetric_key.h", |
| 193 | "symmetric_key_win.cc", |
[email protected] | 59ff2d4 | 2014-04-22 22:25:23 | [diff] [blame] | 194 | "third_party/nss/chromium-blapi.h", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 195 | "third_party/nss/chromium-sha256.h", |
| 196 | "third_party/nss/sha512.cc", |
| 197 | ] |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 198 | |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 199 | deps = [ |
| 200 | "//base", |
| 201 | "//base/third_party/dynamic_annotations", |
| 202 | ] |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 203 | |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 204 | defines = [ "CRYPTO_IMPLEMENTATION" ] |
| 205 | } |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 206 | } |
| 207 | |
brettw | 690c9667 | 2015-04-21 16:19:54 | [diff] [blame^] | 208 | test("crypto_unittests") { |
| 209 | sources = [ |
| 210 | # Tests. |
| 211 | "curve25519_unittest.cc", |
| 212 | "ec_private_key_unittest.cc", |
| 213 | "ec_signature_creator_unittest.cc", |
| 214 | "encryptor_unittest.cc", |
| 215 | "ghash_unittest.cc", |
| 216 | "hkdf_unittest.cc", |
| 217 | "hmac_unittest.cc", |
| 218 | "nss_util_unittest.cc", |
| 219 | "openssl_bio_string_unittest.cc", |
| 220 | "p224_spake_unittest.cc", |
| 221 | "p224_unittest.cc", |
| 222 | "random_unittest.cc", |
| 223 | "rsa_private_key_nss_unittest.cc", |
| 224 | "rsa_private_key_unittest.cc", |
| 225 | "secure_hash_unittest.cc", |
| 226 | "sha2_unittest.cc", |
| 227 | "signature_creator_unittest.cc", |
| 228 | "signature_verifier_unittest.cc", |
| 229 | "symmetric_key_unittest.cc", |
| 230 | ] |
dpranke | 4376059 | 2014-11-08 02:59:57 | [diff] [blame] | 231 | |
brettw | 690c9667 | 2015-04-21 16:19:54 | [diff] [blame^] | 232 | if (use_openssl || !is_linux) { |
| 233 | sources -= [ "rsa_private_key_nss_unittest.cc" ] |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 234 | } |
brettw | 690c9667 | 2015-04-21 16:19:54 | [diff] [blame^] | 235 | |
| 236 | if (use_openssl) { |
| 237 | sources -= [ "nss_util_unittest.cc" ] |
| 238 | } else { |
| 239 | sources -= [ "openssl_bio_string_unittest.cc" ] |
| 240 | } |
| 241 | |
| 242 | configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] |
| 243 | |
| 244 | deps = [ |
| 245 | ":crypto", |
| 246 | ":platform", |
| 247 | ":test_support", |
| 248 | "//base", |
| 249 | "//base/test:run_all_unittests", |
| 250 | "//base/test:test_support", |
| 251 | "//testing/gmock", |
| 252 | "//testing/gtest", |
| 253 | ] |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 254 | } |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 255 | |
[email protected] | 190933f | 2014-07-28 09:56:51 | [diff] [blame] | 256 | source_set("test_support") { |
| 257 | sources = [ |
[email protected] | 190933f | 2014-07-28 09:56:51 | [diff] [blame] | 258 | "scoped_test_nss_chromeos_user.cc", |
| 259 | "scoped_test_nss_chromeos_user.h", |
scottmg | 7c7296f4 | 2015-02-28 02:23:09 | [diff] [blame] | 260 | "scoped_test_nss_db.cc", |
| 261 | "scoped_test_nss_db.h", |
[email protected] | 190933f | 2014-07-28 09:56:51 | [diff] [blame] | 262 | "scoped_test_system_nss_key_slot.cc", |
| 263 | "scoped_test_system_nss_key_slot.h", |
| 264 | ] |
| 265 | deps = [ |
| 266 | ":crypto", |
| 267 | ":platform", |
| 268 | "//base", |
| 269 | ] |
| 270 | |
| 271 | if (!use_nss_certs) { |
| 272 | sources -= [ |
| 273 | "scoped_test_nss_db.cc", |
| 274 | "scoped_test_nss_db.h", |
| 275 | ] |
| 276 | } |
| 277 | |
| 278 | if (!is_chromeos) { |
| 279 | sources -= [ |
| 280 | "scoped_test_nss_chromeos_user.cc", |
| 281 | "scoped_test_nss_chromeos_user.h", |
| 282 | "scoped_test_system_nss_key_slot.cc", |
| 283 | "scoped_test_system_nss_key_slot.h", |
| 284 | ] |
| 285 | } |
| 286 | } |
| 287 | |
brettw | 70d2f6e | 2015-02-25 18:46:53 | [diff] [blame] | 288 | config("platform_config") { |
| 289 | if (!use_openssl && is_clang) { |
| 290 | # There is a broken header guard in /usr/include/nss/secmod.h: |
| 291 | # https://bugzilla.mozilla.org/show_bug.cgi?id=884072 |
| 292 | cflags = [ "-Wno-header-guard" ] |
| 293 | } |
| 294 | } |
| 295 | |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 296 | # This is a meta-target that forwards to NSS's SSL library or OpenSSL, |
| 297 | # according to the state of the crypto flags. A target just wanting to depend |
| 298 | # on the current SSL library should just depend on this. |
| 299 | group("platform") { |
| 300 | if (use_openssl) { |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 301 | deps = [ |
| 302 | "//third_party/boringssl", |
| 303 | ] |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 304 | } else { |
scottmg | 34fb7e5 | 2014-12-03 23:27:24 | [diff] [blame] | 305 | deps = [ |
| 306 | "//net/third_party/nss/ssl:libssl", |
| 307 | ] |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 308 | if (is_linux) { |
| 309 | # On Linux, we use the system NSS (excepting SSL where we always use our |
| 310 | # own). |
[email protected] | 4625ade | 2014-04-15 19:26:44 | [diff] [blame] | 311 | # |
| 312 | # We always need our SSL header search path to come before the system one |
| 313 | # so our versions are used. The libssl target will add the search path we |
Brett Wilson | e5389527 | 2014-09-23 23:41:46 | [diff] [blame] | 314 | # want, but according to GN's ordering rules, public_configs' search path |
| 315 | # will get applied before ones inherited from our dependencies. |
| 316 | # Therefore, we need to explicitly list our custom libssl's config here |
| 317 | # before the system one. |
| 318 | public_configs = [ |
brettw | 70d2f6e | 2015-02-25 18:46:53 | [diff] [blame] | 319 | ":platform_config", |
[email protected] | 4625ade | 2014-04-15 19:26:44 | [diff] [blame] | 320 | "//net/third_party/nss/ssl:ssl_config", |
| 321 | "//third_party/nss:system_nss_no_ssl_config", |
[email protected] | 7a7e085 | 2014-04-14 23:25:13 | [diff] [blame] | 322 | ] |
| 323 | } else { |
| 324 | # Non-Linux platforms use the hermetic NSS from the tree. |
| 325 | deps += [ |
| 326 | "//third_party/nss:nspr", |
| 327 | "//third_party/nss:nss", |
| 328 | ] |
| 329 | } |
[email protected] | c6f27f2 | 2013-08-21 21:44:59 | [diff] [blame] | 330 | } |
| 331 | } |