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

Side by Side Diff: chrome/browser/protector/protector_utils.cc

Issue 11493003: Remove the protector service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix implicit ExtensionSystem -> TemplateURLService dependency Created 8 years 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/protector/protector_utils.h"
6
7 #include <vector>
8
9 #include "base/command_line.h"
10 #include "base/logging.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/protector/keys.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "crypto/hmac.h"
15
16 namespace protector {
17
18 std::string SignSetting(const std::string& value) {
19 crypto::HMAC hmac(crypto::HMAC::SHA256);
20 if (!hmac.Init(kProtectorSigningKey)) {
21 LOG(WARNING) << "Failed to initialize HMAC algorithm for signing";
22 return std::string();
23 }
24
25 std::vector<unsigned char> digest(hmac.DigestLength());
26 if (!hmac.Sign(value, &digest[0], digest.size())) {
27 LOG(WARNING) << "Failed to sign setting";
28 return std::string();
29 }
30
31 return std::string(&digest[0], &digest[0] + digest.size());
32 }
33
34 bool IsSettingValid(const std::string& value, const std::string& signature) {
35 crypto::HMAC hmac(crypto::HMAC::SHA256);
36 if (!hmac.Init(kProtectorSigningKey)) {
37 LOG(WARNING) << "Failed to initialize HMAC algorithm for verification.";
38 return false;
39 }
40 return hmac.Verify(value, signature);
41 }
42
43 bool IsEnabled() {
44 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kProtector);
45 }
46
47 } // namespace protector
OLDNEW
« no previous file with comments | « chrome/browser/protector/protector_utils.h ('k') | chrome/browser/protector/session_startup_change.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698