| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/crypto.gni") | 5 import("//build/config/crypto.gni") |
| 6 | 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") { | 7 component("crypto") { |
| 20 output_name = "crcrypto" # Avoid colliding with OpenSSL's libcrypto. | 8 output_name = "crcrypto" # Avoid colliding with OpenSSL's libcrypto. |
| 21 sources = [ | 9 sources = [ |
| 22 "apple_keychain.h", | 10 "apple_keychain.h", |
| 23 "apple_keychain_ios.mm", | 11 "apple_keychain_ios.mm", |
| 24 "apple_keychain_mac.mm", | 12 "apple_keychain_mac.mm", |
| 25 "capi_util.cc", | 13 "capi_util.cc", |
| 26 "capi_util.h", | 14 "capi_util.h", |
| 27 "crypto_export.h", | 15 "crypto_export.h", |
| 28 "crypto_module_blocking_password_delegate.h", | 16 "crypto_module_blocking_password_delegate.h", |
| 29 "cssm_init.cc", | 17 "cssm_init.cc", |
| 30 "cssm_init.h", | 18 "cssm_init.h", |
| 31 "curve25519.cc", | 19 "curve25519.cc", |
| 20 "curve25519-donna.c", |
| 32 "curve25519.h", | 21 "curve25519.h", |
| 33 "curve25519-donna.c", | |
| 34 "ghash.cc", | |
| 35 "ghash.h", | |
| 36 "ec_private_key.h", | 22 "ec_private_key.h", |
| 37 "ec_private_key_nss.cc", | 23 "ec_private_key_nss.cc", |
| 38 "ec_private_key_openssl.cc", | 24 "ec_private_key_openssl.cc", |
| 39 "ec_signature_creator.cc", | 25 "ec_signature_creator.cc", |
| 40 "ec_signature_creator.h", | 26 "ec_signature_creator.h", |
| 41 "ec_signature_creator_impl.h", | 27 "ec_signature_creator_impl.h", |
| 42 "ec_signature_creator_nss.cc", | 28 "ec_signature_creator_nss.cc", |
| 43 "ec_signature_creator_openssl.cc", | 29 "ec_signature_creator_openssl.cc", |
| 44 "encryptor.cc", | 30 "encryptor.cc", |
| 45 "encryptor.h", | 31 "encryptor.h", |
| 46 "encryptor_nss.cc", | 32 "encryptor_nss.cc", |
| 47 "encryptor_openssl.cc", | 33 "encryptor_openssl.cc", |
| 34 "ghash.cc", |
| 35 "ghash.h", |
| 48 "hkdf.cc", | 36 "hkdf.cc", |
| 49 "hkdf.h", | 37 "hkdf.h", |
| 38 "hmac.cc", |
| 39 "hmac.h", |
| 50 "hmac_nss.cc", | 40 "hmac_nss.cc", |
| 51 "hmac_openssl.cc", | 41 "hmac_openssl.cc", |
| 52 "mac_security_services_lock.cc", | 42 "mac_security_services_lock.cc", |
| 53 "mac_security_services_lock.h", | 43 "mac_security_services_lock.h", |
| 54 # TODO(brettw) these mocks should be moved to a test_support_crypto target | 44 # TODO(brettw) these mocks should be moved to a test_support_crypto target |
| 55 # if possible. | 45 # if possible. |
| 56 "mock_apple_keychain.cc", | 46 "mock_apple_keychain.cc", |
| 57 "mock_apple_keychain.h", | 47 "mock_apple_keychain.h", |
| 58 "mock_apple_keychain_ios.cc", | 48 "mock_apple_keychain_ios.cc", |
| 59 "mock_apple_keychain_mac.cc", | 49 "mock_apple_keychain_mac.cc", |
| 60 "p224_spake.cc", | |
| 61 "p224_spake.h", | |
| 62 "nss_util.cc", | 50 "nss_util.cc", |
| 63 "nss_util.h", | 51 "nss_util.h", |
| 64 "nss_util_internal.h", | 52 "nss_util_internal.h", |
| 65 "openpgp_symmetric_encryption.cc", | 53 "openpgp_symmetric_encryption.cc", |
| 66 "openpgp_symmetric_encryption.h", | 54 "openpgp_symmetric_encryption.h", |
| 67 "openssl_util.cc", | 55 "openssl_util.cc", |
| 68 "openssl_util.h", | 56 "openssl_util.h", |
| 69 "p224.cc", | 57 "p224.cc", |
| 70 "p224.h", | 58 "p224.h", |
| 59 "p224_spake.cc", |
| 60 "p224_spake.h", |
| 61 "random.cc", |
| 71 "random.h", | 62 "random.h", |
| 72 "random.cc", | |
| 73 "rsa_private_key.cc", | 63 "rsa_private_key.cc", |
| 74 "rsa_private_key.h", | 64 "rsa_private_key.h", |
| 75 "rsa_private_key_nss.cc", | 65 "rsa_private_key_nss.cc", |
| 76 "rsa_private_key_openssl.cc", | 66 "rsa_private_key_openssl.cc", |
| 77 "scoped_capi_types.h", | 67 "scoped_capi_types.h", |
| 78 "scoped_nss_types.h", | 68 "scoped_nss_types.h", |
| 69 "secure_hash_default.cc", |
| 79 "secure_hash.h", | 70 "secure_hash.h", |
| 80 "secure_hash_default.cc", | |
| 81 "secure_hash_openssl.cc", | 71 "secure_hash_openssl.cc", |
| 72 "secure_util.cc", |
| 73 "secure_util.h", |
| 82 "sha2.cc", | 74 "sha2.cc", |
| 83 "sha2.h", | 75 "sha2.h", |
| 84 "signature_creator.h", | 76 "signature_creator.h", |
| 85 "signature_creator_nss.cc", | 77 "signature_creator_nss.cc", |
| 86 "signature_creator_openssl.cc", | 78 "signature_creator_openssl.cc", |
| 87 "signature_verifier.h", | 79 "signature_verifier.h", |
| 88 "signature_verifier_nss.cc", | 80 "signature_verifier_nss.cc", |
| 89 "signature_verifier_openssl.cc", | 81 "signature_verifier_openssl.cc", |
| 82 "symmetric_key.h", |
| 90 "symmetric_key_nss.cc", | 83 "symmetric_key_nss.cc", |
| 91 "symmetric_key_openssl.cc", | 84 "symmetric_key_openssl.cc", |
| 92 "third_party/nss/chromium-blapi.h", | 85 "third_party/nss/chromium-blapi.h", |
| 93 "third_party/nss/chromium-blapit.h", | 86 "third_party/nss/chromium-blapit.h", |
| 94 "third_party/nss/chromium-nss.h", | 87 "third_party/nss/chromium-nss.h", |
| 88 "third_party/nss/chromium-sha256.h", |
| 95 "third_party/nss/pk11akey.cc", | 89 "third_party/nss/pk11akey.cc", |
| 96 "third_party/nss/rsawrapr.c", | 90 "third_party/nss/rsawrapr.c", |
| 97 "third_party/nss/secsign.cc", | 91 "third_party/nss/secsign.cc", |
| 92 "third_party/nss/sha512.cc", |
| 98 ] | 93 ] |
| 99 | 94 |
| 100 deps = [ | 95 deps = [ |
| 96 ":platform", |
| 101 "//base", | 97 "//base", |
| 102 "//base/third_party/dynamic_annotations", | 98 "//base/third_party/dynamic_annotations", |
| 103 "//crypto/ssl:metassl", | |
| 104 ] | 99 ] |
| 105 forward_dependent_configs_from = [ "//crypto/ssl:metassl" ] | |
| 106 | 100 |
| 107 if (!is_mac && !is_ios) { | 101 if (!is_mac && !is_ios) { |
| 108 sources -= [ | 102 sources -= [ |
| 109 "apple_keychain.h", | 103 "apple_keychain.h", |
| 110 "mock_apple_keychain.cc", | 104 "mock_apple_keychain.cc", |
| 111 "mock_apple_keychain.h", | 105 "mock_apple_keychain.h", |
| 112 ] | 106 ] |
| 113 } | 107 } |
| 114 | 108 |
| 115 if (!is_linux) { | 109 if (!is_linux) { |
| 110 sources -= [ |
| 111 "openpgp_symmetric_encryption.cc", |
| 112 "openpgp_symmetric_encryption.h", |
| 113 ] |
| 116 if (use_nss) { # Removed for non-NSS in all cases below. | 114 if (use_nss) { # Removed for non-NSS in all cases below. |
| 117 sources -= [ | 115 sources -= [ |
| 118 "openpgp_symmetric_encryption.cc", | 116 "openpgp_symmetric_encryption.cc", |
| 119 "openpgp_symmetric_encryption.h", | 117 "openpgp_symmetric_encryption.h", |
| 120 ] | 118 ] |
| 121 } | 119 } |
| 122 } | 120 } |
| 123 if (!is_mac) { | 121 if (!is_mac) { |
| 124 sources -= [ | 122 sources -= [ |
| 125 "cssm_init.cc", | 123 "cssm_init.cc", |
| 126 "cssm_init.h", | 124 "cssm_init.h", |
| 127 "mac_security_services_lock.cc", | 125 "mac_security_services_lock.cc", |
| 128 "mac_security_services_lock.h", | 126 "mac_security_services_lock.h", |
| 129 ] | 127 ] |
| 130 } | 128 } |
| 131 if (!is_win) { | 129 if (!is_win) { |
| 132 sources -= [ | 130 sources -= [ |
| 133 "capi_util.cc", | 131 "capi_util.cc", |
| 134 "capi_util.h", | 132 "capi_util.h", |
| 135 ] | 133 ] |
| 136 } | 134 } |
| 137 | 135 |
| 138 if (use_nss) { | 136 if (!use_nss) { |
| 139 configs += [ "//third_party/nss:nss_linux_config" ] | |
| 140 } else { | |
| 141 sources -= [ | 137 sources -= [ |
| 142 "ec_private_key_nss.cc", | 138 "ec_private_key_nss.cc", |
| 143 "ec_signature_creator_nss.cc", | 139 "ec_signature_creator_nss.cc", |
| 144 "encryptor_nss.cc", | 140 "encryptor_nss.cc", |
| 145 "hmac_nss.cc", | 141 "hmac_nss.cc", |
| 146 "nss_util.cc", | 142 "nss_util.cc", |
| 147 "nss_util.h", | 143 "nss_util.h", |
| 148 "rsa_private_key_nss.cc", | 144 "rsa_private_key_nss.cc", |
| 149 "secure_hash_default.cc", | 145 "secure_hash_default.cc", |
| 150 "signature_creator_nss.cc", | 146 "signature_creator_nss.cc", |
| (...skipping 17 matching lines...) Expand all Loading... |
| 168 "openssl_util.h", | 164 "openssl_util.h", |
| 169 "rsa_private_key_openssl.cc", | 165 "rsa_private_key_openssl.cc", |
| 170 "secure_hash_openssl.cc", | 166 "secure_hash_openssl.cc", |
| 171 "signature_creator_openssl.cc", | 167 "signature_creator_openssl.cc", |
| 172 "signature_verifier_openssl.cc", | 168 "signature_verifier_openssl.cc", |
| 173 "symmetric_key_openssl.cc", | 169 "symmetric_key_openssl.cc", |
| 174 ] | 170 ] |
| 175 } | 171 } |
| 176 | 172 |
| 177 defines = [ "CRYPTO_IMPLEMENTATION" ] | 173 defines = [ "CRYPTO_IMPLEMENTATION" ] |
| 178 | |
| 179 # TODO(brettw) once GYP compat is no longer necessary, just move | |
| 180 # crypto_minimal_sources to the crypto_minimal target and include a | |
| 181 # dependency on it here. | |
| 182 sources += crypto_minimal_sources | |
| 183 } | |
| 184 | |
| 185 # A minimal crypto subset for core features that small standalone targets can | |
| 186 # use to reduce code size. | |
| 187 static_library("crypto_minimal") { | |
| 188 sources = crypto_minimal_sources | |
| 189 | |
| 190 deps = [ | |
| 191 "//base", | |
| 192 "//base/third_party/dynamic_annotations", | |
| 193 ] | |
| 194 | |
| 195 defines = [ "CRYPTO_IMPLEMENTATION" ] | |
| 196 } | 174 } |
| 197 | 175 |
| 176 if (is_win) { |
| 177 # A minimal crypto subset for hmac-related stuff that small standalone |
| 178 # targets can use to reduce code size on Windows. This does not depend on |
| 179 # OpenSSL/NSS but will use Windows APIs for that functionality. |
| 180 source_set("crypto_minimal_win") { |
| 181 sources = [ |
| 182 "hmac.cc", |
| 183 "hmac.h", |
| 184 "hmac_win.cc", |
| 185 "secure_util.cc", |
| 186 "secure_util.h", |
| 187 "symmetric_key.h", |
| 188 "symmetric_key_win.cc", |
| 189 "third_party/nss/chromium-sha256.h", |
| 190 "third_party/nss/sha512.cc", |
| 191 ] |
| 192 |
| 193 deps = [ |
| 194 "//base", |
| 195 "//base/third_party/dynamic_annotations", |
| 196 ] |
| 197 |
| 198 defines = [ "CRYPTO_IMPLEMENTATION" ] |
| 199 } |
| 200 } |
| 201 |
| 198 test("crypto_unittests") { | 202 test("crypto_unittests") { |
| 199 sources = [ | 203 sources = [ |
| 200 # Tests. | 204 # Tests. |
| 201 "curve25519_unittest.cc", | 205 "curve25519_unittest.cc", |
| 202 "ec_private_key_unittest.cc", | 206 "ec_private_key_unittest.cc", |
| 203 "ec_signature_creator_unittest.cc", | 207 "ec_signature_creator_unittest.cc", |
| 204 "encryptor_unittest.cc", | 208 "encryptor_unittest.cc", |
| 205 "ghash_unittest.cc", | 209 "ghash_unittest.cc", |
| 206 "hkdf_unittest.cc", | 210 "hkdf_unittest.cc", |
| 207 "hmac_unittest.cc", | 211 "hmac_unittest.cc", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 220 ] | 224 ] |
| 221 | 225 |
| 222 if (use_openssl) { | 226 if (use_openssl) { |
| 223 sources -= [ | 227 sources -= [ |
| 224 "nss_util_unittest.cc", | 228 "nss_util_unittest.cc", |
| 225 "openpgp_symmetric_encryption_unittest.cc", | 229 "openpgp_symmetric_encryption_unittest.cc", |
| 226 "rsa_private_key_nss_unittest.cc", | 230 "rsa_private_key_nss_unittest.cc", |
| 227 ] | 231 ] |
| 228 } | 232 } |
| 229 | 233 |
| 234 if (use_openssl || !is_linux) { |
| 235 sources -= [ |
| 236 "rsa_private_key_nss_unittest.cc", |
| 237 "openpgp_symmetric_encryption_unittest.cc", |
| 238 ] |
| 239 } |
| 240 |
| 241 if (use_openssl) { |
| 242 sources -= [ "nss_util_unittest.cc" ] |
| 243 } |
| 244 |
| 230 deps = [ | 245 deps = [ |
| 231 ":crypto", | 246 ":crypto", |
| 247 ":platform", |
| 232 "//base", | 248 "//base", |
| 233 "//base/test:run_all_unittests", | 249 "//base/test:run_all_unittests", |
| 234 "//base/test:test_support", | 250 "//base/test:test_support", |
| 235 "//testing/gmock", | 251 "//testing/gmock", |
| 236 "//testing/gtest", | 252 "//testing/gtest", |
| 237 ] | 253 ] |
| 254 } |
| 238 | 255 |
| 239 if (is_mac) { | 256 # This is a meta-target that forwards to NSS's SSL library or OpenSSL, |
| 240 #deps += "//third_party/nss:nspr" | 257 # according to the state of the crypto flags. A target just wanting to depend |
| 258 # on the current SSL library should just depend on this. |
| 259 group("platform") { |
| 260 if (use_openssl) { |
| 261 deps = [ "//third_party/openssl" ] |
| 262 } else { |
| 263 deps = [ "//net/third_party/nss/ssl:libssl" ] |
| 264 if (is_linux) { |
| 265 # On Linux, we use the system NSS (excepting SSL where we always use our |
| 266 # own). |
| 267 direct_dependent_configs = [ |
| 268 "//third_party/nss:system_nss_no_ssl_config" |
| 269 ] |
| 270 } else { |
| 271 # Non-Linux platforms use the hermetic NSS from the tree. |
| 272 deps += [ |
| 273 "//third_party/nss:nspr", |
| 274 "//third_party/nss:nss", |
| 275 ] |
| 276 } |
| 241 } | 277 } |
| 242 } | 278 } |
| OLD | NEW |