Add method to hide BrowserAccessibilityManager.
[chromium-blink-merge.git] / crypto / BUILD.gn
blobdd4136ae33fd9c3231f1f324d4a720f8504e7e2a
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.
5 import("//build/config/crypto.gni")
7 component("crypto") {
8   output_name = "crcrypto"  # Avoid colliding with OpenSSL's libcrypto.
9   sources = [
10     "apple_keychain.h",
11     "apple_keychain_ios.mm",
12     "apple_keychain_mac.mm",
13     "capi_util.cc",
14     "capi_util.h",
15     "crypto_export.h",
16     "cssm_init.cc",
17     "cssm_init.h",
18     "curve25519.cc",
19     "curve25519-donna.c",
20     "curve25519.h",
21     "ec_private_key.h",
22     "ec_private_key_nss.cc",
23     "ec_private_key_openssl.cc",
24     "ec_signature_creator.cc",
25     "ec_signature_creator.h",
26     "ec_signature_creator_impl.h",
27     "ec_signature_creator_nss.cc",
28     "ec_signature_creator_openssl.cc",
29     "encryptor.cc",
30     "encryptor.h",
31     "encryptor_nss.cc",
32     "encryptor_openssl.cc",
33     "ghash.cc",
34     "ghash.h",
35     "hkdf.cc",
36     "hkdf.h",
37     "hmac.cc",
38     "hmac.h",
39     "hmac_nss.cc",
40     "hmac_openssl.cc",
41     "mac_security_services_lock.cc",
42     "mac_security_services_lock.h",
43     # TODO(brettw) these mocks should be moved to a test_support_crypto target
44     # if possible.
45     "mock_apple_keychain.cc",
46     "mock_apple_keychain.h",
47     "mock_apple_keychain_ios.cc",
48     "mock_apple_keychain_mac.cc",
49     "nss_util.cc",
50     "nss_util.h",
51     "nss_util_internal.h",
52     "openssl_bio_string.cc",
53     "openssl_bio_string.h",
54     "openssl_util.cc",
55     "openssl_util.h",
56     "p224.cc",
57     "p224.h",
58     "p224_spake.cc",
59     "p224_spake.h",
60     "random.cc",
61     "random.h",
62     "rsa_private_key.cc",
63     "rsa_private_key.h",
64     "rsa_private_key_nss.cc",
65     "rsa_private_key_openssl.cc",
66     "scoped_capi_types.h",
67     "scoped_nss_types.h",
68     "secure_hash_default.cc",
69     "secure_hash.h",
70     "secure_hash_openssl.cc",
71     "secure_util.cc",
72     "secure_util.h",
73     "sha2.cc",
74     "sha2.h",
75     "signature_creator.h",
76     "signature_creator_nss.cc",
77     "signature_creator_openssl.cc",
78     "signature_verifier.h",
79     "signature_verifier_nss.cc",
80     "signature_verifier_openssl.cc",
81     "symmetric_key.h",
82     "symmetric_key_nss.cc",
83     "symmetric_key_openssl.cc",
84     "third_party/nss/chromium-blapi.h",
85     "third_party/nss/chromium-blapit.h",
86     "third_party/nss/chromium-nss.h",
87     "third_party/nss/chromium-sha256.h",
88     "third_party/nss/pk11akey.cc",
89     "third_party/nss/rsawrapr.c",
90     "third_party/nss/secsign.cc",
91     "third_party/nss/sha512.cc",
92   ]
94   deps = [
95     ":platform",
96     "//base",
97     "//base/third_party/dynamic_annotations",
98   ]
100   if (!is_mac && !is_ios) {
101     sources -= [
102       "apple_keychain.h",
103       "mock_apple_keychain.cc",
104       "mock_apple_keychain.h",
105     ]
106   }
108   if (!is_mac) {
109     sources -= [
110       "cssm_init.cc",
111       "cssm_init.h",
112       "mac_security_services_lock.cc",
113       "mac_security_services_lock.h",
114     ]
115   }
116   if (!is_win) {
117     sources -= [
118       "capi_util.cc",
119       "capi_util.h",
120     ]
121   }
123   if (is_android) {
124     deps += [ "//third_party/android_tools:cpu_features" ]
125   }
127   if (is_win) {
128     # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
129     cflags = [ "/wd4267" ]
130   }
132   if (use_openssl) {
133     # Remove NSS files when using OpenSSL
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",
141       "nss_util_internal.h",
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",
150       "third_party/nss/pk11akey.cc",
151       "third_party/nss/rsawrapr.c",
152       "third_party/nss/secsign.cc",
153     ]
154   } else {
155     # Remove OpenSSL when using NSS.
156     sources -= [
157       "ec_private_key_openssl.cc",
158       "ec_signature_creator_openssl.cc",
159       "encryptor_openssl.cc",
160       "hmac_openssl.cc",
161       "openssl_bio_string.cc",
162       "openssl_bio_string.h",
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   }
173   defines = [ "CRYPTO_IMPLEMENTATION" ]
176 # TODO(GYP): TODO(dpranke), fix the compile errors for this stuff
177 # and make it work.
178 if (false && is_win) {
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 = [
184       "crypto_export.h",
185       "hmac.cc",
186       "hmac.h",
187       "hmac_win.cc",
188       "scoped_capi_types.h",
189       "scoped_nss_types.h",
190       "secure_util.cc",
191       "secure_util.h",
192       "symmetric_key.h",
193       "symmetric_key_win.cc",
194       "third_party/nss/chromium-blapi.h",
195       "third_party/nss/chromium-sha256.h",
196       "third_party/nss/sha512.cc",
197     ]
199     deps = [
200       "//base",
201       "//base/third_party/dynamic_annotations",
202     ]
204     defines = [ "CRYPTO_IMPLEMENTATION" ]
205   }
208 # TODO(GYP): Make this link on win as well.
209 if (!is_win) {
210   test("crypto_unittests") {
211     sources = [
212       # Tests.
213       "curve25519_unittest.cc",
214       "ec_private_key_unittest.cc",
215       "ec_signature_creator_unittest.cc",
216       "encryptor_unittest.cc",
217       "ghash_unittest.cc",
218       "hkdf_unittest.cc",
219       "hmac_unittest.cc",
220       "nss_util_unittest.cc",
221       "openssl_bio_string_unittest.cc",
222       "p224_unittest.cc",
223       "p224_spake_unittest.cc",
224       "random_unittest.cc",
225       "rsa_private_key_unittest.cc",
226       "rsa_private_key_nss_unittest.cc",
227       "secure_hash_unittest.cc",
228       "sha2_unittest.cc",
229       "signature_creator_unittest.cc",
230       "signature_verifier_unittest.cc",
231       "symmetric_key_unittest.cc",
232     ]
234     if (use_openssl || !is_linux) {
235       sources -= [
236         "rsa_private_key_nss_unittest.cc",
237       ]
238     }
240     if (use_openssl) {
241       sources -= [ "nss_util_unittest.cc" ]
242     } else {
243       sources -= [ "openssl_bio_string_unittest.cc" ]
244     }
246     deps = [
247       ":crypto",
248       ":platform",
249       ":test_support",
250       "//base",
251       "//base/test:run_all_unittests",
252       "//base/test:test_support",
253       "//testing/gmock",
254       "//testing/gtest",
255     ]
256   }
259 source_set("test_support") {
260   sources = [
261     "scoped_test_nss_db.cc",
262     "scoped_test_nss_db.h",
263     "scoped_test_nss_chromeos_user.cc",
264     "scoped_test_nss_chromeos_user.h",
265     "scoped_test_system_nss_key_slot.cc",
266     "scoped_test_system_nss_key_slot.h",
267   ]
268   deps = [
269     ":crypto",
270     ":platform",
271     "//base",
272   ]
274   if (!use_nss_certs) {
275     sources -= [
276       "scoped_test_nss_db.cc",
277       "scoped_test_nss_db.h",
278     ]
279   }
281   if (!is_chromeos) {
282     sources -= [
283       "scoped_test_nss_chromeos_user.cc",
284       "scoped_test_nss_chromeos_user.h",
285       "scoped_test_system_nss_key_slot.cc",
286       "scoped_test_system_nss_key_slot.h",
287     ]
288   }
291 # This is a meta-target that forwards to NSS's SSL library or OpenSSL,
292 # according to the state of the crypto flags. A target just wanting to depend
293 # on the current SSL library should just depend on this.
294 group("platform") {
295   if (use_openssl) {
296     deps = [ "//third_party/boringssl" ]
297   } else {
298     deps = [ "//net/third_party/nss/ssl:libssl" ]
299     if (is_linux) {
300       # On Linux, we use the system NSS (excepting SSL where we always use our
301       # own).
302       #
303       # We always need our SSL header search path to come before the system one
304       # so our versions are used. The libssl target will add the search path we
305       # want, but according to GN's ordering rules, public_configs' search path
306       # will get applied before ones inherited from our dependencies.
307       # Therefore, we need to explicitly list our custom libssl's config here
308       # before the system one.
309       public_configs = [
310         "//net/third_party/nss/ssl:ssl_config",
311         "//third_party/nss:system_nss_no_ssl_config",
312       ]
313     } else {
314       # Non-Linux platforms use the hermetic NSS from the tree.
315       deps += [
316         "//third_party/nss:nspr",
317         "//third_party/nss:nss",
318       ]
319     }
320   }