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")
6 import("//testing/test.gni")
9 output_name = "crcrypto" # Avoid colliding with OpenSSL's libcrypto.
14 "apple_keychain_ios.mm",
15 "apple_keychain_mac.mm",
25 "ec_private_key_nss.cc",
26 "ec_private_key_openssl.cc",
27 "ec_signature_creator.cc",
28 "ec_signature_creator.h",
29 "ec_signature_creator_impl.h",
30 "ec_signature_creator_nss.cc",
31 "ec_signature_creator_openssl.cc",
35 "encryptor_openssl.cc",
44 "mac_security_services_lock.cc",
45 "mac_security_services_lock.h",
47 # TODO(brettw) these mocks should be moved to a test_support_crypto target
49 "mock_apple_keychain.cc",
50 "mock_apple_keychain.h",
51 "mock_apple_keychain_ios.cc",
52 "mock_apple_keychain_mac.cc",
57 "nss_util_internal.h",
58 "openssl_bio_string.cc",
59 "openssl_bio_string.h",
70 "rsa_private_key_nss.cc",
71 "rsa_private_key_openssl.cc",
72 "scoped_capi_types.h",
75 "secure_hash_default.cc",
76 "secure_hash_openssl.cc",
81 "signature_creator.h",
82 "signature_creator_nss.cc",
83 "signature_creator_openssl.cc",
84 "signature_verifier.h",
85 "signature_verifier_nss.cc",
86 "signature_verifier_openssl.cc",
88 "symmetric_key_nss.cc",
89 "symmetric_key_openssl.cc",
90 "third_party/nss/chromium-blapi.h",
91 "third_party/nss/chromium-blapit.h",
92 "third_party/nss/chromium-nss.h",
93 "third_party/nss/chromium-sha256.h",
94 "third_party/nss/pk11akey.cc",
95 "third_party/nss/rsawrapr.c",
96 "third_party/nss/secsign.cc",
97 "third_party/nss/sha512.cc",
100 # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
101 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
106 "//base/third_party/dynamic_annotations",
109 if (!is_mac && !is_ios) {
112 "mock_apple_keychain.cc",
113 "mock_apple_keychain.h",
121 "mac_security_services_lock.cc",
122 "mac_security_services_lock.h",
133 deps += [ "//third_party/android_tools:cpu_features" ]
137 # Remove NSS files when using OpenSSL
139 "ec_private_key_nss.cc",
140 "ec_signature_creator_nss.cc",
143 "rsa_private_key_nss.cc",
144 "secure_hash_default.cc",
145 "signature_creator_nss.cc",
146 "signature_verifier_nss.cc",
147 "symmetric_key_nss.cc",
148 "third_party/nss/chromium-blapi.h",
149 "third_party/nss/chromium-blapit.h",
150 "third_party/nss/chromium-nss.h",
151 "third_party/nss/pk11akey.cc",
152 "third_party/nss/rsawrapr.c",
153 "third_party/nss/secsign.cc",
156 # Remove OpenSSL when using NSS.
160 "ec_private_key_openssl.cc",
161 "ec_signature_creator_openssl.cc",
162 "encryptor_openssl.cc",
164 "openssl_bio_string.cc",
165 "openssl_bio_string.h",
168 "rsa_private_key_openssl.cc",
169 "secure_hash_openssl.cc",
170 "signature_creator_openssl.cc",
171 "signature_verifier_openssl.cc",
172 "symmetric_key_openssl.cc",
176 # Some files are built when NSS is used at all, either for the internal crypto
177 # library or the platform certificate library.
178 if (use_openssl && !use_nss_certs) {
184 "nss_util_internal.h",
188 defines = [ "CRYPTO_IMPLEMENTATION" ]
191 # TODO(GYP): TODO(dpranke), fix the compile errors for this stuff
193 if (false && is_win) {
194 # A minimal crypto subset for hmac-related stuff that small standalone
195 # targets can use to reduce code size on Windows. This does not depend on
196 # OpenSSL/NSS but will use Windows APIs for that functionality.
197 source_set("crypto_minimal_win") {
203 "scoped_capi_types.h",
204 "scoped_nss_types.h",
208 "symmetric_key_win.cc",
209 "third_party/nss/chromium-blapi.h",
210 "third_party/nss/chromium-sha256.h",
211 "third_party/nss/sha512.cc",
216 "//base/third_party/dynamic_annotations",
219 defines = [ "CRYPTO_IMPLEMENTATION" ]
223 test("crypto_unittests") {
226 "curve25519_unittest.cc",
227 "ec_private_key_unittest.cc",
228 "ec_signature_creator_unittest.cc",
229 "encryptor_unittest.cc",
233 "nss_key_util_unittest.cc",
234 "nss_util_unittest.cc",
235 "openssl_bio_string_unittest.cc",
236 "p224_spake_unittest.cc",
238 "random_unittest.cc",
239 "rsa_private_key_unittest.cc",
240 "secure_hash_unittest.cc",
242 "signature_creator_unittest.cc",
243 "signature_verifier_unittest.cc",
244 "symmetric_key_unittest.cc",
247 # Some files are built when NSS is used at all, either for the internal crypto
248 # library or the platform certificate library.
249 if (use_openssl && !use_nss_certs) {
251 "nss_key_util_unittest.cc",
252 "nss_util_unittest.cc",
257 sources -= [ "openssl_bio_string_unittest.cc" ]
260 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
267 "//base/test:run_all_unittests",
268 "//base/test:test_support",
274 source_set("test_support") {
276 "scoped_test_nss_chromeos_user.cc",
277 "scoped_test_nss_chromeos_user.h",
278 "scoped_test_nss_db.cc",
279 "scoped_test_nss_db.h",
280 "scoped_test_system_nss_key_slot.cc",
281 "scoped_test_system_nss_key_slot.h",
289 if (!use_nss_certs) {
291 "scoped_test_nss_db.cc",
292 "scoped_test_nss_db.h",
298 "scoped_test_nss_chromeos_user.cc",
299 "scoped_test_nss_chromeos_user.h",
300 "scoped_test_system_nss_key_slot.cc",
301 "scoped_test_system_nss_key_slot.h",
306 config("platform_config") {
307 if ((!use_openssl || use_nss_certs) && is_clang) {
308 # There is a broken header guard in /usr/include/nss/secmod.h:
309 # https://bugzilla.mozilla.org/show_bug.cgi?id=884072
310 cflags = [ "-Wno-header-guard" ]
314 # This is a meta-target that forwards to NSS's SSL library or OpenSSL,
315 # according to the state of the crypto flags. A target just wanting to depend
316 # on the current SSL library should just depend on this.
320 "//third_party/boringssl",
324 "//net/third_party/nss/ssl:libssl",
328 # Link in NSS if it is used for either the internal crypto library
329 # (!use_openssl) or platform certificate library (use_nss_certs).
330 if (!use_openssl || use_nss_certs) {
332 # On Linux, we use the system NSS (excepting SSL where we always use our
334 public_configs = [ ":platform_config" ]
336 # If using a bundled copy of NSS's SSL library, ensure the bundled SSL
337 # header search path comes before the system one so our versions are
338 # used. The libssl target will add the search path we want, but
339 # according to GN's ordering rules, public_configs' search path will get
340 # applied before ones inherited from our dependencies. Therefore, we
341 # need to explicitly list our custom libssl's config here before the
343 public_configs += [ "//net/third_party/nss/ssl:ssl_config" ]
345 public_configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
347 # Non-Linux platforms use the hermetic NSS from the tree.
349 "//third_party/nss:nspr",
350 "//third_party/nss:nss",