OLD | NEW |
---|---|
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 Loading... | |
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 |
OLD | NEW |