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