BUILD.gn 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. import("//build/buildflag_header.gni")
  5. import("//build/config/chromeos/ui_mode.gni")
  6. import("//crypto/features.gni")
  7. import("//testing/test.gni")
  8. buildflag_header("buildflags") {
  9. header = "crypto_buildflags.h"
  10. flags = [ "USE_NSS_CERTS=$use_nss_certs" ]
  11. }
  12. component("crypto") {
  13. output_name = "crcrypto" # Avoid colliding with OpenSSL's libcrypto.
  14. sources = [
  15. "aead.cc",
  16. "aead.h",
  17. "crypto_export.h",
  18. "ec_private_key.cc",
  19. "ec_private_key.h",
  20. "ec_signature_creator.cc",
  21. "ec_signature_creator.h",
  22. "ec_signature_creator_impl.cc",
  23. "ec_signature_creator_impl.h",
  24. "encryptor.cc",
  25. "encryptor.h",
  26. "hkdf.cc",
  27. "hkdf.h",
  28. "hmac.cc",
  29. "hmac.h",
  30. "openssl_util.cc",
  31. "openssl_util.h",
  32. "p224_spake.cc",
  33. "p224_spake.h",
  34. "random.cc",
  35. "random.h",
  36. "rsa_private_key.cc",
  37. "rsa_private_key.h",
  38. "scoped_capi_types.h",
  39. "scoped_nss_types.h",
  40. "secure_hash.cc",
  41. "secure_hash.h",
  42. "secure_util.cc",
  43. "secure_util.h",
  44. "sha2.cc",
  45. "sha2.h",
  46. "signature_creator.cc",
  47. "signature_creator.h",
  48. "signature_verifier.cc",
  49. "signature_verifier.h",
  50. "symmetric_key.cc",
  51. "symmetric_key.h",
  52. "unexportable_key.cc",
  53. "unexportable_key.h",
  54. ]
  55. deps = [
  56. "//base",
  57. "//base/third_party/dynamic_annotations",
  58. ]
  59. public_deps = [
  60. ":buildflags",
  61. "//third_party/boringssl",
  62. ]
  63. if (is_apple) {
  64. sources += [
  65. "apple_keychain.h",
  66. # TODO(brettw): these mocks should be moved to a test_support_crypto
  67. # target if possible.
  68. "mock_apple_keychain.cc",
  69. "mock_apple_keychain.h",
  70. ]
  71. if (is_mac) {
  72. sources += [
  73. "apple_keychain_mac.cc",
  74. # TODO(brettw): these mocks should be moved to a test_support_crypto
  75. # target if possible.
  76. "mock_apple_keychain_mac.cc",
  77. ]
  78. }
  79. if (is_ios) {
  80. sources += [
  81. "apple_keychain_ios.mm",
  82. # TODO(brettw): these mocks should be moved to a test_support_crypto
  83. # target if possible.
  84. "mock_apple_keychain_ios.cc",
  85. ]
  86. }
  87. frameworks = [
  88. "CoreFoundation.framework",
  89. "Security.framework",
  90. ]
  91. }
  92. if (is_mac) {
  93. sources += [
  94. "mac_security_services_lock.cc",
  95. "mac_security_services_lock.h",
  96. ]
  97. }
  98. if (is_win) {
  99. sources += [
  100. "capi_util.cc",
  101. "capi_util.h",
  102. "unexportable_key_win.cc",
  103. ]
  104. libs = [ "ncrypt.lib" ]
  105. }
  106. # Some files are built when NSS is used for the platform certificate library.
  107. if (use_nss_certs) {
  108. sources += [
  109. "nss_crypto_module_delegate.h",
  110. "nss_key_util.cc",
  111. "nss_key_util.h",
  112. "nss_util.cc",
  113. "nss_util.h",
  114. "nss_util_internal.h",
  115. ]
  116. deps += [ "//build:chromeos_buildflags" ]
  117. configs += [ "//build/config/linux/nss" ]
  118. }
  119. if (is_chromeos_ash) {
  120. sources += [ "nss_util_chromeos.cc" ]
  121. }
  122. if (is_chromeos || is_chromeos_lacros) {
  123. sources += [
  124. "chaps_support.cc",
  125. "chaps_support.h",
  126. ]
  127. }
  128. defines = [ "CRYPTO_IMPLEMENTATION" ]
  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. "hmac_unittest.cc",
  137. "p224_spake_unittest.cc",
  138. "random_unittest.cc",
  139. "rsa_private_key_unittest.cc",
  140. "secure_hash_unittest.cc",
  141. "sha2_unittest.cc",
  142. "signature_creator_unittest.cc",
  143. "signature_verifier_unittest.cc",
  144. "symmetric_key_unittest.cc",
  145. "unexportable_key_unittest.cc",
  146. ]
  147. # Some files are built when NSS is used for the platform certificate library.
  148. if (use_nss_certs) {
  149. sources += [
  150. "nss_key_util_unittest.cc",
  151. "nss_util_unittest.cc",
  152. ]
  153. configs += [ "//build/config/linux/nss" ]
  154. }
  155. deps = [
  156. ":crypto",
  157. ":test_support",
  158. "//base",
  159. "//base/test:run_all_unittests",
  160. "//base/test:test_support",
  161. "//testing/gmock",
  162. "//testing/gtest",
  163. ]
  164. }
  165. static_library("test_support") {
  166. testonly = true
  167. sources = [
  168. "scoped_mock_unexportable_key_provider.cc",
  169. "scoped_mock_unexportable_key_provider.h",
  170. ]
  171. if (use_nss_certs) {
  172. sources += [
  173. "scoped_test_nss_db.cc",
  174. "scoped_test_nss_db.h",
  175. ]
  176. configs += [ "//build/config/linux/nss" ]
  177. }
  178. if (is_chromeos_ash) {
  179. sources += [
  180. "scoped_test_nss_chromeos_user.cc",
  181. "scoped_test_nss_chromeos_user.h",
  182. "scoped_test_system_nss_key_slot.cc",
  183. "scoped_test_system_nss_key_slot.h",
  184. ]
  185. }
  186. deps = [
  187. ":crypto",
  188. "//base",
  189. ]
  190. }