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

Side by Side Diff: chrome/browser/sync/util/cryptographer.cc

Issue 2828021: Take 2: sync changes to support encryption (Closed)
Patch Set: fix flaky password test under valgrind Created 10 years, 6 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
« no previous file with comments | « chrome/browser/sync/util/cryptographer.h ('k') | chrome/chrome_tests.gypi » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/sync/util/cryptographer.h" 5 #include "chrome/browser/sync/util/cryptographer.h"
6 6
7 namespace browser_sync { 7 namespace browser_sync {
8 8
9 const char kNigoriTag[] = "nigori"; 9 const char kNigoriTag[] = "google_chrome_nigori";
10 10
11 // We name a particular Nigori instance (ie. a triplet consisting of a hostname, 11 // We name a particular Nigori instance (ie. a triplet consisting of a hostname,
12 // a username, and a password) by calling Permute on this string. Since the 12 // a username, and a password) by calling Permute on this string. Since the
13 // output of Permute is always the same for a given triplet, clients will always 13 // output of Permute is always the same for a given triplet, clients will always
14 // assign the same name to a particular triplet. 14 // assign the same name to a particular triplet.
15 const char kNigoriKeyName[] = "nigori-key"; 15 const char kNigoriKeyName[] = "nigori-key";
16 16
17 Cryptographer::Cryptographer() { 17 Cryptographer::Cryptographer() : default_nigori_(NULL) {
18 } 18 }
19 19
20 bool Cryptographer::CanDecrypt(const sync_pb::EncryptedData& data) const { 20 bool Cryptographer::CanDecrypt(const sync_pb::EncryptedData& data) const {
21 return nigoris_.end() != nigoris_.find(data.key_name()); 21 return nigoris_.end() != nigoris_.find(data.key_name());
22 } 22 }
23 23
24 bool Cryptographer::Encrypt(const ::google::protobuf::MessageLite& message, 24 bool Cryptographer::Encrypt(const ::google::protobuf::MessageLite& message,
25 sync_pb::EncryptedData* encrypted) const { 25 sync_pb::EncryptedData* encrypted) const {
26 DCHECK(encrypted); 26 DCHECK(encrypted);
27 DCHECK(default_nigori_); 27 DCHECK(default_nigori_);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 continue; 148 continue;
149 } 149 }
150 nigoris_[key.name()] = make_linked_ptr(new_nigori.release()); 150 nigoris_[key.name()] = make_linked_ptr(new_nigori.release());
151 } 151 }
152 } 152 }
153 DCHECK(nigoris_.end() != nigoris_.find(default_key_name)); 153 DCHECK(nigoris_.end() != nigoris_.find(default_key_name));
154 default_nigori_ = &*nigoris_.find(default_key_name); 154 default_nigori_ = &*nigoris_.find(default_key_name);
155 } 155 }
156 156
157 } // namespace browser_sync 157 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/util/cryptographer.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698