blob: 479fe420459ed858a0155632f004f721840493f2 [file] [log] [blame]
[email protected]c6f27f22013-08-21 21:44:591# 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
[email protected]3ad0946b2014-02-24 21:29:495import("//build/config/crypto.gni")
qsrfb5251d12015-01-21 15:57:226import("//testing/test.gni")
[email protected]c6f27f22013-08-21 21:44:597
sergeyu99d83f92015-09-14 23:03:338component("crypto") {
9 output_name = "crcrypto" # Avoid colliding with OpenSSL's libcrypto.
10 sources = [
svaldez22de42fe2016-04-21 19:42:2211 "aead.cc",
12 "aead.h",
sergeyu99d83f92015-09-14 23:03:3313 "apple_keychain.h",
14 "apple_keychain_ios.mm",
15 "apple_keychain_mac.mm",
davidben7dad2a32016-03-01 23:47:4716 "auto_cbb.h",
sergeyu99d83f92015-09-14 23:03:3317 "capi_util.cc",
18 "capi_util.h",
19 "crypto_export.h",
20 "cssm_init.cc",
21 "cssm_init.h",
svaldez22de42fe2016-04-21 19:42:2222 "curve25519.cc",
sergeyu99d83f92015-09-14 23:03:3323 "curve25519.h",
svaldez22de42fe2016-04-21 19:42:2224 "ec_private_key.cc",
sergeyu99d83f92015-09-14 23:03:3325 "ec_private_key.h",
sergeyu99d83f92015-09-14 23:03:3326 "ec_signature_creator.cc",
27 "ec_signature_creator.h",
svaldeze83af292016-04-26 14:33:3728 "ec_signature_creator_impl.cc",
sergeyu99d83f92015-09-14 23:03:3329 "ec_signature_creator_impl.h",
sergeyu99d83f92015-09-14 23:03:3330 "encryptor.cc",
31 "encryptor.h",
sergeyu99d83f92015-09-14 23:03:3332 "hkdf.cc",
33 "hkdf.h",
34 "hmac.cc",
35 "hmac.h",
sergeyu99d83f92015-09-14 23:03:3336 "mac_security_services_lock.cc",
37 "mac_security_services_lock.h",
[email protected]c6f27f22013-08-21 21:44:5938
sergeyu99d83f92015-09-14 23:03:3339 # TODO(brettw) these mocks should be moved to a test_support_crypto target
40 # if possible.
41 "mock_apple_keychain.cc",
42 "mock_apple_keychain.h",
43 "mock_apple_keychain_ios.cc",
44 "mock_apple_keychain_mac.cc",
45 "nss_key_util.cc",
46 "nss_key_util.h",
47 "nss_util.cc",
48 "nss_util.h",
49 "nss_util_internal.h",
50 "openssl_bio_string.cc",
51 "openssl_bio_string.h",
52 "openssl_util.cc",
53 "openssl_util.h",
54 "p224.cc",
55 "p224.h",
56 "p224_spake.cc",
57 "p224_spake.h",
58 "random.cc",
59 "random.h",
svaldez22de42fe2016-04-21 19:42:2260 "rsa_private_key.cc",
sergeyu99d83f92015-09-14 23:03:3361 "rsa_private_key.h",
sergeyu99d83f92015-09-14 23:03:3362 "scoped_capi_types.h",
63 "scoped_nss_types.h",
svaldez22de42fe2016-04-21 19:42:2264 "secure_hash.cc",
sergeyu99d83f92015-09-14 23:03:3365 "secure_hash.h",
sergeyu99d83f92015-09-14 23:03:3366 "secure_util.cc",
67 "secure_util.h",
68 "sha2.cc",
69 "sha2.h",
svaldez22de42fe2016-04-21 19:42:2270 "signature_creator.cc",
sergeyu99d83f92015-09-14 23:03:3371 "signature_creator.h",
svaldez22de42fe2016-04-21 19:42:2272 "signature_verifier.cc",
sergeyu99d83f92015-09-14 23:03:3373 "signature_verifier.h",
svaldez9c641462016-05-02 20:49:0574 "symmetric_key.cc",
sergeyu99d83f92015-09-14 23:03:3375 "symmetric_key.h",
sergeyu99d83f92015-09-14 23:03:3376 ]
77
78 # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
79 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
80
81 deps = [
82 ":platform",
83 "//base",
84 "//base/third_party/dynamic_annotations",
85 ]
86
87 if (!is_mac && !is_ios) {
88 sources -= [
89 "apple_keychain.h",
erikcheneece6c32015-07-07 22:13:1190 "mock_apple_keychain.cc",
91 "mock_apple_keychain.h",
sergeyu99d83f92015-09-14 23:03:3392 ]
sdefresne41b86902016-03-17 18:09:2393 } else {
94 libs = [ "Security.framework" ]
sergeyu99d83f92015-09-14 23:03:3395 }
96
97 if (!is_mac) {
98 sources -= [
99 "cssm_init.cc",
100 "cssm_init.h",
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
svaldez2135be52016-04-20 16:34:53112 # Some files are built when NSS is used for the platform certificate library.
113 if (!use_nss_certs) {
sergeyu99d83f92015-09-14 23:03:33114 sources -= [
davidben85bad9e2015-05-11 20:20:10115 "nss_key_util.cc",
116 "nss_key_util.h",
davidben2bcbc6b2015-04-22 02:36:41117 "nss_util.cc",
118 "nss_util.h",
119 "nss_util_internal.h",
120 ]
sergeyu99d83f92015-09-14 23:03:33121 }
davidben2bcbc6b2015-04-22 02:36:41122
sergeyu99d83f92015-09-14 23:03:33123 defines = [ "CRYPTO_IMPLEMENTATION" ]
erikcheneece6c32015-07-07 22:13:11124
sergeyu99d83f92015-09-14 23:03:33125 if (is_nacl) {
126 deps += [ "//native_client_sdk/src/libraries/nacl_io" ]
erikcheneece6c32015-07-07 22:13:11127 }
[email protected]c6f27f22013-08-21 21:44:59128}
129
dpranke43760592014-11-08 02:59:57130# TODO(GYP): TODO(dpranke), fix the compile errors for this stuff
131# and make it work.
132if (false && is_win) {
[email protected]7a7e0852014-04-14 23:25:13133 # A minimal crypto subset for hmac-related stuff that small standalone
134 # targets can use to reduce code size on Windows. This does not depend on
135 # OpenSSL/NSS but will use Windows APIs for that functionality.
136 source_set("crypto_minimal_win") {
137 sources = [
[email protected]59ff2d42014-04-22 22:25:23138 "crypto_export.h",
[email protected]7a7e0852014-04-14 23:25:13139 "hmac.cc",
140 "hmac.h",
svaldez9c641462016-05-02 20:49:05141 "openssl_util.cc",
142 "openssl_util.h",
[email protected]7a7e0852014-04-14 23:25:13143 "secure_util.cc",
144 "secure_util.h",
svaldez9c641462016-05-02 20:49:05145 "symmetric_key.cc",
[email protected]7a7e0852014-04-14 23:25:13146 "symmetric_key.h",
[email protected]7a7e0852014-04-14 23:25:13147 ]
[email protected]c6f27f22013-08-21 21:44:59148
[email protected]7a7e0852014-04-14 23:25:13149 deps = [
150 "//base",
151 "//base/third_party/dynamic_annotations",
152 ]
[email protected]c6f27f22013-08-21 21:44:59153
[email protected]7a7e0852014-04-14 23:25:13154 defines = [ "CRYPTO_IMPLEMENTATION" ]
155 }
[email protected]c6f27f22013-08-21 21:44:59156}
157
brettw690c96672015-04-21 16:19:54158test("crypto_unittests") {
159 sources = [
svaldez22de42fe2016-04-21 19:42:22160 "aead_unittest.cc",
brettw690c96672015-04-21 16:19:54161 "curve25519_unittest.cc",
162 "ec_private_key_unittest.cc",
163 "ec_signature_creator_unittest.cc",
164 "encryptor_unittest.cc",
brettw690c96672015-04-21 16:19:54165 "hkdf_unittest.cc",
166 "hmac_unittest.cc",
davidben85bad9e2015-05-11 20:20:10167 "nss_key_util_unittest.cc",
brettw690c96672015-04-21 16:19:54168 "nss_util_unittest.cc",
169 "openssl_bio_string_unittest.cc",
170 "p224_spake_unittest.cc",
171 "p224_unittest.cc",
172 "random_unittest.cc",
brettw690c96672015-04-21 16:19:54173 "rsa_private_key_unittest.cc",
174 "secure_hash_unittest.cc",
175 "sha2_unittest.cc",
176 "signature_creator_unittest.cc",
177 "signature_verifier_unittest.cc",
178 "symmetric_key_unittest.cc",
179 ]
dpranke43760592014-11-08 02:59:57180
svaldez2135be52016-04-20 16:34:53181 # Some files are built when NSS is used for the platform certificate library.
182 if (!use_nss_certs) {
davidben85bad9e2015-05-11 20:20:10183 sources -= [
184 "nss_key_util_unittest.cc",
185 "nss_util_unittest.cc",
186 ]
[email protected]7a7e0852014-04-14 23:25:13187 }
brettw690c96672015-04-21 16:19:54188
brettw690c96672015-04-21 16:19:54189 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
190
191 deps = [
192 ":crypto",
193 ":platform",
194 ":test_support",
195 "//base",
196 "//base/test:run_all_unittests",
197 "//base/test:test_support",
198 "//testing/gmock",
199 "//testing/gtest",
200 ]
[email protected]7a7e0852014-04-14 23:25:13201}
[email protected]c6f27f22013-08-21 21:44:59202
[email protected]190933f2014-07-28 09:56:51203source_set("test_support") {
204 sources = [
[email protected]190933f2014-07-28 09:56:51205 "scoped_test_nss_chromeos_user.cc",
206 "scoped_test_nss_chromeos_user.h",
scottmg7c7296f42015-02-28 02:23:09207 "scoped_test_nss_db.cc",
208 "scoped_test_nss_db.h",
[email protected]190933f2014-07-28 09:56:51209 "scoped_test_system_nss_key_slot.cc",
210 "scoped_test_system_nss_key_slot.h",
211 ]
212 deps = [
213 ":crypto",
214 ":platform",
215 "//base",
216 ]
217
218 if (!use_nss_certs) {
219 sources -= [
220 "scoped_test_nss_db.cc",
221 "scoped_test_nss_db.h",
222 ]
223 }
224
225 if (!is_chromeos) {
226 sources -= [
227 "scoped_test_nss_chromeos_user.cc",
228 "scoped_test_nss_chromeos_user.h",
229 "scoped_test_system_nss_key_slot.cc",
230 "scoped_test_system_nss_key_slot.h",
231 ]
232 }
233}
234
brettw70d2f6e2015-02-25 18:46:53235config("platform_config") {
svaldez2135be52016-04-20 16:34:53236 if (use_nss_certs && is_clang) {
brettw70d2f6e2015-02-25 18:46:53237 # There is a broken header guard in /usr/include/nss/secmod.h:
238 # https://bugzilla.mozilla.org/show_bug.cgi?id=884072
239 cflags = [ "-Wno-header-guard" ]
240 }
241}
242
[email protected]7a7e0852014-04-14 23:25:13243# This is a meta-target that forwards to NSS's SSL library or OpenSSL,
244# according to the state of the crypto flags. A target just wanting to depend
245# on the current SSL library should just depend on this.
246group("platform") {
svaldez2135be52016-04-20 16:34:53247 public_deps = [
248 "//third_party/boringssl",
249 ]
davidben2bcbc6b2015-04-22 02:36:41250
svaldez2135be52016-04-20 16:34:53251 # Link in NSS if it is used for the platform certificate library
252 # (use_nss_certs).
253 if (use_nss_certs) {
254 public_configs = [ ":platform_config" ]
255 public_configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
[email protected]c6f27f22013-08-21 21:44:59256 }
257}