Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_util.cc

Issue 218: HMAC-SHA1 implementation for Mac based on CommonCrypto (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/hmac_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
6 6
7 #include "base/hmac.h" 7 #include "base/hmac.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/sha2.h" 9 #include "base/sha2.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 std::string key_copy = key; 140 std::string key_copy = key;
141 DecodeWebSafe(&key_copy); 141 DecodeWebSafe(&key_copy);
142 std::string decoded_key; 142 std::string decoded_key;
143 net::Base64Decode(key_copy, &decoded_key); 143 net::Base64Decode(key_copy, &decoded_key);
144 144
145 std::string mac_copy = mac; 145 std::string mac_copy = mac;
146 DecodeWebSafe(&mac_copy); 146 DecodeWebSafe(&mac_copy);
147 std::string decoded_mac; 147 std::string decoded_mac;
148 net::Base64Decode(mac_copy, &decoded_mac); 148 net::Base64Decode(mac_copy, &decoded_mac);
149 149
150 HMAC hmac(HMAC::SHA1, 150 base::HMAC hmac(base::HMAC::SHA1,
151 reinterpret_cast<const unsigned char*>(decoded_key.data()), 151 reinterpret_cast<const unsigned char*>(decoded_key.data()),
152 static_cast<int>(decoded_key.length())); 152 static_cast<int>(decoded_key.length()));
153 const std::string data_str(data, data_length); 153 const std::string data_str(data, data_length);
154 unsigned char digest[kSafeBrowsingMacDigestSize]; 154 unsigned char digest[kSafeBrowsingMacDigestSize];
155 if (!hmac.Sign(data_str, digest, kSafeBrowsingMacDigestSize)) 155 if (!hmac.Sign(data_str, digest, kSafeBrowsingMacDigestSize))
156 return false; 156 return false;
157 157
158 return memcmp(digest, decoded_mac.data(), kSafeBrowsingMacDigestSize) == 0; 158 return memcmp(digest, decoded_mac.data(), kSafeBrowsingMacDigestSize) == 0;
159 } 159 }
160 160
161 void FreeChunks(std::deque<SBChunk>* chunks) { 161 void FreeChunks(std::deque<SBChunk>* chunks) {
162 while (!chunks->empty()) { 162 while (!chunks->empty()) {
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 // Validate that the next entry is wholly contained inside of |data_|. 598 // Validate that the next entry is wholly contained inside of |data_|.
599 const char* end = data_.get() + size_; 599 const char* end = data_.get() + size_;
600 if (next + SBEntry::kMinSize <= end && next + next_entry->Size() <= end) { 600 if (next + SBEntry::kMinSize <= end && next + next_entry->Size() <= end) {
601 *entry = next_entry; 601 *entry = next_entry;
602 return true; 602 return true;
603 } 603 }
604 604
605 return false; 605 return false;
606 } 606 }
607 607
OLDNEW
« no previous file with comments | « base/hmac_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698