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

Side by Side 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: Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/protector/protector.h" 5 #include "chrome/browser/protector/protector.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/protector/settings_change_global_error.h" 9 #include "chrome/browser/protector/settings_change_global_error.h"
10 #include "chrome/browser/protector/keys.h" 10 #include "chrome/browser/protector/keys.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::string SignSetting(const std::string& value) { 70 std::string SignSetting(const std::string& value) {
71 crypto::HMAC hmac(crypto::HMAC::SHA256); 71 crypto::HMAC hmac(crypto::HMAC::SHA256);
72 DCHECK(hmac.Init(kProtectorSigningKey)); 72 DCHECK(hmac.Init(kProtectorSigningKey));
73 73
74 std::vector<unsigned char> digest(hmac.DigestLength()); 74 std::vector<unsigned char> digest(hmac.DigestLength());
75 DCHECK(hmac.Sign(value, &digest[0], digest.size())); 75 DCHECK(hmac.Sign(value, &digest[0], digest.size()));
76 76
77 return std::string(&digest[0], &digest[0] + digest.size()); 77 return std::string(&digest[0], &digest[0] + digest.size());
78 } 78 }
79 79
80 bool IsSettingValid(const std::string& value, const std::string& signature) {
81 crypto::HMAC hmac(crypto::HMAC::SHA256);
82 DCHECK(hmac.Init(kProtectorSigningKey));
Ivan Korotkov 2011/11/01 14:18:39 Init should be called outside of DCHECK.
83 return hmac.Verify(value, signature);
84 }
85
80 } // namespace protector 86 } // namespace protector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698