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 5 import("ssl/flags.gni") 6 7 crypto_minimal_sources = [ 8 "hmac.cc", 9 "hmac.h", 10 "hmac_win.cc", 11 "secure_util.cc", 12 "secure_util.h", 13 "symmetric_key.h", 14 "symmetric_key_win.cc", 15 "third_party/nss/chromium-sha256.h", 16 "third_party/nss/sha512.cc", 17 ] 18 19 component("crypto") { 20 external = true 21 output_name = "crcrypto" # Avoid colliding with OpenSSL's libcrypto. 22 sources = [ 23 "apple_keychain.h", 24 "apple_keychain_ios.mm", 25 "apple_keychain_mac.mm", 26 "capi_util.cc", 27 "capi_util.h", 28 "crypto_export.h", 29 "crypto_module_blocking_password_delegate.h", 30 "cssm_init.cc", 31 "cssm_init.h", 32 "curve25519.cc", 33 "curve25519.h", 34 "curve25519-donna.c", 35 "ghash.cc", 36 "ghash.h", 37 "ec_private_key.h", 38 "ec_private_key_nss.cc", 39 "ec_private_key_openssl.cc", 40 "ec_signature_creator.cc", 41 "ec_signature_creator.h", 42 "ec_signature_creator_impl.h", 43 "ec_signature_creator_nss.cc", 44 "ec_signature_creator_openssl.cc", 45 "encryptor.cc", 46 "encryptor.h", 47 "encryptor_nss.cc", 48 "encryptor_openssl.cc", 49 "hkdf.cc", 50 "hkdf.h", 51 "hmac_nss.cc", 52 "hmac_openssl.cc", 53 "mac_security_services_lock.cc", 54 "mac_security_services_lock.h", 55 # TODO(brettw) these mocks should be moved to a test_support_crypto target 56 # if possible. 57 "mock_apple_keychain.cc", 58 "mock_apple_keychain.h", 59 "mock_apple_keychain_ios.cc", 60 "mock_apple_keychain_mac.cc", 61 "p224_spake.cc", 62 "p224_spake.h", 63 "nss_util.cc", 64 "nss_util.h", 65 "nss_util_internal.h", 66 "openpgp_symmetric_encryption.cc", 67 "openpgp_symmetric_encryption.h", 68 "openssl_util.cc", 69 "openssl_util.h", 70 "p224.cc", 71 "p224.h", 72 "random.h", 73 "random.cc", 74 "rsa_private_key.cc", 75 "rsa_private_key.h", 76 "rsa_private_key_nss.cc", 77 "rsa_private_key_openssl.cc", 78 "scoped_capi_types.h", 79 "scoped_nss_types.h", 80 "secure_hash.h", 81 "secure_hash_default.cc", 82 "secure_hash_openssl.cc", 83 "sha2.cc", 84 "sha2.h", 85 "signature_creator.h", 86 "signature_creator_nss.cc", 87 "signature_creator_openssl.cc", 88 "signature_verifier.h", 89 "signature_verifier_nss.cc", 90 "signature_verifier_openssl.cc", 91 "symmetric_key_nss.cc", 92 "symmetric_key_openssl.cc", 93 "third_party/nss/chromium-blapi.h", 94 "third_party/nss/chromium-blapit.h", 95 "third_party/nss/chromium-nss.h", 96 "third_party/nss/pk11akey.cc", 97 "third_party/nss/rsawrapr.c", 98 "third_party/nss/secsign.cc", 99 ] 100 101 deps = [ 102 "//base", 103 "//base/third_party/dynamic_annotations", 104 "//crypto/ssl:metassl", 105 ] 106 forward_dependent_configs_from = [ "//crypto/ssl:metassl" ] 107 108 if (!is_mac && !is_ios) { 109 sources -= [ 110 "apple_keychain.h", 111 "mock_apple_keychain.cc", 112 "mock_apple_keychain.h", 113 ] 114 } 115 116 if (!is_linux) { 117 if (use_nss) { # Removed for non-NSS in all cases below. 118 sources -= [ 119 "openpgp_symmetric_encryption.cc", 120 "openpgp_symmetric_encryption.h", 121 ] 122 } 123 } 124 if (!is_mac) { 125 sources -= [ 126 "cssm_init.cc", 127 "cssm_init.h", 128 "mac_security_services_lock.cc", 129 "mac_security_services_lock.h", 130 ] 131 } 132 if (!is_win) { 133 sources -= [ 134 "capi_util.cc", 135 "capi_util.h", 136 ] 137 } 138 139 if (use_nss) { 140 configs += "//third_party/nss:nss_linux_config" 141 } else { 142 sources -= [ 143 "ec_private_key_nss.cc", 144 "ec_signature_creator_nss.cc", 145 "encryptor_nss.cc", 146 "hmac_nss.cc", 147 "nss_util.cc", 148 "nss_util.h", 149 "rsa_private_key_nss.cc", 150 "secure_hash_default.cc", 151 "signature_creator_nss.cc", 152 "signature_verifier_nss.cc", 153 "symmetric_key_nss.cc", 154 "third_party/nss/chromium-blapi.h", 155 "third_party/nss/chromium-blapit.h", 156 "third_party/nss/chromium-nss.h", 157 "third_party/nss/pk11akey.cc", 158 "third_party/nss/rsawrapr.c", 159 "third_party/nss/secsign.cc", 160 ] 161 } 162 if (!use_openssl) { 163 sources -= [ 164 "ec_private_key_openssl.cc", 165 "ec_signature_creator_openssl.cc", 166 "encryptor_openssl.cc", 167 "hmac_openssl.cc", 168 "openssl_util.cc", 169 "openssl_util.h", 170 "rsa_private_key_openssl.cc", 171 "secure_hash_openssl.cc", 172 "signature_creator_openssl.cc", 173 "signature_verifier_openssl.cc", 174 "symmetric_key_openssl.cc", 175 ] 176 } 177 178 defines = [ "CRYPTO_IMPLEMENTATION" ] 179 180 # TODO(brettw) once GYP compat is no longer necessary, just move 181 # crypto_minimal_sources to the crypto_minimal target and include a 182 # dependency on it here. 183 sources += crypto_minimal_sources 184 } 185 186 # A minimal crypto subset for core features that small standalone targets can 187 # use to reduce code size. 188 static_library("crypto_minimal") { 189 external = true 190 sources = crypto_minimal_sources 191 192 deps = [ 193 "//base", 194 "//base/third_party/dynamic_annotations", 195 ] 196 197 defines = [ "CRYPTO_IMPLEMENTATION" ] 198 } 199 200 test("crypto_unittests") { 201 external = true 202 sources = [ 203 # Infrastructure files. 204 "run_all_unittests.cc", 205 206 # Tests. 207 "curve25519_unittest.cc", 208 "ec_private_key_unittest.cc", 209 "ec_signature_creator_unittest.cc", 210 "encryptor_unittest.cc", 211 "ghash_unittest.cc", 212 "hkdf_unittest.cc", 213 "hmac_unittest.cc", 214 "nss_util_unittest.cc", 215 "p224_unittest.cc", 216 "p224_spake_unittest.cc", 217 "random_unittest.cc", 218 "rsa_private_key_unittest.cc", 219 "rsa_private_key_nss_unittest.cc", 220 "secure_hash_unittest.cc", 221 "sha2_unittest.cc", 222 "signature_creator_unittest.cc", 223 "signature_verifier_unittest.cc", 224 "symmetric_key_unittest.cc", 225 "openpgp_symmetric_encryption_unittest.cc", 226 ] 227 228 if (use_openssl) { 229 sources -= [ 230 "nss_util_unittest.cc", 231 "openpgp_symmetric_encryption_unittest.cc", 232 "rsa_private_key_nss_unittest,cc", 233 ] 234 } 235 236 deps = [ 237 ":crypto", 238 "//base", 239 "//base:test_support_base", 240 "//testing:gmock", 241 "//testing:gtest", 242 ] 243 244 if (is_mac) { 245 #deps += "//third_party/nss:nspr" 246 } 247 } 248