Upload upstream chromium 67.0.3396
[platform/framework/web/chromium-efl.git] / crypto / BUILD.gn
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
5 import("//build/config/crypto.gni")
6 import("//testing/test.gni")
7
8 component("crypto") {
9   output_name = "crcrypto"  # Avoid colliding with OpenSSL's libcrypto.
10   sources = [
11     "aead.cc",
12     "aead.h",
13     "apple_keychain.h",
14     "apple_keychain_ios.mm",
15     "apple_keychain_mac.mm",
16     "capi_util.cc",
17     "capi_util.h",
18     "crypto_export.h",
19     "ec_private_key.cc",
20     "ec_private_key.h",
21     "ec_signature_creator.cc",
22     "ec_signature_creator.h",
23     "ec_signature_creator_impl.cc",
24     "ec_signature_creator_impl.h",
25     "encryptor.cc",
26     "encryptor.h",
27     "hkdf.cc",
28     "hkdf.h",
29     "hmac.cc",
30     "hmac.h",
31     "mac_security_services_lock.cc",
32     "mac_security_services_lock.h",
33
34     # TODO(brettw) these mocks should be moved to a test_support_crypto target
35     # if possible.
36     "mock_apple_keychain.cc",
37     "mock_apple_keychain.h",
38     "mock_apple_keychain_ios.cc",
39     "mock_apple_keychain_mac.cc",
40     "nss_crypto_module_delegate.h",
41     "nss_key_util.cc",
42     "nss_key_util.h",
43     "nss_util.cc",
44     "nss_util.h",
45     "nss_util_internal.h",
46     "openssl_util.cc",
47     "openssl_util.h",
48     "p224.cc",
49     "p224.h",
50     "p224_spake.cc",
51     "p224_spake.h",
52     "random.cc",
53     "random.h",
54     "rsa_private_key.cc",
55     "rsa_private_key.h",
56     "scoped_capi_types.h",
57     "scoped_nss_types.h",
58     "secure_hash.cc",
59     "secure_hash.h",
60     "secure_util.cc",
61     "secure_util.h",
62     "sha2.cc",
63     "sha2.h",
64     "signature_creator.cc",
65     "signature_creator.h",
66     "signature_verifier.cc",
67     "signature_verifier.h",
68     "symmetric_key.cc",
69     "symmetric_key.h",
70     "wincrypt_shim.h",
71   ]
72
73   # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
74   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
75
76   deps = [
77     ":platform",
78     "//base",
79     "//base/third_party/dynamic_annotations",
80   ]
81
82   public_deps = [
83     "//third_party/boringssl",
84   ]
85
86   if (!is_mac && !is_ios) {
87     sources -= [
88       "apple_keychain.h",
89       "mock_apple_keychain.cc",
90       "mock_apple_keychain.h",
91     ]
92   } else {
93     libs = [
94       "CoreFoundation.framework",
95       "Security.framework",
96     ]
97   }
98
99   if (!is_mac) {
100     sources -= [
101       "mac_security_services_lock.cc",
102       "mac_security_services_lock.h",
103     ]
104   }
105   if (!is_win) {
106     sources -= [
107       "capi_util.cc",
108       "capi_util.h",
109     ]
110   }
111
112   # Some files are built when NSS is used for the platform certificate library.
113   if (!use_nss_certs) {
114     sources -= [
115       "nss_key_util.cc",
116       "nss_key_util.h",
117       "nss_util.cc",
118       "nss_util.h",
119       "nss_util_internal.h",
120     ]
121   }
122
123   defines = [ "CRYPTO_IMPLEMENTATION" ]
124
125   if (is_nacl) {
126     deps += [ "//native_client_sdk/src/libraries/nacl_io" ]
127   }
128 }
129
130 test("crypto_unittests") {
131   sources = [
132     "aead_unittest.cc",
133     "ec_private_key_unittest.cc",
134     "ec_signature_creator_unittest.cc",
135     "encryptor_unittest.cc",
136     "hkdf_unittest.cc",
137     "hmac_unittest.cc",
138     "nss_key_util_unittest.cc",
139     "nss_util_unittest.cc",
140     "p224_spake_unittest.cc",
141     "p224_unittest.cc",
142     "random_unittest.cc",
143     "rsa_private_key_unittest.cc",
144     "secure_hash_unittest.cc",
145     "sha2_unittest.cc",
146     "signature_creator_unittest.cc",
147     "signature_verifier_unittest.cc",
148     "symmetric_key_unittest.cc",
149   ]
150
151   # Some files are built when NSS is used for the platform certificate library.
152   if (!use_nss_certs) {
153     sources -= [
154       "nss_key_util_unittest.cc",
155       "nss_util_unittest.cc",
156     ]
157   }
158
159   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
160
161   deps = [
162     ":crypto",
163     ":platform",
164     ":test_support",
165     "//base",
166     "//base/test:run_all_unittests",
167     "//base/test:test_support",
168     "//testing/gmock",
169     "//testing/gtest",
170   ]
171 }
172
173 # This has no sources in some cases so can't be a static library.
174 source_set("test_support") {
175   testonly = true
176   sources = []
177
178   if (use_nss_certs) {
179     sources += [
180       "scoped_test_nss_db.cc",
181       "scoped_test_nss_db.h",
182     ]
183   }
184
185   if (is_chromeos) {
186     sources += [
187       "scoped_test_nss_chromeos_user.cc",
188       "scoped_test_nss_chromeos_user.h",
189       "scoped_test_system_nss_key_slot.cc",
190       "scoped_test_system_nss_key_slot.h",
191     ]
192   }
193
194   deps = [
195     ":crypto",
196     ":platform",
197     "//base",
198   ]
199 }
200
201 config("platform_config") {
202   if (use_nss_certs && is_clang) {
203     # There is a broken header guard in /usr/include/nss/secmod.h:
204     # https://bugzilla.mozilla.org/show_bug.cgi?id=884072
205     cflags = [ "-Wno-header-guard" ]
206   }
207 }
208
209 # This is a meta-target that forwards to NSS's SSL library or OpenSSL,
210 # according to the state of the crypto flags. A target just wanting to depend
211 # on the current SSL library should just depend on this.
212 group("platform") {
213   public_deps = [
214     "//third_party/boringssl",
215   ]
216
217   # Link in NSS if it is used for the platform certificate library
218   # (use_nss_certs).
219   if (use_nss_certs) {
220     public_configs = [ ":platform_config" ]
221     public_configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
222   }
223 }