summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorbryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-16 21:22:19 +0000
committerbryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-16 21:22:19 +0000
commitce82c057bf25ea69aede1a546eff032ef3a79c45 (patch)
tree66921c8fcb6ff572d6e8628f816a0acdd21dd27d /chrome/browser
parentc7ebcb98313a3726a45325c30e468bf8efd4b80f (diff)
downloadchromium_src-ce82c057bf25ea69aede1a546eff032ef3a79c45.zip
chromium_src-ce82c057bf25ea69aede1a546eff032ef3a79c45.tar.gz
chromium_src-ce82c057bf25ea69aede1a546eff032ef3a79c45.tar.bz2
Replace SafeBrowsing MAC with downloads over SSL.
BUG=119662 TEST=updated unittests, ran Chrome and verified SB functionality on new profile Review URL: http://codereview.chromium.org/10069031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132456 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/prefs/browser_prefs.cc5
-rw-r--r--chrome/browser/safe_browsing/protocol_manager.cc169
-rw-r--r--chrome/browser/safe_browsing/protocol_manager.h70
-rw-r--r--chrome/browser/safe_browsing/protocol_manager_unittest.cc111
-rw-r--r--chrome/browser/safe_browsing/protocol_parser.cc117
-rw-r--r--chrome/browser/safe_browsing/protocol_parser.h24
-rw-r--r--chrome/browser/safe_browsing/protocol_parser_unittest.cc324
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc61
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.h11
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc20
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_test.cc23
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util.cc37
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util.h11
13 files changed, 138 insertions, 845 deletions
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 4082f01..db78104 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -46,7 +46,6 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
-#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/tabs/pinned_tab_codec.h"
#include "chrome/browser/task_manager/task_manager.h"
@@ -130,10 +129,6 @@ void RegisterLocalState(PrefService* local_state) {
NotificationPrefsManager::RegisterPrefs(local_state);
#endif
-#if defined(ENABLE_SAFE_BROWSING)
- SafeBrowsingService::RegisterPrefs(local_state);
-#endif
-
#if defined(ENABLE_TASK_MANAGER)
TaskManager::RegisterPrefs(local_state);
#endif // defined(ENABLE_TASK_MANAGER)
diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc
index 669c85c..cce3e8c 100644
--- a/chrome/browser/safe_browsing/protocol_manager.cc
+++ b/chrome/browser/safe_browsing/protocol_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -7,7 +7,6 @@
#ifndef NDEBUG
#include "base/base64.h"
#endif
-#include "base/bind.h"
#include "base/environment.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
@@ -48,16 +47,12 @@ class SBProtocolManagerFactoryImpl : public SBProtocolManagerFactory {
virtual SafeBrowsingProtocolManager* CreateProtocolManager(
SafeBrowsingService* sb_service,
const std::string& client_name,
- const std::string& client_key,
- const std::string& wrapped_key,
net::URLRequestContextGetter* request_context_getter,
- const std::string& info_url_prefix,
- const std::string& mackey_url_prefix,
+ const std::string& url_prefix,
bool disable_auto_update) {
return new SafeBrowsingProtocolManager(
- sb_service, client_name, client_key, wrapped_key,
- request_context_getter, info_url_prefix, mackey_url_prefix,
- disable_auto_update);
+ sb_service, client_name, request_context_getter,
+ url_prefix, disable_auto_update);
}
private:
DISALLOW_COPY_AND_ASSIGN(SBProtocolManagerFactoryImpl);
@@ -72,29 +67,22 @@ SBProtocolManagerFactory* SafeBrowsingProtocolManager::factory_ = NULL;
SafeBrowsingProtocolManager* SafeBrowsingProtocolManager::Create(
SafeBrowsingService* sb_service,
const std::string& client_name,
- const std::string& client_key,
- const std::string& wrapped_key,
net::URLRequestContextGetter* request_context_getter,
- const std::string& info_url_prefix,
- const std::string& mackey_url_prefix,
+ const std::string& url_prefix,
bool disable_auto_update) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!factory_)
factory_ = new SBProtocolManagerFactoryImpl();
- return factory_->CreateProtocolManager(sb_service, client_name, client_key,
- wrapped_key, request_context_getter,
- info_url_prefix, mackey_url_prefix,
- disable_auto_update);
+ return factory_->CreateProtocolManager(sb_service, client_name,
+ request_context_getter,
+ url_prefix, disable_auto_update);
}
SafeBrowsingProtocolManager::SafeBrowsingProtocolManager(
SafeBrowsingService* sb_service,
const std::string& client_name,
- const std::string& client_key,
- const std::string& wrapped_key,
net::URLRequestContextGetter* request_context_getter,
- const std::string& http_url_prefix,
- const std::string& https_url_prefix,
+ const std::string& url_prefix,
bool disable_auto_update)
: sb_service_(sb_service),
request_type_(NO_REQUEST),
@@ -104,17 +92,13 @@ SafeBrowsingProtocolManager::SafeBrowsingProtocolManager(
gethash_back_off_mult_(1),
next_update_sec_(-1),
update_state_(FIRST_REQUEST),
- initial_request_(true),
chunk_pending_to_write_(false),
- client_key_(client_key),
- wrapped_key_(wrapped_key),
update_size_(0),
client_name_(client_name),
request_context_getter_(request_context_getter),
- http_url_prefix_(http_url_prefix),
- https_url_prefix_(https_url_prefix),
+ url_prefix_(url_prefix),
disable_auto_update_(disable_auto_update) {
- DCHECK(!http_url_prefix_.empty() && !https_url_prefix_.empty());
+ DCHECK(!url_prefix_.empty());
// Set the backoff multiplier fuzz to a random value between 0 and 1.
back_off_fuzz_ = static_cast<float>(base::RandDouble());
@@ -168,8 +152,7 @@ void SafeBrowsingProtocolManager::GetFullHash(
sb_service_->HandleGetHashResults(check, full_hashes, false);
return;
}
- bool use_mac = !client_key_.empty();
- GURL gethash_url = GetHashUrl(use_mac);
+ GURL gethash_url = GetHashUrl();
content::URLFetcher* fetcher = content::URLFetcher::Create(
gethash_url, content::URLFetcher::POST, this);
hash_requests_[fetcher] = check;
@@ -185,15 +168,6 @@ void SafeBrowsingProtocolManager::GetFullHash(
}
void SafeBrowsingProtocolManager::GetNextUpdate() {
- if (initial_request_) {
- if (client_key_.empty() || wrapped_key_.empty()) {
- IssueKeyRequest();
- return;
- } else {
- initial_request_ = false;
- }
- }
-
if (!request_.get())
IssueUpdateRequest();
}
@@ -242,24 +216,18 @@ void SafeBrowsingProtocolManager::OnURLFetchComplete(
can_cache = true;
gethash_error_count_ = 0;
gethash_back_off_mult_ = 1;
- bool re_key = false;
SafeBrowsingProtocolParser parser;
std::string data;
source->GetResponseAsString(&data);
parsed_ok = parser.ParseGetHash(
data.data(),
static_cast<int>(data.length()),
- client_key_,
- &re_key,
&full_hashes);
if (!parsed_ok) {
// If we fail to parse it, we must still inform the SafeBrowsingService
// so that it doesn't hold up the user's request indefinitely. Not sure
// what to do at that point though!
full_hashes.clear();
- } else {
- if (re_key)
- HandleReKey();
}
} else {
HandleGetHashError(Time::Now());
@@ -279,7 +247,7 @@ void SafeBrowsingProtocolManager::OnURLFetchComplete(
hash_requests_.erase(it);
} else {
- // Update, chunk or key response.
+ // Update or chunk response.
fetcher.reset(request_.release());
if (request_type_ == UPDATE_REQUEST) {
@@ -312,15 +280,6 @@ void SafeBrowsingProtocolManager::OnURLFetchComplete(
if (parsed_ok)
chunk_request_urls_.pop_front();
break;
- case GETKEY_REQUEST:
- if (initial_request_) {
- // This is the first request we've made this session. Now that we
- // have the keys, do the regular update request.
- initial_request_ = false;
- GetNextUpdate();
- return;
- }
- break;
case UPDATE_REQUEST:
if (chunk_request_urls_.empty() && parsed_ok) {
// We are up to date since the servers gave us nothing new, so we
@@ -367,13 +326,11 @@ bool SafeBrowsingProtocolManager::HandleServiceResponse(const GURL& url,
switch (request_type_) {
case UPDATE_REQUEST: {
int next_update_sec = -1;
- bool re_key = false;
bool reset = false;
scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes(
new std::vector<SBChunkDelete>);
std::vector<ChunkUrl> chunk_urls;
- if (!parser.ParseUpdate(data, length, client_key_,
- &next_update_sec, &re_key,
+ if (!parser.ParseUpdate(data, length, &next_update_sec,
&reset, chunk_deletes.get(), &chunk_urls)) {
return false;
}
@@ -392,10 +349,6 @@ bool SafeBrowsingProtocolManager::HandleServiceResponse(const GURL& url,
next_update_sec_ = base::RandInt(15 * 60, 45 * 60);
}
- // We need to request a new set of keys for MAC.
- if (re_key)
- HandleReKey();
-
// New chunks to download.
if (!chunk_urls.empty()) {
UMA_HISTOGRAM_COUNTS("SB2.UpdateUrls", chunk_urls.size());
@@ -422,31 +375,23 @@ bool SafeBrowsingProtocolManager::HandleServiceResponse(const GURL& url,
base::Time::Now() - chunk_request_start_);
const ChunkUrl chunk_url = chunk_request_urls_.front();
- bool re_key = false;
scoped_ptr<SBChunkList> chunks(new SBChunkList);
UMA_HISTOGRAM_COUNTS("SB2.ChunkSize", length);
update_size_ += length;
if (!parser.ParseChunk(chunk_url.list_name, data, length,
- client_key_, chunk_url.mac,
- &re_key, chunks.get())) {
+ chunks.get())) {
#ifndef NDEBUG
std::string data_str;
data_str.assign(data, length);
std::string encoded_chunk;
base::Base64Encode(data_str, &encoded_chunk);
VLOG(1) << "ParseChunk error for chunk: " << chunk_url.url
- << ", client_key: " << client_key_
- << ", wrapped_key: " << wrapped_key_
- << ", mac: " << chunk_url.mac
<< ", Base64Encode(data): " << encoded_chunk
<< ", length: " << length;
#endif
return false;
}
- if (re_key)
- HandleReKey();
-
// Chunks to add to storage. Pass ownership of |chunks|.
if (!chunks->empty()) {
chunk_pending_to_write_ = true;
@@ -455,19 +400,6 @@ bool SafeBrowsingProtocolManager::HandleServiceResponse(const GURL& url,
break;
}
- case GETKEY_REQUEST: {
- std::string client_key, wrapped_key;
- if (!parser.ParseNewKey(data, length, &client_key, &wrapped_key))
- return false;
-
- client_key_ = client_key;
- wrapped_key_ = wrapped_key;
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&SafeBrowsingService::OnNewMacKeys,
- sb_service_, client_key_, wrapped_key_));
- break;
- }
default:
return false;
@@ -571,16 +503,6 @@ void SafeBrowsingProtocolManager::IssueChunkRequest() {
request_->Start();
}
-void SafeBrowsingProtocolManager::IssueKeyRequest() {
- GURL key_url = MacKeyUrl();
- request_type_ = GETKEY_REQUEST;
- request_.reset(content::URLFetcher::Create(
- key_url, content::URLFetcher::GET, this));
- request_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
- request_->SetRequestContext(request_context_getter_);
- request_->Start();
-}
-
void SafeBrowsingProtocolManager::OnGetChunksComplete(
const std::vector<SBListChunkRanges>& lists, bool database_error) {
DCHECK_EQ(request_type_, UPDATE_REQUEST);
@@ -590,14 +512,12 @@ void SafeBrowsingProtocolManager::OnGetChunksComplete(
return;
}
- const bool use_mac = !client_key_.empty();
-
// Format our stored chunks:
std::string list_data;
bool found_malware = false;
bool found_phishing = false;
for (size_t i = 0; i < lists.size(); ++i) {
- list_data.append(FormatList(lists[i], use_mac));
+ list_data.append(FormatList(lists[i]));
if (lists[i].name == safe_browsing_util::kPhishingList)
found_phishing = true;
@@ -609,13 +529,13 @@ void SafeBrowsingProtocolManager::OnGetChunksComplete(
// lists.
if (!found_phishing)
list_data.append(FormatList(
- SBListChunkRanges(safe_browsing_util::kPhishingList), use_mac));
+ SBListChunkRanges(safe_browsing_util::kPhishingList)));
if (!found_malware)
list_data.append(FormatList(
- SBListChunkRanges(safe_browsing_util::kMalwareList), use_mac));
+ SBListChunkRanges(safe_browsing_util::kMalwareList)));
- GURL update_url = UpdateUrl(use_mac);
+ GURL update_url = UpdateUrl();
request_.reset(content::URLFetcher::Create(
update_url, content::URLFetcher::POST, this));
request_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
@@ -690,33 +610,23 @@ void SafeBrowsingProtocolManager::ReportMalwareDetails(
// static
std::string SafeBrowsingProtocolManager::FormatList(
- const SBListChunkRanges& list, bool use_mac) {
+ const SBListChunkRanges& list) {
std::string formatted_results;
formatted_results.append(list.name);
formatted_results.append(";");
if (!list.adds.empty()) {
formatted_results.append("a:" + list.adds);
- if (!list.subs.empty() || use_mac)
+ if (!list.subs.empty())
formatted_results.append(":");
}
if (!list.subs.empty()) {
formatted_results.append("s:" + list.subs);
- if (use_mac)
- formatted_results.append(":");
}
- if (use_mac)
- formatted_results.append("mac");
formatted_results.append("\n");
return formatted_results;
}
-void SafeBrowsingProtocolManager::HandleReKey() {
- client_key_.clear();
- wrapped_key_.clear();
- IssueKeyRequest();
-}
-
void SafeBrowsingProtocolManager::HandleGetHashError(const Time& now) {
int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_);
next_gethash_time_ = now + TimeDelta::FromSeconds(next);
@@ -745,28 +655,13 @@ std::string SafeBrowsingProtocolManager::ComposeUrl(
return url;
}
-GURL SafeBrowsingProtocolManager::UpdateUrl(bool use_mac) const {
- std::string url = ComposeUrl(http_url_prefix_, "downloads", client_name_,
- version_, additional_query_);
- if (use_mac) {
- url.append("&wrkey=");
- url.append(wrapped_key_);
- }
- return GURL(url);
-}
-
-GURL SafeBrowsingProtocolManager::GetHashUrl(bool use_mac) const {
- std::string url= ComposeUrl(http_url_prefix_, "gethash", client_name_,
- version_, additional_query_);
- if (use_mac) {
- url.append("&wrkey=");
- url.append(wrapped_key_);
- }
- return GURL(url);
+GURL SafeBrowsingProtocolManager::UpdateUrl() const {
+ return GURL(ComposeUrl(url_prefix_, "downloads", client_name_, version_,
+ additional_query_));
}
-GURL SafeBrowsingProtocolManager::MacKeyUrl() const {
- return GURL(ComposeUrl(https_url_prefix_, "newkey", client_name_, version_,
+GURL SafeBrowsingProtocolManager::GetHashUrl() const {
+ return GURL(ComposeUrl(url_prefix_, "gethash", client_name_, version_,
additional_query_));
}
@@ -779,8 +674,7 @@ GURL SafeBrowsingProtocolManager::SafeBrowsingHitUrl(
threat_type == SafeBrowsingService::BINARY_MALWARE_URL ||
threat_type == SafeBrowsingService::BINARY_MALWARE_HASH ||
threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL);
- // The malware and phishing hits go over HTTP.
- std::string url = ComposeUrl(http_url_prefix_, "report", client_name_,
+ std::string url = ComposeUrl(url_prefix_, "report", client_name_,
version_, additional_query_);
std::string threat_list = "none";
switch (threat_type) {
@@ -811,10 +705,9 @@ GURL SafeBrowsingProtocolManager::SafeBrowsingHitUrl(
}
GURL SafeBrowsingProtocolManager::MalwareDetailsUrl() const {
- // The malware details go over HTTPS.
std::string url = base::StringPrintf(
"%s/clientreport/malware?client=%s&appver=%s&pver=1.0",
- https_url_prefix_.c_str(),
+ url_prefix_.c_str(),
client_name_.c_str(),
version_.c_str());
return GURL(url);
@@ -824,7 +717,11 @@ GURL SafeBrowsingProtocolManager::NextChunkUrl(const std::string& url) const {
std::string next_url;
if (!StartsWithASCII(url, "http://", false) &&
!StartsWithASCII(url, "https://", false)) {
- next_url.append("http://");
+ // Use https if we updated via https, otherwise http (useful for testing).
+ if (StartsWithASCII(url_prefix_, "https://", false))
+ next_url.append("https://");
+ else
+ next_url.append("http://");
next_url.append(url);
} else {
next_url = url;
diff --git a/chrome/browser/safe_browsing/protocol_manager.h b/chrome/browser/safe_browsing/protocol_manager.h
index 981150c..df7a90d 100644
--- a/chrome/browser/safe_browsing/protocol_manager.h
+++ b/chrome/browser/safe_browsing/protocol_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -49,11 +49,8 @@ class SBProtocolManagerFactory {
virtual SafeBrowsingProtocolManager* CreateProtocolManager(
SafeBrowsingService* sb_service,
const std::string& client_name,
- const std::string& client_key,
- const std::string& wrapped_key,
net::URLRequestContextGetter* request_context_getter,
- const std::string& info_url_prefix,
- const std::string& mackey_url_prefix,
+ const std::string& url_prefix,
bool disable_auto_update) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(SBProtocolManagerFactory);
@@ -65,7 +62,6 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestGetHashUrl);
FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest,
TestGetHashBackOffTimes);
- FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestMacKeyUrl);
FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest,
TestSafeBrowsingHitUrl);
FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest,
@@ -87,11 +83,8 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
static SafeBrowsingProtocolManager* Create(
SafeBrowsingService* sb_service,
const std::string& client_name,
- const std::string& client_key,
- const std::string& wrapped_key,
net::URLRequestContextGetter* request_context_getter,
- const std::string& info_url_prefix,
- const std::string& mackey_url_prefix,
+ const std::string& url_prefix,
bool disable_auto_update);
// Sets up the update schedule and internal state for making periodic requests
@@ -136,8 +129,6 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
// malware reports. |report| is the serialized report.
void ReportMalwareDetails(const std::string& report);
- bool is_initial_request() const { return initial_request_; }
-
// The last time we received an update.
base::Time last_update() const { return last_update_; }
@@ -193,11 +184,8 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
SafeBrowsingProtocolManager(
SafeBrowsingService* sb_service,
const std::string& client_name,
- const std::string& client_key,
- const std::string& wrapped_key,
net::URLRequestContextGetter* request_context_getter,
- const std::string& http_url_prefix,
- const std::string& https_url_prefix,
+ const std::string& url_prefix,
bool disable_auto_update);
private:
@@ -210,13 +198,11 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
NO_REQUEST = 0, // No requests in progress
UPDATE_REQUEST, // Request for redirect URLs
CHUNK_REQUEST, // Request for a specific chunk
- GETKEY_REQUEST // Update the client's MAC key
};
- // Composes a URL using |prefix|, |method| (e.g.: gethash, download,
- // newkey, report), |client_name| and |version|. When not empty,
- // |additional_query| is appended to the URL with an additional "&"
- // in the front.
+ // Composes a URL using |prefix|, |method| (e.g.: gethash, download, report).
+ // |client_name| and |version|. When not empty, |additional_query| is
+ // appended to the URL with an additional "&" in the front.
static std::string ComposeUrl(const std::string& prefix,
const std::string& method,
const std::string& client_name,
@@ -224,13 +210,9 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
const std::string& additional_query);
// Generates Update URL for querying about the latest set of chunk updates.
- // Append "wrkey=xxx" to the URL when |use_mac| is true.
- GURL UpdateUrl(bool use_mac) const;
+ GURL UpdateUrl() const;
// Generates GetHash request URL for retrieving full hashes.
- // Append "wrkey=xxx" to the URL when |use_mac| is true.
- GURL GetHashUrl(bool use_mac) const;
- // Generates new MAC client key request URL.
- GURL MacKeyUrl() const;
+ GURL GetHashUrl() const;
// Generates URL for reporting safe browsing hits for UMA users.
GURL SafeBrowsingHitUrl(
const GURL& malicious_url, const GURL& page_url, const GURL& referrer_url,
@@ -269,23 +251,15 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
// Sends a request for a chunk to the SafeBrowsing servers.
void IssueChunkRequest();
- // Gets a key from the SafeBrowsing servers for use with MAC. This should only
- // be called once per client unless the server directly tells us to update.
- void IssueKeyRequest();
-
// Formats a string returned from the database into:
- // "list_name;a:<add_chunk_ranges>:s:<sub_chunk_ranges>:mac\n"
- static std::string FormatList(const SBListChunkRanges& list, bool use_mac);
+ // "list_name;a:<add_chunk_ranges>:s:<sub_chunk_ranges>\n"
+ static std::string FormatList(const SBListChunkRanges& list);
// Runs the protocol parser on received data and update the
// SafeBrowsingService with the new content. Returns 'true' on successful
// parse, 'false' on error.
bool HandleServiceResponse(const GURL& url, const char* data, int length);
- // If the SafeBrowsing service wants us to re-key, we clear our key state and
- // issue the request.
- void HandleReKey();
-
// Updates internal state for each GetHash response error, assuming that the
// current time is |now|.
void HandleGetHashError(const base::Time& now);
@@ -332,7 +306,7 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
int next_update_sec_;
base::OneShotTimer<SafeBrowsingProtocolManager> update_timer_;
- // All chunk requests that need to be made, along with their MAC.
+ // All chunk requests that need to be made.
std::deque<ChunkUrl> chunk_request_urls_;
// Map of GetHash requests.
@@ -348,19 +322,10 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
};
UpdateRequestState update_state_;
- // We'll attempt to get keys once per browser session if we don't already have
- // them. They are not essential to operation, but provide a layer of
- // verification.
- bool initial_request_;
-
// True if the service has been given an add/sub chunk but it hasn't been
// added to the database yet.
bool chunk_pending_to_write_;
- // The keys used for MAC. Empty keys mean we aren't using MAC.
- std::string client_key_;
- std::string wrapped_key_;
-
// The last time we successfully received an update.
base::Time last_update_;
@@ -384,19 +349,16 @@ class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
std::string client_name_;
// A string that is appended to the end of URLs for download, gethash,
- // newkey, safebrowsing hits and chunk update requests.
+ // safebrowsing hits and chunk update requests.
std::string additional_query_;
// The context we use to issue network requests.
scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
// URL prefix where browser fetches safebrowsing chunk updates, hashes, and
- // reports hits to the safebrowsing list for UMA users.
- std::string http_url_prefix_;
-
- // URL prefix where browser fetches MAC client key, and reports detailed
- // malware reports for users who opt-in.
- std::string https_url_prefix_;
+ // reports hits to the safebrowsing list and sends detaild malware reports
+ // for UMA users.
+ std::string url_prefix_;
// When true, protocol manager will not start an update unless
// ForceScheduleNextUpdate() is called. This is set for testing purpose.
diff --git a/chrome/browser/safe_browsing/protocol_manager_unittest.cc b/chrome/browser/safe_browsing/protocol_manager_unittest.cc
index c621879..28b6666 100644
--- a/chrome/browser/safe_browsing/protocol_manager_unittest.cc
+++ b/chrome/browser/safe_browsing/protocol_manager_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
//
@@ -11,14 +11,9 @@
using base::Time;
using base::TimeDelta;
-static const char kInfoUrlPrefix[] = "http://info.prefix.com/foo";
-static const char kMacKeyUrlPrefix[] = "https://key.prefix.com/bar";
+static const char kUrlPrefix[] = "https://prefix.com/foo";
static const char kClient[] = "unittest";
static const char kAppVer[] = "1.0";
-static const char kClientKey[] = "SCg9lcLHd0dfksXgYsacwQ==";
-static const char kWrappedKey[] =
- "AKEgNisjLl7iRYrjWHmpd_XwCiilxrw8nNaYH47tiQ7pDe9cEErjVHGZaPPUau5h61tbXSDqA"
- "BiJZnDFByc_g8B5vTwxkhBf9g==";
static const char kAdditionalQuery[] = "additional_query";
class SafeBrowsingProtocolManagerTest : public testing::Test {
@@ -26,8 +21,7 @@ class SafeBrowsingProtocolManagerTest : public testing::Test {
// Ensure that we respect section 5 of the SafeBrowsing protocol specification.
TEST_F(SafeBrowsingProtocolManagerTest, TestBackOffTimes) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
+ SafeBrowsingProtocolManager pm(NULL, kClient, NULL, kUrlPrefix, false);
pm.next_update_sec_ = 1800;
DCHECK(pm.back_off_fuzz_ >= 0.0 && pm.back_off_fuzz_ <= 1.0);
@@ -63,44 +57,33 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestBackOffTimes) {
EXPECT_EQ(pm.GetNextUpdateTime(false), 1800 * 1000);
}
-// Test string combinations with and without MAC.
TEST_F(SafeBrowsingProtocolManagerTest, TestChunkStrings) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
+ SafeBrowsingProtocolManager pm(NULL, kClient, NULL, kUrlPrefix, false);
// Add and Sub chunks.
SBListChunkRanges phish("goog-phish-shavar");
phish.adds = "1,4,6,8-20,99";
phish.subs = "16,32,64-96";
- EXPECT_EQ(pm.FormatList(phish, false),
+ EXPECT_EQ(pm.FormatList(phish),
"goog-phish-shavar;a:1,4,6,8-20,99:s:16,32,64-96\n");
- EXPECT_EQ(pm.FormatList(phish, true),
- "goog-phish-shavar;a:1,4,6,8-20,99:s:16,32,64-96:mac\n");
// Add chunks only.
phish.subs = "";
- EXPECT_EQ(pm.FormatList(phish, false),
- "goog-phish-shavar;a:1,4,6,8-20,99\n");
- EXPECT_EQ(pm.FormatList(phish, true),
- "goog-phish-shavar;a:1,4,6,8-20,99:mac\n");
+ EXPECT_EQ(pm.FormatList(phish), "goog-phish-shavar;a:1,4,6,8-20,99\n");
// Sub chunks only.
phish.adds = "";
phish.subs = "16,32,64-96";
- EXPECT_EQ(pm.FormatList(phish, false), "goog-phish-shavar;s:16,32,64-96\n");
- EXPECT_EQ(pm.FormatList(phish, true),
- "goog-phish-shavar;s:16,32,64-96:mac\n");
+ EXPECT_EQ(pm.FormatList(phish), "goog-phish-shavar;s:16,32,64-96\n");
// No chunks of either type.
phish.adds = "";
phish.subs = "";
- EXPECT_EQ(pm.FormatList(phish, false), "goog-phish-shavar;\n");
- EXPECT_EQ(pm.FormatList(phish, true), "goog-phish-shavar;mac\n");
+ EXPECT_EQ(pm.FormatList(phish), "goog-phish-shavar;\n");
}
TEST_F(SafeBrowsingProtocolManagerTest, TestGetHashBackOffTimes) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
+ SafeBrowsingProtocolManager pm(NULL, kClient, NULL, kUrlPrefix, false);
// No errors or back off time yet.
EXPECT_EQ(pm.gethash_error_count_, 0);
@@ -152,56 +135,37 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestGetHashBackOffTimes) {
}
TEST_F(SafeBrowsingProtocolManagerTest, TestGetHashUrl) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
+ SafeBrowsingProtocolManager pm(NULL, kClient, NULL, kUrlPrefix, false);
pm.version_ = kAppVer;
- EXPECT_EQ("http://info.prefix.com/foo/gethash?client=unittest&appver=1.0&"
- "pver=2.2", pm.GetHashUrl(false).spec());
- EXPECT_EQ("http://info.prefix.com/foo/gethash?client=unittest&appver=1.0&"
- "pver=2.2&wrkey=AKEgNisjLl7iRYrjWHmpd_XwCiilxrw8nNaYH47tiQ7pDe9cE"
- "ErjVHGZaPPUau5h61tbXSDqABiJZnDFByc_g8B5vTwxkhBf9g==",
- pm.GetHashUrl(true).spec());
+ EXPECT_EQ("https://prefix.com/foo/gethash?client=unittest&appver=1.0&"
+ "pver=2.2", pm.GetHashUrl().spec());
pm.set_additional_query(kAdditionalQuery);
- EXPECT_EQ("http://info.prefix.com/foo/gethash?client=unittest&appver=1.0&"
+ EXPECT_EQ("https://prefix.com/foo/gethash?client=unittest&appver=1.0&"
"pver=2.2&additional_query",
- pm.GetHashUrl(false).spec());
- EXPECT_EQ("http://info.prefix.com/foo/gethash?client=unittest&appver=1.0&"
- "pver=2.2&additional_query&wrkey=AKEgNisjLl7iRYrjWHmpd_XwCiilxrw8"
- "nNaYH47tiQ7pDe9cEErjVHGZaPPUau5h61tbXSDqABiJZnDFByc_g8B5vTwxkhBf"
- "9g==", pm.GetHashUrl(true).spec());
+ pm.GetHashUrl().spec());
}
TEST_F(SafeBrowsingProtocolManagerTest, TestUpdateUrl) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
+ SafeBrowsingProtocolManager pm(NULL, kClient, NULL, kUrlPrefix, false);
pm.version_ = kAppVer;
- EXPECT_EQ("http://info.prefix.com/foo/downloads?client=unittest&appver=1.0&"
- "pver=2.2", pm.UpdateUrl(false).spec());
- EXPECT_EQ("http://info.prefix.com/foo/downloads?client=unittest&appver=1.0&"
- "pver=2.2&wrkey=AKEgNisjLl7iRYrjWHmpd_XwCiilxrw8nNaYH47tiQ7pDe9cE"
- "ErjVHGZaPPUau5h61tbXSDqABiJZnDFByc_g8B5vTwxkhBf9g==",
- pm.UpdateUrl(true).spec());
+ EXPECT_EQ("https://prefix.com/foo/downloads?client=unittest&appver=1.0&"
+ "pver=2.2", pm.UpdateUrl().spec());
pm.set_additional_query(kAdditionalQuery);
- EXPECT_EQ("http://info.prefix.com/foo/downloads?client=unittest&appver=1.0&"
- "pver=2.2&additional_query", pm.UpdateUrl(false).spec());
- EXPECT_EQ("http://info.prefix.com/foo/downloads?client=unittest&appver=1.0&"
- "pver=2.2&additional_query&wrkey=AKEgNisjLl7iRYrjWHmpd_XwCiilxrw8"
- "nNaYH47tiQ7pDe9cEErjVHGZaPPUau5h61tbXSDqABiJZnDFByc_g8B5vTwxkhBf"
- "9g==", pm.UpdateUrl(true).spec());
+ EXPECT_EQ("https://prefix.com/foo/downloads?client=unittest&appver=1.0&"
+ "pver=2.2&additional_query", pm.UpdateUrl().spec());
}
TEST_F(SafeBrowsingProtocolManagerTest, TestSafeBrowsingHitUrl) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
+ SafeBrowsingProtocolManager pm(NULL, kClient, NULL, kUrlPrefix, false);
pm.version_ = kAppVer;
GURL malicious_url("http://malicious.url.com");
GURL page_url("http://page.url.com");
GURL referrer_url("http://referrer.url.com");
- EXPECT_EQ("http://info.prefix.com/foo/report?client=unittest&appver=1.0&"
+ EXPECT_EQ("https://prefix.com/foo/report?client=unittest&appver=1.0&"
"pver=2.2&evts=malblhit&evtd=http%3A%2F%2Fmalicious.url.com%2F&"
"evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
"url.com%2F&evtb=1",
@@ -210,7 +174,7 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestSafeBrowsingHitUrl) {
true, SafeBrowsingService::URL_MALWARE).spec());
pm.set_additional_query(kAdditionalQuery);
- EXPECT_EQ("http://info.prefix.com/foo/report?client=unittest&appver=1.0&"
+ EXPECT_EQ("https://prefix.com/foo/report?client=unittest&appver=1.0&"
"pver=2.2&additional_query&evts=phishblhit&"
"evtd=http%3A%2F%2Fmalicious.url.com%2F&"
"evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
@@ -219,7 +183,7 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestSafeBrowsingHitUrl) {
malicious_url, page_url, referrer_url,
false, SafeBrowsingService::URL_PHISHING).spec());
- EXPECT_EQ("http://info.prefix.com/foo/report?client=unittest&appver=1.0&"
+ EXPECT_EQ("https://prefix.com/foo/report?client=unittest&appver=1.0&"
"pver=2.2&additional_query&evts=binurlhit&"
"evtd=http%3A%2F%2Fmalicious.url.com%2F&"
"evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
@@ -228,7 +192,7 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestSafeBrowsingHitUrl) {
malicious_url, page_url, referrer_url,
false, SafeBrowsingService::BINARY_MALWARE_URL).spec());
- EXPECT_EQ("http://info.prefix.com/foo/report?client=unittest&appver=1.0&"
+ EXPECT_EQ("https://prefix.com/foo/report?client=unittest&appver=1.0&"
"pver=2.2&additional_query&evts=binhashhit&"
"evtd=http%3A%2F%2Fmalicious.url.com%2F&"
"evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
@@ -237,7 +201,7 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestSafeBrowsingHitUrl) {
malicious_url, page_url, referrer_url,
false, SafeBrowsingService::BINARY_MALWARE_HASH).spec());
- EXPECT_EQ("http://info.prefix.com/foo/report?client=unittest&appver=1.0&"
+ EXPECT_EQ("https://prefix.com/foo/report?client=unittest&appver=1.0&"
"pver=2.2&additional_query&evts=phishcsdhit&"
"evtd=http%3A%2F%2Fmalicious.url.com%2F&"
"evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
@@ -248,32 +212,17 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestSafeBrowsingHitUrl) {
}
TEST_F(SafeBrowsingProtocolManagerTest, TestMalwareDetailsUrl) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
+ SafeBrowsingProtocolManager pm(NULL, kClient, NULL, kUrlPrefix, false);
pm.version_ = kAppVer;
pm.set_additional_query(kAdditionalQuery); // AdditionalQuery is not used.
- EXPECT_EQ("https://key.prefix.com/bar/clientreport/malware?"
+ EXPECT_EQ("https://prefix.com/foo/clientreport/malware?"
"client=unittest&appver=1.0&pver=1.0",
pm.MalwareDetailsUrl().spec());
}
-TEST_F(SafeBrowsingProtocolManagerTest, TestMacKeyUrl) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
- pm.version_ = kAppVer;
-
- EXPECT_EQ("https://key.prefix.com/bar/newkey?client=unittest&appver=1.0&"
- "pver=2.2", pm.MacKeyUrl().spec());
-
- pm.set_additional_query(kAdditionalQuery);
- EXPECT_EQ("https://key.prefix.com/bar/newkey?client=unittest&appver=1.0&"
- "pver=2.2&additional_query", pm.MacKeyUrl().spec());
-}
-
TEST_F(SafeBrowsingProtocolManagerTest, TestNextChunkUrl) {
- SafeBrowsingProtocolManager pm(NULL, kClient, kClientKey, kWrappedKey, NULL,
- kInfoUrlPrefix, kMacKeyUrlPrefix, false);
+ SafeBrowsingProtocolManager pm(NULL, kClient, NULL, kUrlPrefix, false);
pm.version_ = kAppVer;
std::string url_partial = "localhost:1234/foo/bar?foo";
@@ -281,7 +230,7 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestNextChunkUrl) {
std::string url_https_full = "https://localhost:1234/foo/bar?foo";
std::string url_https_no_query = "https://localhost:1234/foo/bar";
- EXPECT_EQ("http://localhost:1234/foo/bar?foo",
+ EXPECT_EQ("https://localhost:1234/foo/bar?foo",
pm.NextChunkUrl(url_partial).spec());
EXPECT_EQ("http://localhost:1234/foo/bar?foo",
pm.NextChunkUrl(url_http_full).spec());
@@ -291,7 +240,7 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestNextChunkUrl) {
pm.NextChunkUrl(url_https_no_query).spec());
pm.set_additional_query(kAdditionalQuery);
- EXPECT_EQ("http://localhost:1234/foo/bar?foo&additional_query",
+ EXPECT_EQ("https://localhost:1234/foo/bar?foo&additional_query",
pm.NextChunkUrl(url_partial).spec());
EXPECT_EQ("http://localhost:1234/foo/bar?foo&additional_query",
pm.NextChunkUrl(url_http_full).spec());
diff --git a/chrome/browser/safe_browsing/protocol_parser.cc b/chrome/browser/safe_browsing/protocol_parser.cc
index ba207be..47ef41d 100644
--- a/chrome/browser/safe_browsing/protocol_parser.cc
+++ b/chrome/browser/safe_browsing/protocol_parser.cc
@@ -44,8 +44,6 @@ SafeBrowsingProtocolParser::SafeBrowsingProtocolParser() {
bool SafeBrowsingProtocolParser::ParseGetHash(
const char* chunk_data,
int chunk_len,
- const std::string& key,
- bool* re_key,
std::vector<SBFullHashResult>* full_hashes) {
full_hashes->clear();
int length = chunk_len;
@@ -53,23 +51,6 @@ bool SafeBrowsingProtocolParser::ParseGetHash(
int offset;
std::string line;
- if (!key.empty()) {
- if (!GetLine(data, length, &line))
- return false; // Error! Bad GetHash result.
-
- if (line == "e:pleaserekey") {
- *re_key = true;
- return true;
- }
-
- offset = static_cast<int>(line.size()) + 1;
- data += offset;
- length -= offset;
-
- if (!safe_browsing_util::VerifyMAC(key, line, data, length))
- return false;
- }
-
while (length > 0) {
if (!GetLine(data, length, &line))
return false;
@@ -125,9 +106,7 @@ void SafeBrowsingProtocolParser::FormatGetHash(
bool SafeBrowsingProtocolParser::ParseUpdate(
const char* chunk_data,
int chunk_len,
- const std::string& key,
int* next_update_sec,
- bool* re_key,
bool* reset,
std::vector<SBChunkDelete>* deletes,
std::vector<ChunkUrl>* chunk_urls) {
@@ -141,12 +120,6 @@ bool SafeBrowsingProtocolParser::ParseUpdate(
// Populated below.
std::string list_name;
- // If we requested the MAC, the response must start with a MAC command.
- // This test ensures it is present, the value will be verified in the
- // switch statement below.
- if (!key.empty() && (length < 1 || data[0] != 'm'))
- return false;
-
while (length > 0) {
std::string cmd_line;
if (!GetLine(data, length, &cmd_line))
@@ -184,50 +157,20 @@ bool SafeBrowsingProtocolParser::ParseUpdate(
break;
}
- case 'e':
- if (cmd_parts[1] != "pleaserekey")
- return false;
- *re_key = true;
- break;
-
case 'i':
// The line providing the name of the list (i.e. 'goog-phish-shavar').
list_name = cmd_parts[1];
break;
- case 'm':
- // Verify that the MAC of the remainer of this chunk is what we expect.
- if (!key.empty() &&
- !safe_browsing_util::VerifyMAC(key, cmd_parts[1], data, length))
- return false;
- break;
-
case 'n':
// The line providing the next earliest time (in seconds) to re-query.
*next_update_sec = atoi(cmd_parts[1].c_str());
break;
case 'u': {
- // The redirect command is of the form: u:<url>,<mac> where <url> can
- // contain multiple colons, commas or any valid URL characters. We scan
- // backwards in the string looking for the first ',' we encounter and
- // assume that everything before that is the URL and everything after
- // is the MAC (if the MAC was requested).
- std::string mac;
- std::string redirect_url(cmd_line, 2); // Skip the initial "u:".
- if (!key.empty()) {
- std::string::size_type mac_pos = redirect_url.rfind(',');
- if (mac_pos == std::string::npos)
- return false;
- mac = redirect_url.substr(mac_pos + 1);
- redirect_url = redirect_url.substr(0, mac_pos);
- }
-
ChunkUrl chunk_url;
- chunk_url.url = redirect_url;
+ chunk_url.url = cmd_line.substr(2); // Skip the initial "u:".
chunk_url.list_name = list_name;
- if (!key.empty())
- chunk_url.mac = mac;
chunk_urls->push_back(chunk_url);
break;
}
@@ -250,18 +193,10 @@ bool SafeBrowsingProtocolParser::ParseUpdate(
bool SafeBrowsingProtocolParser::ParseChunk(const std::string& list_name,
const char* data,
int length,
- const std::string& key,
- const std::string& mac,
- bool* re_key,
SBChunkList* chunks) {
int remaining = length;
const char* chunk_data = data;
- if (!key.empty() &&
- !safe_browsing_util::VerifyMAC(key, mac, data, length)) {
- return false;
- }
-
while (remaining > 0) {
std::string cmd_line;
if (!GetLine(chunk_data, length, &cmd_line))
@@ -272,15 +207,7 @@ bool SafeBrowsingProtocolParser::ParseChunk(const std::string& list_name,
remaining -= line_len;
std::vector<std::string> cmd_parts;
base::SplitString(cmd_line, ':', &cmd_parts);
-
- // Handle a possible re-key command.
if (cmd_parts.size() != 4) {
- if (cmd_parts.size() == 2 &&
- cmd_parts[0] == "e" &&
- cmd_parts[1] == "pleaserekey") {
- *re_key = true;
- continue;
- }
return false;
}
@@ -485,45 +412,3 @@ bool SafeBrowsingProtocolParser::ReadPrefixes(
return true;
}
-
-bool SafeBrowsingProtocolParser::ParseNewKey(const char* chunk_data,
- int chunk_length,
- std::string* client_key,
- std::string* wrapped_key) {
- DCHECK(client_key && wrapped_key);
- client_key->clear();
- wrapped_key->clear();
-
- const char* data = chunk_data;
- int remaining = chunk_length;
-
- while (remaining > 0) {
- std::string line;
- if (!GetLine(data, remaining, &line))
- return false;
-
- std::vector<std::string> cmd_parts;
- base::SplitString(line, ':', &cmd_parts);
- if (cmd_parts.size() != 3)
- return false;
-
- if (static_cast<int>(cmd_parts[2].size()) != atoi(cmd_parts[1].c_str()))
- return false;
-
- if (cmd_parts[0] == "clientkey") {
- client_key->assign(cmd_parts[2]);
- } else if (cmd_parts[0] == "wrappedkey") {
- wrapped_key->assign(cmd_parts[2]);
- } else {
- return false;
- }
-
- data += line.size() + 1;
- remaining -= static_cast<int>(line.size()) + 1;
- }
-
- if (client_key->empty() || wrapped_key->empty())
- return false;
-
- return true;
-}
diff --git a/chrome/browser/safe_browsing/protocol_parser.h b/chrome/browser/safe_browsing/protocol_parser.h
index 79ab563..b2756dc 100644
--- a/chrome/browser/safe_browsing/protocol_parser.h
+++ b/chrome/browser/safe_browsing/protocol_parser.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -56,18 +56,13 @@ class SafeBrowsingProtocolParser {
// Parse the response of an update request. Results for chunk deletions (both
// add-del and sub-del are returned in 'chunk_deletes', and new chunk URLs to
// download are contained in 'chunk_urls'. The next time the client is allowed
- // to request another update is returned in 'next_update_sec'. If the service
- // wants us to retrieve new MAC keys, 're_key' will be set to true. If we are
- // using MACs to verify responses, the 'key' must be set to the private key
- // returned from the SafeBrowsing servers. 'reset' will be set to true if the
- // SafeBrowsing service wants us to dump our database.
+ // to request another update is returned in 'next_update_sec'. 'reset' will
+ // be set to true if the SafeBrowsing service wants us to dump our database.
// Returns 'true'if it was able to decode the chunk properly, 'false' if not
// decoded properly and the results should be ignored.
bool ParseUpdate(const char* chunk_data,
int chunk_len,
- const std::string& key,
int* next_update_sec,
- bool* re_key,
bool* reset,
std::vector<SBChunkDelete>* chunk_deletes,
std::vector<ChunkUrl>* chunk_urls);
@@ -78,30 +73,17 @@ class SafeBrowsingProtocolParser {
bool ParseChunk(const std::string& list_name,
const char* chunk_data,
int chunk_len,
- const std::string& key,
- const std::string& mac,
- bool* re_key,
SBChunkList* chunks);
// Parse the result of a GetHash request, returning the list of full hashes.
- // If we are checking for valid MACs, the caller should populate 'key'.
bool ParseGetHash(const char* chunk_data,
int chunk_len,
- const std::string& key,
- bool* re_key,
std::vector<SBFullHashResult>* full_hashes);
// Convert a list of partial hashes into a proper GetHash request.
void FormatGetHash(const std::vector<SBPrefix>& prefixes,
std::string* request);
- // Parse the keys used for subsequent communications with the SafeBrowsing
- // servers. Returns true on successful parse, false on parse error.
- bool ParseNewKey(const char* chunk_data,
- int chunk_length,
- std::string* client_key,
- std::string* wrapped_key);
-
private:
bool ParseAddChunk(const std::string& list_name,
const char* data,
diff --git a/chrome/browser/safe_browsing/protocol_parser_unittest.cc b/chrome/browser/safe_browsing/protocol_parser_unittest.cc
index 3f77a06..8b7abe3 100644
--- a/chrome/browser/safe_browsing/protocol_parser_unittest.cc
+++ b/chrome/browser/safe_browsing/protocol_parser_unittest.cc
@@ -16,15 +16,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddChunk) {
// Run the parse.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kMalwareList,
add_chunk.data(),
static_cast<int>(add_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 1);
EXPECT_EQ(chunks[0].hosts.size(), 3U);
@@ -69,15 +67,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddFullChunk) {
// Run the parse.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kMalwareList,
add_chunk.data(),
static_cast<int>(add_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 1);
EXPECT_EQ(chunks[0].hosts.size(), 1U);
@@ -100,15 +96,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddChunks) {
// Run the parse.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kMalwareList,
add_chunk.data(),
static_cast<int>(add_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 2U);
EXPECT_EQ(chunks[0].chunk_number, 1);
EXPECT_EQ(chunks[0].hosts.size(), 3U);
@@ -162,15 +156,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddBigChunk) {
add_chunk.append(base::StringPrintf("001%d", i));
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kMalwareList,
add_chunk.data(),
static_cast<int>(add_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 1);
@@ -190,14 +182,12 @@ TEST(SafeBrowsingProtocolParsingTest, TestTruncatedBinHashChunk) {
// This chunk delares there are 4 prefixes but actually only contains 2.
const char add_chunk[] = "a:1:4:16\n11112222";
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(safe_browsing_util::kBinHashList,
add_chunk,
static_cast<int>(sizeof(add_chunk)),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_FALSE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 0U);
}
@@ -206,34 +196,30 @@ TEST(SafeBrowsingProtocolParsingTest, TestTruncatedUrlHashChunk) {
// This chunk delares there are 4 prefixes but actually only contains 2.
const char add_chunk[] = "a:1:4:21\naaaa\00411112222";
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
// For safe_browsing_util::kMalwareList.
bool result = parser.ParseChunk(safe_browsing_util::kMalwareList,
add_chunk,
static_cast<int>(sizeof(add_chunk)),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_FALSE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 0U);
// For safe_browsing_util::kPhishingList.
result = parser.ParseChunk(safe_browsing_util::kPhishingList,
add_chunk,
static_cast<int>(sizeof(add_chunk)),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_FALSE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 0U);
// For safe_browsing_util::kBinUrlList.
result = parser.ParseChunk(safe_browsing_util::kBinUrlList,
add_chunk,
static_cast<int>(sizeof(add_chunk)),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_FALSE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 0U);
}
@@ -246,15 +232,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestSubChunk) {
// Run the parse.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kMalwareList,
sub_chunk.data(),
static_cast<int>(sub_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 9);
EXPECT_EQ(chunks[0].hosts.size(), 3U);
@@ -307,15 +291,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestSubFullChunk) {
// Run the parse.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kMalwareList,
sub_chunk.data(),
static_cast<int>(sub_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 1);
EXPECT_EQ(chunks[0].hosts.size(), 1U);
@@ -338,17 +320,14 @@ TEST(SafeBrowsingProtocolParsingTest, TestChunkDelete) {
SafeBrowsingProtocolParser parser;
int next_query_sec = 0;
- bool re_key = false;
bool reset = false;
std::vector<SBChunkDelete> deletes;
std::vector<ChunkUrl> urls;
EXPECT_TRUE(parser.ParseUpdate(add_del.data(),
- static_cast<int>(add_del.length()), "",
- &next_query_sec, &re_key,
- &reset, &deletes, &urls));
+ static_cast<int>(add_del.length()),
+ &next_query_sec, &reset, &deletes, &urls));
EXPECT_TRUE(urls.empty());
- EXPECT_FALSE(re_key);
EXPECT_FALSE(reset);
EXPECT_EQ(next_query_sec, 1700);
EXPECT_EQ(deletes.size(), 2U);
@@ -371,9 +350,8 @@ TEST(SafeBrowsingProtocolParsingTest, TestChunkDelete) {
urls.clear();
add_del = "n:1700\nad:1-7,43-597,44444,99999\ni:malware\nsd:4,21-27171717\n";
EXPECT_FALSE(parser.ParseUpdate(add_del.data(),
- static_cast<int>(add_del.length()), "",
- &next_query_sec, &re_key,
- &reset, &deletes, &urls));
+ static_cast<int>(add_del.length()),
+ &next_query_sec, &reset, &deletes, &urls));
}
// Test parsing the SafeBrowsing update response.
@@ -387,16 +365,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestRedirects) {
SafeBrowsingProtocolParser parser;
int next_query_sec = 0;
- bool re_key = false;
bool reset = false;
std::vector<SBChunkDelete> deletes;
std::vector<ChunkUrl> urls;
EXPECT_TRUE(parser.ParseUpdate(redirects.data(),
- static_cast<int>(redirects.length()), "",
- &next_query_sec, &re_key,
- &reset, &deletes, &urls));
+ static_cast<int>(redirects.length()),
+ &next_query_sec, &reset, &deletes, &urls));
- EXPECT_FALSE(re_key);
EXPECT_FALSE(reset);
EXPECT_EQ(urls.size(), 4U);
EXPECT_EQ(urls[0].url,
@@ -412,63 +387,19 @@ TEST(SafeBrowsingProtocolParsingTest, TestRedirects) {
EXPECT_TRUE(deletes.empty());
}
-TEST(SafeBrowsingProtocolParsingTest, TestRedirectsWithMac) {
- std::string redirects("m:IZhFUj0bMPBMsGw7MMA-VIzrNLg=\n"
- "i:goog-phish-shavar\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6501-6505:6501-6505,"
- "pcY6iVeT9-CBQ3fdAF0rpnKjR1Y=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_a_8001-8160:8001-8024,"
- "8026-8045,8048-8049,8051-8134,8136-8152,8155-8160,"
- "j6XXAEWnjYk9tVVLBSdQvIEq2Wg=\n");
-
- SafeBrowsingProtocolParser parser;
- int next_query_sec = 0;
- bool re_key = false;
- bool reset = false;
- const std::string key("58Lqn5WIP961x3zuLGo5Uw==");
- std::vector<SBChunkDelete> deletes;
- std::vector<ChunkUrl> urls;
-
- ASSERT_TRUE(parser.ParseUpdate(redirects.data(),
- static_cast<int>(redirects.length()), key,
- &next_query_sec, &re_key,
- &reset, &deletes, &urls));
-
- EXPECT_FALSE(re_key);
- EXPECT_FALSE(reset);
- EXPECT_EQ(urls.size(), 2U);
- EXPECT_EQ(urls[0].url,
- "s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6501-6505:6501-6505");
- EXPECT_EQ(urls[0].mac, "pcY6iVeT9-CBQ3fdAF0rpnKjR1Y=");
- EXPECT_EQ(urls[1].url,
- "s.ytimg.com/safebrowsing/rd/goog-phish-shavar_a_8001-8160:8001-8024,"
- "8026-8045,8048-8049,8051-8134,8136-8152,8155-8160");
- EXPECT_EQ(urls[1].mac, "j6XXAEWnjYk9tVVLBSdQvIEq2Wg=");
-
- std::string bad_redirects = redirects;
- bad_redirects[0] = 'z';
- EXPECT_FALSE(parser.ParseUpdate(bad_redirects.data(),
- static_cast<int>(bad_redirects.length()), key,
- &next_query_sec, &re_key,
- &reset, &deletes, &urls));
-}
-
// Test parsing various SafeBrowsing protocol headers.
TEST(SafeBrowsingProtocolParsingTest, TestNextQueryTime) {
std::string headers("n:1800\ni:goog-white-shavar\n");
SafeBrowsingProtocolParser parser;
int next_query_sec = 0;
- bool re_key = false;
bool reset = false;
std::vector<SBChunkDelete> deletes;
std::vector<ChunkUrl> urls;
EXPECT_TRUE(parser.ParseUpdate(headers.data(),
- static_cast<int>(headers.length()), "",
- &next_query_sec, &re_key,
- &reset, &deletes, &urls));
+ static_cast<int>(headers.length()),
+ &next_query_sec, &reset, &deletes, &urls));
EXPECT_EQ(next_query_sec, 1800);
- EXPECT_FALSE(re_key);
EXPECT_FALSE(reset);
EXPECT_TRUE(deletes.empty());
EXPECT_TRUE(urls.empty());
@@ -481,14 +412,11 @@ TEST(SafeBrowsingProtocolParsingTest, TestGetHash) {
"00001111222233334444555566667777"
"ffffeeeeddddccccbbbbaaaa99998888");
std::vector<SBFullHashResult> full_hashes;
- bool re_key = false;
SafeBrowsingProtocolParser parser;
EXPECT_TRUE(parser.ParseGetHash(get_hash.data(),
- static_cast<int>(get_hash.length()), "",
- &re_key,
+ static_cast<int>(get_hash.length()),
&full_hashes));
- EXPECT_FALSE(re_key);
EXPECT_EQ(full_hashes.size(), 3U);
EXPECT_EQ(memcmp(&full_hashes[0].hash,
"00112233445566778899aabbccddeeff",
@@ -510,11 +438,9 @@ TEST(SafeBrowsingProtocolParsingTest, TestGetHash) {
"cafebeefcafebeefdeaddeaddeaddead"
"zzzzyyyyxxxxwwwwvvvvuuuuttttssss");
EXPECT_TRUE(parser.ParseGetHash(get_hash2.data(),
- static_cast<int>(get_hash2.length()), "",
- &re_key,
+ static_cast<int>(get_hash2.length()),
&full_hashes));
- EXPECT_FALSE(re_key);
EXPECT_EQ(full_hashes.size(), 3U);
EXPECT_EQ(memcmp(&full_hashes[0].hash,
"00112233445566778899aabbccddeeff",
@@ -530,55 +456,15 @@ TEST(SafeBrowsingProtocolParsingTest, TestGetHash) {
EXPECT_EQ(full_hashes[2].list_name, "goog-malware-shavar");
}
-TEST(SafeBrowsingProtocolParsingTest, TestGetHashWithMac) {
- const unsigned char get_hash[] = {
- 0x32, 0x56, 0x74, 0x6f, 0x6b, 0x36, 0x64, 0x41,
- 0x51, 0x72, 0x65, 0x51, 0x62, 0x38, 0x51, 0x68,
- 0x59, 0x45, 0x57, 0x51, 0x57, 0x4d, 0x52, 0x65,
- 0x42, 0x63, 0x41, 0x3d, 0x0a, 0x67, 0x6f, 0x6f,
- 0x67, 0x2d, 0x70, 0x68, 0x69, 0x73, 0x68, 0x2d,
- 0x73, 0x68, 0x61, 0x76, 0x61, 0x72, 0x3a, 0x36,
- 0x31, 0x36, 0x39, 0x3a, 0x33, 0x32, 0x0a, 0x17,
- 0x7f, 0x03, 0x42, 0x28, 0x1c, 0x31, 0xb9, 0x0b,
- 0x1c, 0x7b, 0x9d, 0xaf, 0x7b, 0x43, 0x99, 0x10,
- 0xc1, 0xab, 0xe3, 0x1b, 0x35, 0x80, 0x38, 0x96,
- 0xf9, 0x44, 0x4f, 0x28, 0xb4, 0xeb, 0x45
- };
-
- const unsigned char hash_result[] = {
- 0x17, 0x7f, 0x03, 0x42, 0x28, 0x1c, 0x31, 0xb9,
- 0x0b, 0x1c, 0x7b, 0x9d, 0xaf, 0x7b, 0x43, 0x99,
- 0x10, 0xc1, 0xab, 0xe3, 0x1b, 0x35, 0x80, 0x38,
- 0x96, 0xf9, 0x44, 0x4f, 0x28, 0xb4, 0xeb, 0x45
- };
-
- const std::string key = "58Lqn5WIP961x3zuLGo5Uw==";
- std::vector<SBFullHashResult> full_hashes;
- bool re_key = false;
- SafeBrowsingProtocolParser parser;
- EXPECT_TRUE(parser.ParseGetHash(reinterpret_cast<const char*>(get_hash),
- sizeof(get_hash),
- key,
- &re_key,
- &full_hashes));
- EXPECT_FALSE(re_key);
- EXPECT_EQ(full_hashes.size(), 1U);
- EXPECT_EQ(memcmp(hash_result, &full_hashes[0].hash, sizeof(SBFullHash)), 0);
-}
-
TEST(SafeBrowsingProtocolParsingTest, TestGetHashWithUnknownList) {
std::string hash_response = "goog-phish-shavar:1:32\n"
"12345678901234567890123456789012"
"googpub-phish-shavar:19:32\n"
"09876543210987654321098765432109";
- bool re_key = false;
- std::string key = "";
std::vector<SBFullHashResult> full_hashes;
SafeBrowsingProtocolParser parser;
EXPECT_TRUE(parser.ParseGetHash(hash_response.data(),
hash_response.size(),
- key,
- &re_key,
&full_hashes));
EXPECT_EQ(full_hashes.size(), 1U);
@@ -592,8 +478,6 @@ TEST(SafeBrowsingProtocolParsingTest, TestGetHashWithUnknownList) {
full_hashes.clear();
EXPECT_TRUE(parser.ParseGetHash(hash_response.data(),
hash_response.size(),
- key,
- &re_key,
&full_hashes));
EXPECT_EQ(full_hashes.size(), 2U);
@@ -620,50 +504,17 @@ TEST(SafeBrowsingProtocolParsingTest, TestFormatHash) {
EXPECT_EQ(get_hash, "4:12\n1234abcdpqrs");
}
-TEST(SafeBrowsingProtocolParsingTest, TestGetKey) {
- SafeBrowsingProtocolParser parser;
- std::string key_response("clientkey:10:0123456789\n"
- "wrappedkey:20:abcdefghijklmnopqrst\n");
-
- std::string client_key, wrapped_key;
- EXPECT_TRUE(parser.ParseNewKey(key_response.data(),
- static_cast<int>(key_response.length()),
- &client_key,
- &wrapped_key));
-
- EXPECT_EQ(client_key, "0123456789");
- EXPECT_EQ(wrapped_key, "abcdefghijklmnopqrst");
-}
-
-TEST(SafeBrowsingProtocolParsingTest, TestReKey) {
- SafeBrowsingProtocolParser parser;
- std::string update("n:1800\ni:phishy\ne:pleaserekey\n");
-
- bool re_key = false;
- bool reset = false;
- int next_update = -1;
- std::vector<SBChunkDelete> deletes;
- std::vector<ChunkUrl> urls;
- EXPECT_TRUE(parser.ParseUpdate(update.data(),
- static_cast<int>(update.size()), "",
- &next_update, &re_key,
- &reset, &deletes, &urls));
- EXPECT_TRUE(re_key);
-}
-
TEST(SafeBrowsingProtocolParsingTest, TestReset) {
SafeBrowsingProtocolParser parser;
std::string update("n:1800\ni:phishy\nr:pleasereset\n");
- bool re_key = false;
bool reset = false;
int next_update = -1;
std::vector<SBChunkDelete> deletes;
std::vector<ChunkUrl> urls;
EXPECT_TRUE(parser.ParseUpdate(update.data(),
- static_cast<int>(update.size()), "",
- &next_update, &re_key,
- &reset, &deletes, &urls));
+ static_cast<int>(update.size()),
+ &next_update, &reset, &deletes, &urls));
EXPECT_TRUE(reset);
}
@@ -673,14 +524,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestReset) {
TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeAddChunk) {
std::string add_chunk("a:1:4:0\n");
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kMalwareList,
add_chunk.data(),
static_cast<int>(add_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 1);
@@ -695,7 +545,7 @@ TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeAddChunk) {
safe_browsing_util::kMalwareList,
add_chunks.data(),
static_cast<int>(add_chunks.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
EXPECT_EQ(chunks.size(), 3U);
@@ -720,14 +570,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeAddChunk) {
TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeSubChunk) {
std::string sub_chunk("s:9:4:0\n");
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kMalwareList,
sub_chunk.data(),
static_cast<int>(sub_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 9);
@@ -744,7 +593,7 @@ TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeSubChunk) {
safe_browsing_util::kMalwareList,
sub_chunks.data(),
static_cast<int>(sub_chunks.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
EXPECT_EQ(chunks[0].chunk_number, 1);
@@ -767,121 +616,18 @@ TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeSubChunk) {
EXPECT_EQ(chunks[2].hosts[1].entry->ChunkIdAtPrefix(0), 0x35363738);
}
-TEST(SafeBrowsingProtocolParsingTest, TestVerifyUpdateMac) {
- SafeBrowsingProtocolParser parser;
-
- const std::string update_body =
- "n:1895\n"
- "i:goog-phish-shavar\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6501-6505:6501-6505,"
- "pcY6iVeT9-CBQ3fdAF0rpnKjR1Y=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6506-6510:6506-6510,"
- "SDBrYC3rX3KEPe72LOypnP6QYac=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6511-6520:6511-6520,"
- "9UQo-e7OkcsXT2wFWTAhOuWOsUs=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6521-6560:6521-6560,"
- "qVNw6JIpR1q6PIXST7J4LJ9n3Zg=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6561-6720:6561-6720,"
- "7OiJvCbiwvpzPITW-hQohY5NHuc=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6721-6880:6721-6880,"
- "oBS3svhoi9deIa0sWZ_gnD0ujj8=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_6881-7040:6881-7040,"
- "a0r8Xit4VvH39xgyQHZTPczKBIE=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_s_7041-7200:7041-7163,"
- "q538LChutGknBw55s6kcE2wTcvU=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_a_8001-8160:8001-8024,"
- "8026-8045,8048-8049,8051-8134,8136-8152,8155-8160,"
- "j6XXAEWnjYk9tVVLBSdQvIEq2Wg=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_a_8161-8320:8161-8215,"
- "8217-8222,8224-8320,YaNfiqdQOt-uLCLWVLj46AZpAjQ=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_a_8321-8480:8321-8391,"
- "8393-8399,8402,8404-8419,8421-8425,8427,8431-8433,8435-8439,8441-8443,"
- "8445-8446,8448-8480,ALj31GQMwGiIeU3bM2ZYKITfU-U=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_a_8481-8640:8481-8500,"
- "8502-8508,8510-8511,8513-8517,8519-8525,8527-8531,8533,8536-8539,"
- "8541-8576,8578-8638,8640,TlQYRmS_kZ5PBAUIUyNQDq0Jprs=\n"
- "u:s.ytimg.com/safebrowsing/rd/goog-phish-shavar_a_8641-8800:8641-8689,"
- "8691-8731,8733-8786,x1Qf7hdNrO8b6yym03ZzNydDS1o=\n";
-
- const std::string update = "m:XIU0LiQhAPJq6dynXwHbygjS5tw=\n" + update_body;
-
- bool re_key = false;
- bool reset = false;
- int next_update = -1;
- std::vector<SBChunkDelete> deletes;
- std::vector<ChunkUrl> urls;
- const std::string key("58Lqn5WIP961x3zuLGo5Uw==");
-
- // Should pass with correct mac.
- ASSERT_TRUE(parser.ParseUpdate(update.data(),
- static_cast<int>(update.size()), key,
- &next_update, &re_key,
- &reset, &deletes, &urls));
- EXPECT_FALSE(re_key);
- EXPECT_EQ(next_update, 1895);
-
- // Should fail if mac is not present.
- EXPECT_FALSE(parser.ParseUpdate(update_body.data(),
- static_cast<int>(update_body.size()), key,
- &next_update, &re_key,
- &reset, &deletes, &urls));
-
- std::string bad_update = update;
- bad_update[1] = 'z';
- // Should fail if mac command isn't formatted correctly.
- EXPECT_FALSE(parser.ParseUpdate(bad_update.data(),
- static_cast<int>(bad_update.size()), key,
- &next_update, &re_key,
- &reset, &deletes, &urls));
-
- bad_update = update;
- bad_update[5] ^= 1;
- // Should fail if mac is incorrect.
- EXPECT_FALSE(parser.ParseUpdate(bad_update.data(),
- static_cast<int>(bad_update.size()), key,
- &next_update, &re_key,
- &reset, &deletes, &urls));
-
-}
-
-TEST(SafeBrowsingProtocolParsingTest, TestVerifyChunkMac) {
- SafeBrowsingProtocolParser parser;
-
- const unsigned char chunk[] = {
- 0x73, 0x3a, 0x32, 0x30, 0x30, 0x32, 0x3a, 0x34,
- 0x3a, 0x32, 0x32, 0x0a, 0x2f, 0x4f, 0x89, 0x7a,
- 0x01, 0x00, 0x00, 0x0a, 0x59, 0xc8, 0x71, 0xdf,
- 0x9d, 0x29, 0x0c, 0xba, 0xd7, 0x00, 0x00, 0x00,
- 0x0a, 0x59
- };
-
- bool re_key = false;
- SBChunkList chunks;
- const std::string key("v_aDSz6jI92WeHCOoZ07QA==");
- const std::string mac("W9Xp2fUcQ9V66If6Cvsrstpa4Kk=");
-
- EXPECT_TRUE(parser.ParseChunk(
- safe_browsing_util::kMalwareList,
- reinterpret_cast<const char*>(chunk),
- sizeof(chunk), key, mac,
- &re_key, &chunks));
- EXPECT_FALSE(re_key);
-}
-
TEST(SafeBrowsingProtocolParsingTest, TestAddBinHashChunks) {
std::string add_chunk("a:1:4:16\naaaabbbbccccdddd"
"a:2:4:8\n11112222");
// Run the parse.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kBinHashList,
add_chunk.data(),
static_cast<int>(add_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 2U);
EXPECT_EQ(chunks[0].chunk_number, 1);
EXPECT_EQ(chunks[0].hosts.size(), 1U);
@@ -911,15 +657,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddBigBinHashChunk) {
add_chunk.append(base::StringPrintf("%04d", i));
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kBinHashList,
add_chunk.data(),
static_cast<int>(add_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 1);
@@ -936,15 +680,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestSubBinHashChunk) {
// Run the parser.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kBinHashList,
sub_chunk.data(),
static_cast<int>(sub_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 9);
EXPECT_EQ(chunks[0].hosts.size(), 1U);
@@ -966,15 +708,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestAddDownloadWhitelistChunk) {
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
// Run the parse.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kDownloadWhiteList,
add_chunk.data(),
static_cast<int>(add_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
EXPECT_TRUE(result);
- EXPECT_FALSE(re_key);
EXPECT_EQ(chunks.size(), 2U);
EXPECT_EQ(chunks[0].chunk_number, 1);
EXPECT_EQ(chunks[0].hosts.size(), 1U);
@@ -1006,15 +746,13 @@ TEST(SafeBrowsingProtocolParsingTest, TestSubDownloadWhitelistChunk) {
// Run the parser.
SafeBrowsingProtocolParser parser;
- bool re_key = false;
SBChunkList chunks;
bool result = parser.ParseChunk(
safe_browsing_util::kDownloadWhiteList,
sub_chunk.data(),
static_cast<int>(sub_chunk.length()),
- "", "", &re_key, &chunks);
+ &chunks);
ASSERT_TRUE(result);
- EXPECT_FALSE(re_key);
ASSERT_EQ(chunks.size(), 1U);
EXPECT_EQ(chunks[0].chunk_number, 1);
EXPECT_EQ(chunks[0].hosts.size(), 1U);
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index 8ab946eb..6b02909e 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -59,14 +59,9 @@ namespace {
const FilePath::CharType kCookiesFile[] = FILE_PATH_LITERAL(" Cookies");
// The default URL prefix where browser fetches chunk updates, hashes,
-// and reports safe browsing hits.
-const char* const kSbDefaultInfoURLPrefix =
- "http://safebrowsing.clients.google.com/safebrowsing";
-
-// The default URL prefix where browser fetches MAC client key and reports
-// malware details.
-const char* const kSbDefaultMacKeyURLPrefix =
- "https://sb-ssl.google.com/safebrowsing";
+// and reports safe browsing hits and malware details.
+const char* const kSbDefaultURLPrefix =
+ "https://safebrowsing.google.com/safebrowsing";
// When download url check takes this long, client's callback will be called
// without waiting for the result.
@@ -586,26 +581,11 @@ void SafeBrowsingService::OnBlockingPageDone(
}
}
-void SafeBrowsingService::OnNewMacKeys(const std::string& client_key,
- const std::string& wrapped_key) {
- PrefService* prefs = g_browser_process->local_state();
- if (prefs) {
- prefs->SetString(prefs::kSafeBrowsingClientKey, client_key);
- prefs->SetString(prefs::kSafeBrowsingWrappedKey, wrapped_key);
- }
-}
-
net::URLRequestContextGetter* SafeBrowsingService::url_request_context() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
return url_request_context_getter_.get();
}
-// static
-void SafeBrowsingService::RegisterPrefs(PrefService* prefs) {
- prefs->RegisterStringPref(prefs::kSafeBrowsingClientKey, "");
- prefs->RegisterStringPref(prefs::kSafeBrowsingWrappedKey, "");
-}
-
void SafeBrowsingService::ResetDatabase() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(enabled_);
@@ -653,9 +633,7 @@ void SafeBrowsingService::DestroyURLRequestContextOnIOThread() {
url_request_context_ = NULL;
}
-void SafeBrowsingService::StartOnIOThread(
- const std::string& client_key,
- const std::string& wrapped_key) {
+void SafeBrowsingService::StartOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (enabled_)
return;
@@ -686,24 +664,17 @@ void SafeBrowsingService::StartOnIOThread(
bool disable_auto_update =
cmdline->HasSwitch(switches::kSbDisableAutoUpdate) ||
cmdline->HasSwitch(switches::kDisableBackgroundNetworking);
- std::string info_url_prefix =
- cmdline->HasSwitch(switches::kSbInfoURLPrefix) ?
- cmdline->GetSwitchValueASCII(switches::kSbInfoURLPrefix) :
- kSbDefaultInfoURLPrefix;
- std::string mackey_url_prefix =
- cmdline->HasSwitch(switches::kSbMacKeyURLPrefix) ?
- cmdline->GetSwitchValueASCII(switches::kSbMacKeyURLPrefix) :
- kSbDefaultMacKeyURLPrefix;
+ std::string url_prefix =
+ cmdline->HasSwitch(switches::kSbURLPrefix) ?
+ cmdline->GetSwitchValueASCII(switches::kSbURLPrefix) :
+ kSbDefaultURLPrefix;
DCHECK(!protocol_manager_);
protocol_manager_ =
SafeBrowsingProtocolManager::Create(this,
client_name,
- client_key,
- wrapped_key,
url_request_context_getter_,
- info_url_prefix,
- mackey_url_prefix,
+ url_prefix,
disable_auto_update);
protocol_manager_->Initialize();
@@ -1005,17 +976,6 @@ void SafeBrowsingService::DatabaseUpdateFinished(bool update_succeeded) {
void SafeBrowsingService::Start() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // Retrieve client MAC keys.
- PrefService* local_state = g_browser_process->local_state();
- DCHECK(local_state);
- std::string client_key, wrapped_key;
- if (local_state) {
- client_key =
- local_state->GetString(prefs::kSafeBrowsingClientKey);
- wrapped_key =
- local_state->GetString(prefs::kSafeBrowsingWrappedKey);
- }
-
CommandLine* cmdline = CommandLine::ForCurrentProcess();
enable_download_protection_ =
!cmdline->HasSwitch(switches::kSbDisableDownloadProtection);
@@ -1039,8 +999,7 @@ void SafeBrowsingService::Start() {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(&SafeBrowsingService::StartOnIOThread,
- this, client_key, wrapped_key));
+ base::Bind(&SafeBrowsingService::StartOnIOThread, this));
}
void SafeBrowsingService::Stop() {
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h
index 7b68ee9..511a758 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.h
+++ b/chrome/browser/safe_browsing/safe_browsing_service.h
@@ -263,11 +263,6 @@ class SafeBrowsingService
void OnBlockingPageDone(const std::vector<UnsafeResource>& resources,
bool proceed);
- // Called on the UI thread when the SafeBrowsingProtocolManager has received
- // updated MAC keys.
- void OnNewMacKeys(const std::string& client_key,
- const std::string& wrapped_key);
-
bool enabled() const { return enabled_; }
bool download_protection_enabled() const {
@@ -288,9 +283,6 @@ class SafeBrowsingService
net::URLRequestContextGetter* url_request_context();
- // Preference handling.
- static void RegisterPrefs(PrefService* prefs);
-
// Called on the IO thread to reset the database.
void ResetDatabase();
@@ -357,8 +349,7 @@ class SafeBrowsingService
// Called to initialize objects that are used on the io_thread. This may be
// called multiple times during the life of the SafeBrowsingService.
- void StartOnIOThread(const std::string& client_key,
- const std::string& wrapped_key);
+ void StartOnIOThread();
// Called to shutdown operations on the io_thread. This may be called multiple
// times during the life of the SafeBrowsingService.
diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
index 3340b21..a330994 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
@@ -194,15 +194,11 @@ class TestProtocolManager : public SafeBrowsingProtocolManager {
public:
TestProtocolManager(SafeBrowsingService* sb_service,
const std::string& client_name,
- const std::string& client_key,
- const std::string& wrapped_key,
net::URLRequestContextGetter* request_context_getter,
- const std::string& info_url_prefix,
- const std::string& mackey_url_prefix,
+ const std::string& url_prefix,
bool disable_auto_update)
- : SafeBrowsingProtocolManager(sb_service, client_name, client_key,
- wrapped_key, request_context_getter,
- info_url_prefix, mackey_url_prefix,
+ : SafeBrowsingProtocolManager(sb_service, client_name,
+ request_context_getter, url_prefix,
disable_auto_update),
sb_service_(sb_service),
delay_ms_(0) {
@@ -249,16 +245,12 @@ class TestSBProtocolManagerFactory : public SBProtocolManagerFactory {
virtual SafeBrowsingProtocolManager* CreateProtocolManager(
SafeBrowsingService* sb_service,
const std::string& client_name,
- const std::string& client_key,
- const std::string& wrapped_key,
net::URLRequestContextGetter* request_context_getter,
- const std::string& info_url_prefix,
- const std::string& mackey_url_prefix,
+ const std::string& url_prefix,
bool disable_auto_update) {
pm_ = new TestProtocolManager(
- sb_service, client_name, client_key, wrapped_key,
- request_context_getter, info_url_prefix, mackey_url_prefix,
- disable_auto_update);
+ sb_service, client_name, request_context_getter,
+ url_prefix, disable_auto_update);
return pm_;
}
TestProtocolManager* GetProtocolManager() {
diff --git a/chrome/browser/safe_browsing/safe_browsing_test.cc b/chrome/browser/safe_browsing/safe_browsing_test.cc
index 877d943..3983e83 100644
--- a/chrome/browser/safe_browsing/safe_browsing_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_test.cc
@@ -52,7 +52,8 @@ using content::BrowserThread;
namespace {
-const FilePath::CharType kDataFile[] = FILE_PATH_LITERAL("testing_input.dat");
+const FilePath::CharType kDataFile[] =
+ FILE_PATH_LITERAL("testing_input_nomac.dat");
const char kUrlVerifyPath[] = "/safebrowsing/verify_urls";
const char kDBVerifyPath[] = "/safebrowsing/verify_database";
const char kDBResetPath[] = "/reset";
@@ -209,7 +210,6 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
SafeBrowsingServiceTest()
: safe_browsing_service_(NULL),
is_database_ready_(true),
- is_initial_request_(false),
is_update_scheduled_(false),
is_checked_url_in_db_(false),
is_checked_url_safe_(false) {
@@ -221,8 +221,6 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
void UpdateSafeBrowsingStatus() {
ASSERT_TRUE(safe_browsing_service_);
base::AutoLock lock(update_status_mutex_);
- is_initial_request_ =
- safe_browsing_service_->protocol_manager_->is_initial_request();
last_update_ = safe_browsing_service_->protocol_manager_->last_update();
is_update_scheduled_ =
safe_browsing_service_->protocol_manager_->update_timer_.IsRunning();
@@ -273,11 +271,6 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
return is_database_ready_;
}
- bool is_initial_request() {
- base::AutoLock l(update_status_mutex_);
- return is_initial_request_;
- }
-
base::Time last_update() {
base::AutoLock l(update_status_mutex_);
return last_update_;
@@ -317,15 +310,12 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
command_line->AppendSwitch(
switches::kDisableClientSidePhishingDetection);
- // In this test, we fetch SafeBrowsing data and Mac key from the same
- // server. Although in real production, they are served from different
- // servers.
+ // Point to the testing server for all SafeBrowsing requests.
std::string url_prefix =
base::StringPrintf("http://%s:%d/safebrowsing",
SafeBrowsingTestServer::Host(),
SafeBrowsingTestServer::Port());
- command_line->AppendSwitchASCII(switches::kSbInfoURLPrefix, url_prefix);
- command_line->AppendSwitchASCII(switches::kSbMacKeyURLPrefix, url_prefix);
+ command_line->AppendSwitchASCII(switches::kSbURLPrefix, url_prefix);
}
void SetTestStep(int step) {
@@ -342,7 +332,6 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
// States associated with safebrowsing service updates.
bool is_database_ready_;
- bool is_initial_request_;
base::Time last_update_;
bool is_update_scheduled_;
// Indicates if there is a match between a URL's prefix and safebrowsing
@@ -577,7 +566,6 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest,
// is checked.
safe_browsing_helper->WaitForStatusUpdate(0);
EXPECT_TRUE(is_database_ready());
- EXPECT_TRUE(is_initial_request());
EXPECT_FALSE(is_update_scheduled());
EXPECT_TRUE(last_update().is_null());
// Starts updates. After each update, the test will fetch a list of URLs with
@@ -601,8 +589,7 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest,
// Periodically pull the status.
safe_browsing_helper->WaitForStatusUpdate(
TestTimeouts::tiny_timeout_ms());
- } while (is_update_scheduled() || is_initial_request() ||
- !is_database_ready());
+ } while (is_update_scheduled() || !is_database_ready());
if (last_update() < now) {
diff --git a/chrome/browser/safe_browsing/safe_browsing_util.cc b/chrome/browser/safe_browsing/safe_browsing_util.cc
index 4f10429..10ef5a2 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util.cc
@@ -4,12 +4,10 @@
#include "chrome/browser/safe_browsing/safe_browsing_util.h"
-#include "base/base64.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "chrome/browser/google/google_util.h"
-#include "crypto/hmac.h"
#include "crypto/sha2.h"
#include "googleurl/src/gurl.h"
#include "googleurl/src/url_util.h"
@@ -20,8 +18,6 @@
#include "chrome/installer/util/browser_distribution.h"
#endif
-static const int kSafeBrowsingMacDigestSize = 20;
-
// Continue to this URL after submitting the phishing report form.
// TODO(paulg): Change to a Chrome specific URL.
static const char kContinueUrlFormat[] =
@@ -479,39 +475,6 @@ bool IsBadbinhashList(const std::string& list_name) {
return list_name.compare(kBinHashList) == 0;
}
-static void DecodeWebSafe(std::string* decoded) {
- DCHECK(decoded);
- for (std::string::iterator i(decoded->begin()); i != decoded->end(); ++i) {
- if (*i == '_')
- *i = '/';
- else if (*i == '-')
- *i = '+';
- }
-}
-
-bool VerifyMAC(const std::string& key, const std::string& mac,
- const char* data, int data_length) {
- std::string key_copy = key;
- DecodeWebSafe(&key_copy);
- std::string decoded_key;
- base::Base64Decode(key_copy, &decoded_key);
-
- std::string mac_copy = mac;
- DecodeWebSafe(&mac_copy);
- std::string decoded_mac;
- base::Base64Decode(mac_copy, &decoded_mac);
-
- crypto::HMAC hmac(crypto::HMAC::SHA1);
- if (!hmac.Init(decoded_key))
- return false;
- const std::string data_str(data, data_length);
- unsigned char digest[kSafeBrowsingMacDigestSize];
- if (!hmac.Sign(data_str, digest, kSafeBrowsingMacDigestSize))
- return false;
-
- return !memcmp(digest, decoded_mac.data(), kSafeBrowsingMacDigestSize);
-}
-
GURL GeneratePhishingReportUrl(const std::string& report_page,
const std::string& url_to_report,
bool is_client_side_detection) {
diff --git a/chrome/browser/safe_browsing/safe_browsing_util.h b/chrome/browser/safe_browsing/safe_browsing_util.h
index 577ffab..4d8abd0 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util.h
+++ b/chrome/browser/safe_browsing/safe_browsing_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
//
@@ -23,10 +23,9 @@ class SBEntry;
// A truncated hash's type.
typedef int32 SBPrefix;
-// Container for holding a chunk URL and the MAC of the contents of the URL.
+// Container for holding a chunk URL and the list it belongs to.
struct ChunkUrl {
std::string url;
- std::string mac;
std::string list_name;
};
@@ -319,12 +318,6 @@ bool IsMalwareList(const std::string& list_name);
bool IsBadbinurlList(const std::string& list_name);
bool IsBadbinhashList(const std::string& list_name);
-// Returns 'true' if 'mac' can be verified using 'key' and 'data'.
-bool VerifyMAC(const std::string& key,
- const std::string& mac,
- const char* data,
- int data_length);
-
GURL GeneratePhishingReportUrl(const std::string& report_page,
const std::string& url_to_report,
bool is_client_side_detection);