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",
55 "nss_util_internal.h",
56 "openssl_bio_string.cc",
57 "openssl_bio_string.h",
68 "rsa_private_key_nss.cc",
69 "rsa_private_key_openssl.cc",
70 "scoped_capi_types.h",
73 "secure_hash_default.cc",
74 "secure_hash_openssl.cc",
79 "signature_creator.h",
80 "signature_creator_nss.cc",
81 "signature_creator_openssl.cc",
82 "signature_verifier.h",
83 "signature_verifier_nss.cc",
84 "signature_verifier_openssl.cc",
86 "symmetric_key_nss.cc",
87 "symmetric_key_openssl.cc",
88 "third_party/nss/chromium-blapi.h",
89 "third_party/nss/chromium-blapit.h",
90 "third_party/nss/chromium-nss.h",
91 "third_party/nss/chromium-sha256.h",
92 "third_party/nss/pk11akey.cc",
93 "third_party/nss/rsawrapr.c",
94 "third_party/nss/secsign.cc",
95 "third_party/nss/sha512.cc",
98 # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
99 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
104 "//base/third_party/dynamic_annotations",
107 if (!is_mac && !is_ios) {
110 "mock_apple_keychain.cc",
111 "mock_apple_keychain.h",
119 "mac_security_services_lock.cc",
120 "mac_security_services_lock.h",
131 deps += [ "//third_party/android_tools:cpu_features" ]
135 # Remove NSS files when using OpenSSL
137 "ec_private_key_nss.cc",
138 "ec_signature_creator_nss.cc",
141 "rsa_private_key_nss.cc",
142 "secure_hash_default.cc",
143 "signature_creator_nss.cc",
144 "signature_verifier_nss.cc",
145 "symmetric_key_nss.cc",
146 "third_party/nss/chromium-blapi.h",
147 "third_party/nss/chromium-blapit.h",
148 "third_party/nss/chromium-nss.h",
149 "third_party/nss/pk11akey.cc",
150 "third_party/nss/rsawrapr.c",
151 "third_party/nss/secsign.cc",
154 # Remove OpenSSL when using NSS.
158 "ec_private_key_openssl.cc",
159 "ec_signature_creator_openssl.cc",
160 "encryptor_openssl.cc",
162 "openssl_bio_string.cc",
163 "openssl_bio_string.h",
166 "rsa_private_key_openssl.cc",
167 "secure_hash_openssl.cc",
168 "signature_creator_openssl.cc",
169 "signature_verifier_openssl.cc",
170 "symmetric_key_openssl.cc",
174 # Remove nss_util when NSS is used for neither the internal crypto library
175 # nor the platform certificate library.
176 if (use_openssl && !use_nss_certs) {
180 "nss_util_internal.h",
184 defines = [ "CRYPTO_IMPLEMENTATION" ]
187 # TODO(GYP): TODO(dpranke), fix the compile errors for this stuff
189 if (false && is_win) {
190 # A minimal crypto subset for hmac-related stuff that small standalone
191 # targets can use to reduce code size on Windows. This does not depend on
192 # OpenSSL/NSS but will use Windows APIs for that functionality.
193 source_set("crypto_minimal_win") {
199 "scoped_capi_types.h",
200 "scoped_nss_types.h",
204 "symmetric_key_win.cc",
205 "third_party/nss/chromium-blapi.h",
206 "third_party/nss/chromium-sha256.h",
207 "third_party/nss/sha512.cc",
212 "//base/third_party/dynamic_annotations",
215 defines = [ "CRYPTO_IMPLEMENTATION" ]
219 test("crypto_unittests") {
222 "curve25519_unittest.cc",
223 "ec_private_key_unittest.cc",
224 "ec_signature_creator_unittest.cc",
225 "encryptor_unittest.cc",
229 "nss_util_unittest.cc",
230 "openssl_bio_string_unittest.cc",
231 "p224_spake_unittest.cc",
233 "random_unittest.cc",
234 "rsa_private_key_nss_unittest.cc",
235 "rsa_private_key_unittest.cc",
236 "secure_hash_unittest.cc",
238 "signature_creator_unittest.cc",
239 "signature_verifier_unittest.cc",
240 "symmetric_key_unittest.cc",
243 # Remove nss_util when NSS is used for neither the internal crypto library
244 # nor the platform certificate library.
245 if (use_openssl && !use_nss_certs) {
246 sources -= [ "nss_util_unittest.cc" ]
250 sources -= [ "rsa_private_key_nss_unittest.cc" ]
252 sources -= [ "openssl_bio_string_unittest.cc" ]
255 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
262 "//base/test:run_all_unittests",
263 "//base/test:test_support",
269 source_set("test_support") {
271 "scoped_test_nss_chromeos_user.cc",
272 "scoped_test_nss_chromeos_user.h",
273 "scoped_test_nss_db.cc",
274 "scoped_test_nss_db.h",
275 "scoped_test_system_nss_key_slot.cc",
276 "scoped_test_system_nss_key_slot.h",
284 if (!use_nss_certs) {
286 "scoped_test_nss_db.cc",
287 "scoped_test_nss_db.h",
293 "scoped_test_nss_chromeos_user.cc",
294 "scoped_test_nss_chromeos_user.h",
295 "scoped_test_system_nss_key_slot.cc",
296 "scoped_test_system_nss_key_slot.h",
301 config("platform_config") {
302 if ((!use_openssl || use_nss_certs) && is_clang) {
303 # There is a broken header guard in /usr/include/nss/secmod.h:
304 # https://bugzilla.mozilla.org/show_bug.cgi?id=884072
305 cflags = [ "-Wno-header-guard" ]
309 # This is a meta-target that forwards to NSS's SSL library or OpenSSL,
310 # according to the state of the crypto flags. A target just wanting to depend
311 # on the current SSL library should just depend on this.
315 "//third_party/boringssl",
319 "//net/third_party/nss/ssl:libssl",
323 # Link in NSS if it is used for either the internal crypto library
324 # (!use_openssl) or platform certificate library (use_nss_certs).
325 if (!use_openssl || use_nss_certs) {
327 # On Linux, we use the system NSS (excepting SSL where we always use our
329 public_configs = [ ":platform_config" ]
331 # If using a bundled copy of NSS's SSL library, ensure the bundled SSL
332 # header search path comes before the system one so our versions are
333 # used. The libssl target will add the search path we want, but
334 # according to GN's ordering rules, public_configs' search path will get
335 # applied before ones inherited from our dependencies. Therefore, we
336 # need to explicitly list our custom libssl's config here before the
338 public_configs += [ "//net/third_party/nss/ssl:ssl_config" ]
340 public_configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
342 # Non-Linux platforms use the hermetic NSS from the tree.
344 "//third_party/nss:nspr",
345 "//third_party/nss:nss",