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

Unified Diff: chrome/browser/protector/protector.cc

Issue 8430027: Added histogram on successful check. Safe verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed signing, added counters Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/protector/protector.h ('k') | chrome/browser/webdata/keyword_table.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/protector/protector.cc
diff --git a/chrome/browser/protector/protector.cc b/chrome/browser/protector/protector.cc
index e26fe18b8eea59a542401231c2675f1164139366..1b2d04185146a018f23401506752200f674e3f3b 100644
--- a/chrome/browser/protector/protector.cc
+++ b/chrome/browser/protector/protector.cc
@@ -69,12 +69,27 @@ void Protector::OnChangesAction(SettingChangeAction action) {
std::string SignSetting(const std::string& value) {
crypto::HMAC hmac(crypto::HMAC::SHA256);
- DCHECK(hmac.Init(kProtectorSigningKey));
+ if (!hmac.Init(kProtectorSigningKey)) {
+ LOG(WARNING) << "Failed to initialize HMAC algorithm for signing";
Ilya Sherman 2011/11/01 18:19:11 Are you sure you want LOG(WARNING) here rather tha
whywhat 2011/11/02 08:14:29 HMAC implementation is platform dependent so may c
+ return std::string();
+ }
std::vector<unsigned char> digest(hmac.DigestLength());
- DCHECK(hmac.Sign(value, &digest[0], digest.size()));
+ if (!hmac.Sign(value, &digest[0], digest.size())) {
+ LOG(WARNING) << "Failed to sign setting";
+ return std::string();
+ }
return std::string(&digest[0], &digest[0] + digest.size());
}
+bool IsSettingValid(const std::string& value, const std::string& signature) {
+ crypto::HMAC hmac(crypto::HMAC::SHA256);
+ if (!hmac.Init(kProtectorSigningKey)) {
+ LOG(WARNING) << "Failed to initialize HMAC algorithm for verification.";
+ return false;
+ }
+ return hmac.Verify(value, signature);
+}
+
} // namespace protector
« no previous file with comments | « chrome/browser/protector/protector.h ('k') | chrome/browser/webdata/keyword_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698