summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-14 17:37:14 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-14 17:37:14 +0000
commit4b559b4ddffc0b7f688019bcb80658f05e063af7 (patch)
tree0be21d8914de707f5125d2cb66733cbcf088606c /chrome/browser/safe_browsing
parent056dd45d610de34312344445d7b078a31f4a1e20 (diff)
downloadchromium_src-4b559b4ddffc0b7f688019bcb80658f05e063af7.zip
chromium_src-4b559b4ddffc0b7f688019bcb80658f05e063af7.tar.gz
chromium_src-4b559b4ddffc0b7f688019bcb80658f05e063af7.tar.bz2
Move crypto files out of base, to a top level directory.
src/crypto is now an independent project that contains our cryptographic primitives (except md5 and sha1). This removes the base dependency from nss, openssl and sqlite. BUG=76996 TEST=none Review URL: http://codereview.chromium.org/6805019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
-rw-r--r--chrome/browser/safe_browsing/filter_false_positive_perftest.cc4
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database.cc17
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_unittest.cc6
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc6
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h6
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util.cc20
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util_unittest.cc6
7 files changed, 33 insertions, 32 deletions
diff --git a/chrome/browser/safe_browsing/filter_false_positive_perftest.cc b/chrome/browser/safe_browsing/filter_false_positive_perftest.cc
index 3548806..e69a59d 100644
--- a/chrome/browser/safe_browsing/filter_false_positive_perftest.cc
+++ b/chrome/browser/safe_browsing/filter_false_positive_perftest.cc
@@ -64,10 +64,10 @@
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/rand_util.h"
-#include "base/sha2.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/time.h"
+#include "crypto/sha2.h"
#include "chrome/browser/safe_browsing/bloom_filter.h"
#include "chrome/browser/safe_browsing/safe_browsing_util.h"
#include "chrome/common/chrome_paths.h"
@@ -176,7 +176,7 @@ int GeneratePrefixHits(const std::string url,
for (size_t i = 0; i < hosts.size(); ++i) {
for (size_t j = 0; j < paths.size(); ++j) {
SBPrefix prefix;
- base::SHA256HashString(hosts[i] + paths[j], &prefix, sizeof(prefix));
+ crypto::SHA256HashString(hosts[i] + paths[j], &prefix, sizeof(prefix));
if (bloom_filter->Exists(prefix))
prefixes->push_back(prefix);
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc
index ecc208c..0f979d4 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database.cc
@@ -13,7 +13,7 @@
#include "base/time.h"
#include "base/message_loop.h"
#include "base/process_util.h"
-#include "base/sha2.h"
+#include "crypto/sha2.h"
#include "chrome/browser/safe_browsing/bloom_filter.h"
#include "chrome/browser/safe_browsing/prefix_set.h"
#include "chrome/browser/safe_browsing/safe_browsing_store_file.h"
@@ -71,8 +71,8 @@ void GetDownloadUrlPrefix(const GURL& url, SBPrefix* prefix) {
safe_browsing_util::CanonicalizeUrl(url, &hostname, &path, &query);
SBFullHash full_hash;
- base::SHA256HashString(hostname + path + query, &full_hash,
- sizeof(full_hash));
+ crypto::SHA256HashString(hostname + path + query, &full_hash,
+ sizeof(full_hash));
*prefix = full_hash.prefix;
}
@@ -103,8 +103,8 @@ void BrowseFullHashesToCheck(const GURL& url,
for (size_t j = 0; j < paths.size(); ++j) {
const std::string& path = paths[j];
SBFullHash full_hash;
- base::SHA256HashString(hosts[i] + path, &full_hash,
- sizeof(full_hash));
+ crypto::SHA256HashString(hosts[i] + path, &full_hash,
+ sizeof(full_hash));
full_hashes->push_back(full_hash);
// We may have /foo as path-prefix in the whitelist which should
@@ -113,8 +113,8 @@ void BrowseFullHashesToCheck(const GURL& url,
if (include_whitelist_hashes &&
path.size() > 1 &&
path[path.size() - 1] == '/') {
- base::SHA256HashString(hosts[i] + path.substr(0, path.size() - 1),
- &full_hash, sizeof(full_hash));
+ crypto::SHA256HashString(hosts[i] + path.substr(0, path.size() - 1),
+ &full_hash, sizeof(full_hash));
full_hashes->push_back(full_hash);
}
}
@@ -1297,7 +1297,8 @@ void SafeBrowsingDatabaseNew::LoadCsdWhitelist(
std::sort(new_csd_whitelist.begin(), new_csd_whitelist.end());
SBFullHash kill_switch;
- base::SHA256HashString(kCsdKillSwitchUrl, &kill_switch, sizeof(kill_switch));
+ crypto::SHA256HashString(kCsdKillSwitchUrl, &kill_switch,
+ sizeof(kill_switch));
if (std::binary_search(new_csd_whitelist.begin(), new_csd_whitelist.end(),
kill_switch)) {
// The kill switch is whitelisted hence we whitelist all URLs.
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
index 5af27d1..11ea60c 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
@@ -10,8 +10,8 @@
#include "base/logging.h"
#include "base/memory/scoped_temp_dir.h"
#include "base/message_loop.h"
-#include "base/sha2.h"
#include "base/time.h"
+#include "crypto/sha2.h"
#include "chrome/browser/safe_browsing/safe_browsing_database.h"
#include "chrome/browser/safe_browsing/safe_browsing_store_file.h"
#include "chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h"
@@ -26,13 +26,13 @@ namespace {
SBPrefix Sha256Prefix(const std::string& str) {
SBPrefix prefix;
- base::SHA256HashString(str, &prefix, sizeof(prefix));
+ crypto::SHA256HashString(str, &prefix, sizeof(prefix));
return prefix;
}
SBFullHash Sha256Hash(const std::string& str) {
SBFullHash hash;
- base::SHA256HashString(str, &hash, sizeof(hash));
+ crypto::SHA256HashString(str, &hash, sizeof(hash));
return hash;
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
index 5434a53..8abecac 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
@@ -9,7 +9,7 @@
#include "base/command_line.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram.h"
-#include "base/sha2.h"
+#include "crypto/sha2.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/safe_browsing/safe_browsing_database.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
@@ -256,8 +256,8 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
std::string host;
std::string path;
safe_browsing_util::CanonicalizeUrl(url, &host, &path, NULL);
- base::SHA256HashString(host + path, &full_hash->hash,
- sizeof(SBFullHash));
+ crypto::SHA256HashString(host + path, &full_hash->hash,
+ sizeof(SBFullHash));
full_hash->list_name = list_name;
full_hash->add_chunk_id = add_chunk_id;
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h b/chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h
index 5fa8ece..0868531 100644
--- a/chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h
+++ b/chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,7 +8,7 @@
#include "chrome/browser/safe_browsing/safe_browsing_store.h"
-#include "base/sha2.h"
+#include "crypto/sha2.h"
#include "testing/gtest/include/gtest/gtest.h"
// Helper code for testing that a SafeBrowsingStore implementation
@@ -17,7 +17,7 @@
// Helper to make it easy to initialize SBFullHash constants.
inline const SBFullHash SBFullHashFromString(const char* str) {
SBFullHash h;
- base::SHA256HashString(str, &h.full_hash, sizeof(h.full_hash));
+ crypto::SHA256HashString(str, &h.full_hash, sizeof(h.full_hash));
return h;
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_util.cc b/chrome/browser/safe_browsing/safe_browsing_util.cc
index d42ba79..427b9c7 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util.cc
@@ -1,13 +1,13 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/safe_browsing/safe_browsing_util.h"
#include "base/base64.h"
-#include "base/hmac.h"
-#include "base/sha2.h"
#include "base/string_util.h"
+#include "crypto/hmac.h"
+#include "crypto/sha2.h"
#include "chrome/browser/google/google_util.h"
#include "googleurl/src/gurl.h"
#include "googleurl/src/url_util.h"
@@ -436,9 +436,9 @@ int GetUrlHashIndex(const GURL& url,
for (size_t h = 0; h < hosts.size(); ++h) {
for (size_t p = 0; p < paths.size(); ++p) {
SBFullHash key;
- base::SHA256HashString(hosts[h] + paths[p],
- key.full_hash,
- sizeof(SBFullHash));
+ crypto::SHA256HashString(hosts[h] + paths[p],
+ key.full_hash,
+ sizeof(SBFullHash));
int index = GetHashIndex(key, full_hashes);
if (index != -1) return index;
}
@@ -485,7 +485,7 @@ bool VerifyMAC(const std::string& key, const std::string& mac,
std::string decoded_mac;
base::Base64Decode(mac_copy, &decoded_mac);
- base::HMAC hmac(base::HMAC::SHA1);
+ crypto::HMAC hmac(crypto::HMAC::SHA1);
if (!hmac.Init(decoded_key))
return false;
const std::string data_str(data, data_length);
@@ -520,12 +520,12 @@ GURL GeneratePhishingReportUrl(const std::string& report_page,
}
void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out) {
- DCHECK_EQ(static_cast<size_t>(base::SHA256_LENGTH), hash_in.size());
- memcpy(hash_out->full_hash, hash_in.data(), base::SHA256_LENGTH);
+ DCHECK_EQ(static_cast<size_t>(crypto::SHA256_LENGTH), hash_in.size());
+ memcpy(hash_out->full_hash, hash_in.data(), crypto::SHA256_LENGTH);
}
std::string SBFullHashToString(const SBFullHash& hash) {
- DCHECK_EQ(static_cast<size_t>(base::SHA256_LENGTH), sizeof(hash.full_hash));
+ DCHECK_EQ(static_cast<size_t>(crypto::SHA256_LENGTH), sizeof(hash.full_hash));
return std::string(hash.full_hash, sizeof(hash.full_hash));
}
} // namespace safe_browsing_util
diff --git a/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
index 0cc0b3b..be20d31 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util_unittest.cc
@@ -1,11 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <algorithm>
-#include "base/sha2.h"
#include "base/string_util.h"
+#include "crypto/sha2.h"
#include "chrome/browser/safe_browsing/safe_browsing_util.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -283,7 +283,7 @@ TEST(SafeBrowsingUtilTest, CanonicalizeUrl) {
TEST(SafeBrowsingUtilTest, GetUrlHashIndex) {
GURL url("http://www.evil.com/phish.html");
SBFullHashResult full_hash;
- base::SHA256HashString(url.host() + url.path(),
+ crypto::SHA256HashString(url.host() + url.path(),
&full_hash.hash,
sizeof(SBFullHash));
std::vector<SBFullHashResult> full_hashes;