• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/buildflag_header.gni")
6import("//build/config/chromeos/ui_mode.gni")
7import("//components/nacl/toolchain.gni")
8import("//crypto/features.gni")
9import("//testing/test.gni")
10
11buildflag_header("buildflags") {
12  header = "crypto_buildflags.h"
13  flags = [ "USE_NSS_CERTS=$use_nss_certs" ]
14}
15
16component("crypto") {
17  output_name = "crcrypto"  # Avoid colliding with OpenSSL's libcrypto.
18  sources = [
19    "aead.cc",
20    "aead.h",
21    "crypto_export.h",
22    "ec_private_key.cc",
23    "ec_private_key.h",
24    "ec_signature_creator.cc",
25    "ec_signature_creator.h",
26    "ec_signature_creator_impl.cc",
27    "ec_signature_creator_impl.h",
28    "encryptor.cc",
29    "encryptor.h",
30    "hkdf.cc",
31    "hkdf.h",
32    "hmac.cc",
33    "hmac.h",
34    "openssl_util.cc",
35    "openssl_util.h",
36    "p224_spake.cc",
37    "p224_spake.h",
38    "random.cc",
39    "random.h",
40    "rsa_private_key.cc",
41    "rsa_private_key.h",
42    "scoped_nss_types.h",
43    "secure_hash.cc",
44    "secure_hash.h",
45    "secure_util.cc",
46    "secure_util.h",
47    "sha2.cc",
48    "sha2.h",
49    "signature_creator.cc",
50    "signature_creator.h",
51    "signature_verifier.cc",
52    "signature_verifier.h",
53    "symmetric_key.cc",
54    "symmetric_key.h",
55    "unexportable_key.cc",
56    "unexportable_key.h",
57    "unexportable_key_metrics.cc",
58    "unexportable_key_metrics.h",
59    "unexportable_key_software_unsecure.cc",
60  ]
61
62  deps = [ "//base/third_party/dynamic_annotations" ]
63
64  public_deps = [
65    ":buildflags",
66    "//base",
67    "//third_party/boringssl",
68  ]
69
70  if (is_apple) {
71    sources += [
72      "apple_keychain.h",
73
74      # TODO(brettw): these mocks should be moved to a test_support_crypto
75      # target if possible.
76      "mock_apple_keychain.cc",
77      "mock_apple_keychain.h",
78    ]
79
80    if (is_mac) {
81      sources += [
82        "apple_keychain_mac.cc",
83
84        # TODO(brettw): these mocks should be moved to a test_support_crypto
85        # target if possible.
86        "mock_apple_keychain_mac.cc",
87      ]
88    }
89    if (is_ios) {
90      sources += [
91        "apple_keychain_ios.mm",
92
93        # TODO(brettw): these mocks should be moved to a test_support_crypto
94        # target if possible.
95        "mock_apple_keychain_ios.cc",
96      ]
97    }
98
99    frameworks = [
100      "CoreFoundation.framework",
101      "Security.framework",
102    ]
103  }
104
105  if (is_mac) {
106    sources += [
107      "mac_security_services_lock.cc",
108      "mac_security_services_lock.h",
109    ]
110  }
111  if (is_win) {
112    sources += [
113      "scoped_capi_types.h",
114      "scoped_cng_types.h",
115      "unexportable_key_win.cc",
116    ]
117    libs = [ "ncrypt.lib" ]
118  }
119
120  # Some files are built when NSS is used for the platform certificate library.
121  if (use_nss_certs) {
122    sources += [
123      "nss_crypto_module_delegate.h",
124      "nss_key_util.cc",
125      "nss_key_util.h",
126      "nss_util.cc",
127      "nss_util.h",
128      "nss_util_internal.h",
129    ]
130    deps += [
131      "//build:chromeos_buildflags",
132      "//components/nacl/common:buildflags",
133    ]
134    configs += [ "//build/config/linux/nss" ]
135  }
136
137  if (is_chromeos_ash && !is_minimal_toolchain) {
138    sources += [ "nss_util_chromeos.cc" ]
139  }
140
141  if (is_chromeos && !is_minimal_toolchain) {
142    sources += [
143      "chaps_support.cc",
144      "chaps_support.h",
145    ]
146  }
147
148  defines = [ "CRYPTO_IMPLEMENTATION" ]
149}
150
151test("crypto_unittests") {
152  sources = [
153    "aead_unittest.cc",
154    "ec_private_key_unittest.cc",
155    "ec_signature_creator_unittest.cc",
156    "encryptor_unittest.cc",
157    "hmac_unittest.cc",
158    "p224_spake_unittest.cc",
159    "random_unittest.cc",
160    "rsa_private_key_unittest.cc",
161    "secure_hash_unittest.cc",
162    "sha2_unittest.cc",
163    "signature_creator_unittest.cc",
164    "signature_verifier_unittest.cc",
165    "symmetric_key_unittest.cc",
166    "unexportable_key_unittest.cc",
167  ]
168
169  if (is_win) {
170    sources += [ "unexportable_key_metrics_unittest.cc" ]
171  }
172
173  # Some files are built when NSS is used for the platform certificate library.
174  if (use_nss_certs) {
175    sources += [
176      "nss_key_util_unittest.cc",
177      "nss_util_unittest.cc",
178    ]
179    configs += [ "//build/config/linux/nss" ]
180  }
181
182  deps = [
183    ":crypto",
184    ":test_support",
185    "//base",
186    "//base/test:run_all_unittests",
187    "//base/test:test_support",
188    "//testing/gmock",
189    "//testing/gtest",
190  ]
191}
192
193static_library("test_support") {
194  testonly = true
195  sources = [
196    "scoped_mock_unexportable_key_provider.cc",
197    "scoped_mock_unexportable_key_provider.h",
198  ]
199
200  if (use_nss_certs) {
201    sources += [
202      "scoped_test_nss_db.cc",
203      "scoped_test_nss_db.h",
204    ]
205    configs += [ "//build/config/linux/nss" ]
206  }
207
208  if (is_chromeos_ash) {
209    sources += [
210      "scoped_test_nss_chromeos_user.cc",
211      "scoped_test_nss_chromeos_user.h",
212      "scoped_test_system_nss_key_slot.cc",
213      "scoped_test_system_nss_key_slot.h",
214    ]
215  }
216
217  deps = [
218    ":crypto",
219    "//base",
220  ]
221}
222