Add DriveAppRegistryObserver.
[chromium-blink-merge.git] / crypto / BUILD.gn
blob110868da4c31525010fc03906dc14ef904567c7f
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     "crypto_module_blocking_password_delegate.h",
17     "cssm_init.cc",
18     "cssm_init.h",
19     "curve25519.cc",
20     "curve25519-donna.c",
21     "curve25519.h",
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",
34     "ghash.cc",
35     "ghash.h",
36     "hkdf.cc",
37     "hkdf.h",
38     "hmac.cc",
39     "hmac.h",
40     "hmac_nss.cc",
41     "hmac_openssl.cc",
42     "mac_security_services_lock.cc",
43     "mac_security_services_lock.h",
44     # TODO(brettw) these mocks should be moved to a test_support_crypto target
45     # if possible.
46     "mock_apple_keychain.cc",
47     "mock_apple_keychain.h",
48     "mock_apple_keychain_ios.cc",
49     "mock_apple_keychain_mac.cc",
50     "nss_util.cc",
51     "nss_util.h",
52     "nss_util_internal.h",
53     "openpgp_symmetric_encryption.cc",
54     "openpgp_symmetric_encryption.h",
55     "openssl_util.cc",
56     "openssl_util.h",
57     "p224.cc",
58     "p224.h",
59     "p224_spake.cc",
60     "p224_spake.h",
61     "random.cc",
62     "random.h",
63     "rsa_private_key.cc",
64     "rsa_private_key.h",
65     "rsa_private_key_nss.cc",
66     "rsa_private_key_openssl.cc",
67     "scoped_capi_types.h",
68     "scoped_nss_types.h",
69     "secure_hash_default.cc",
70     "secure_hash.h",
71     "secure_hash_openssl.cc",
72     "secure_util.cc",
73     "secure_util.h",
74     "sha2.cc",
75     "sha2.h",
76     "signature_creator.h",
77     "signature_creator_nss.cc",
78     "signature_creator_openssl.cc",
79     "signature_verifier.h",
80     "signature_verifier_nss.cc",
81     "signature_verifier_openssl.cc",
82     "symmetric_key.h",
83     "symmetric_key_nss.cc",
84     "symmetric_key_openssl.cc",
85     "third_party/nss/chromium-blapi.h",
86     "third_party/nss/chromium-blapit.h",
87     "third_party/nss/chromium-nss.h",
88     "third_party/nss/chromium-sha256.h",
89     "third_party/nss/pk11akey.cc",
90     "third_party/nss/rsawrapr.c",
91     "third_party/nss/secsign.cc",
92     "third_party/nss/sha512.cc",
93   ]
95   deps = [
96     ":platform",
97     "//base",
98     "//base/third_party/dynamic_annotations",
99   ]
101   if (!is_mac && !is_ios) {
102     sources -= [
103       "apple_keychain.h",
104       "mock_apple_keychain.cc",
105       "mock_apple_keychain.h",
106     ]
107   }
109   if (!is_linux) {
110     sources -= [
111       "openpgp_symmetric_encryption.cc",
112       "openpgp_symmetric_encryption.h",
113     ]
114     if (use_nss) {  # Removed for non-NSS in all cases below.
115       sources -= [
116         "openpgp_symmetric_encryption.cc",
117         "openpgp_symmetric_encryption.h",
118       ]
119     }
120   }
121   if (!is_mac) {
122     sources -= [
123       "cssm_init.cc",
124       "cssm_init.h",
125       "mac_security_services_lock.cc",
126       "mac_security_services_lock.h",
127     ]
128   }
129   if (!is_win) {
130     sources -= [
131       "capi_util.cc",
132       "capi_util.h",
133     ]
134   }
136   if (!use_nss) {
137     sources -= [
138       "ec_private_key_nss.cc",
139       "ec_signature_creator_nss.cc",
140       "encryptor_nss.cc",
141       "hmac_nss.cc",
142       "nss_util.cc",
143       "nss_util.h",
144       "rsa_private_key_nss.cc",
145       "secure_hash_default.cc",
146       "signature_creator_nss.cc",
147       "signature_verifier_nss.cc",
148       "symmetric_key_nss.cc",
149       "third_party/nss/chromium-blapi.h",
150       "third_party/nss/chromium-blapit.h",
151       "third_party/nss/chromium-nss.h",
152       "third_party/nss/pk11akey.cc",
153       "third_party/nss/rsawrapr.c",
154       "third_party/nss/secsign.cc",
155     ]
156   }
157   if (!use_openssl) {
158     sources -= [
159       "ec_private_key_openssl.cc",
160       "ec_signature_creator_openssl.cc",
161       "encryptor_openssl.cc",
162       "hmac_openssl.cc",
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 if (is_win) {
177   # A minimal crypto subset for hmac-related stuff that small standalone
178   # targets can use to reduce code size on Windows. This does not depend on
179   # OpenSSL/NSS but will use Windows APIs for that functionality.
180   source_set("crypto_minimal_win") {
181     sources = [
182       "hmac.cc",
183       "hmac.h",
184       "hmac_win.cc",
185       "secure_util.cc",
186       "secure_util.h",
187       "symmetric_key.h",
188       "symmetric_key_win.cc",
189       "third_party/nss/chromium-sha256.h",
190       "third_party/nss/sha512.cc",
191     ]
193     deps = [
194       "//base",
195       "//base/third_party/dynamic_annotations",
196     ]
198     defines = [ "CRYPTO_IMPLEMENTATION" ]
199   }
202 test("crypto_unittests") {
203   sources = [
204     # Tests.
205     "curve25519_unittest.cc",
206     "ec_private_key_unittest.cc",
207     "ec_signature_creator_unittest.cc",
208     "encryptor_unittest.cc",
209     "ghash_unittest.cc",
210     "hkdf_unittest.cc",
211     "hmac_unittest.cc",
212     "nss_util_unittest.cc",
213     "p224_unittest.cc",
214     "p224_spake_unittest.cc",
215     "random_unittest.cc",
216     "rsa_private_key_unittest.cc",
217     "rsa_private_key_nss_unittest.cc",
218     "secure_hash_unittest.cc",
219     "sha2_unittest.cc",
220     "signature_creator_unittest.cc",
221     "signature_verifier_unittest.cc",
222     "symmetric_key_unittest.cc",
223     "openpgp_symmetric_encryption_unittest.cc",
224   ]
226   if (use_openssl) {
227     sources -= [
228       "nss_util_unittest.cc",
229       "openpgp_symmetric_encryption_unittest.cc",
230       "rsa_private_key_nss_unittest.cc",
231     ]
232   }
234   if (use_openssl || !is_linux) {
235     sources -= [
236       "rsa_private_key_nss_unittest.cc",
237       "openpgp_symmetric_encryption_unittest.cc",
238     ]
239   }
241   if (use_openssl) {
242     sources -= [ "nss_util_unittest.cc" ]
243   }
245   deps = [
246     ":crypto",
247     ":platform",
248     "//base",
249     "//base/test:run_all_unittests",
250     "//base/test:test_support",
251     "//testing/gmock",
252     "//testing/gtest",
253   ]
256 # This is a meta-target that forwards to NSS's SSL library or OpenSSL,
257 # according to the state of the crypto flags. A target just wanting to depend
258 # on the current SSL library should just depend on this.
259 group("platform") {
260   if (use_openssl) {
261     deps = [ "//third_party/openssl" ]
262   } else {
263     deps = [ "//net/third_party/nss/ssl:libssl" ]
264     if (is_linux) {
265       # On Linux, we use the system NSS (excepting SSL where we always use our
266       # own).
267       direct_dependent_configs = [
268         "//third_party/nss:system_nss_no_ssl_config"
269       ]
270     } else {
271       # Non-Linux platforms use the hermetic NSS from the tree.
272       deps += [
273         "//third_party/nss:nspr",
274         "//third_party/nss:nss",
275       ]
276     }
277   }