| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef SYNC_UTIL_CRYPTOGRAPHER_H_ | 5 #ifndef SYNC_UTIL_CRYPTOGRAPHER_H_ |
| 6 #define SYNC_UTIL_CRYPTOGRAPHER_H_ | 6 #define SYNC_UTIL_CRYPTOGRAPHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Update the cryptographer based on the contents of the nigori specifics. | 172 // Update the cryptographer based on the contents of the nigori specifics. |
| 173 // This updates both the encryption keys and the set of encrypted types. | 173 // This updates both the encryption keys and the set of encrypted types. |
| 174 // Returns NEEDS_PASSPHRASE if was unable to decrypt the pending keys, | 174 // Returns NEEDS_PASSPHRASE if was unable to decrypt the pending keys, |
| 175 // SUCCESS otherwise. | 175 // SUCCESS otherwise. |
| 176 // Note: will not change the default key. If the nigori's keybag | 176 // Note: will not change the default key. If the nigori's keybag |
| 177 // is decryptable, all keys are added to the local keybag and the current | 177 // is decryptable, all keys are added to the local keybag and the current |
| 178 // default is preserved. If the nigori's keybag is not decryptable, it is | 178 // default is preserved. If the nigori's keybag is not decryptable, it is |
| 179 // stored in the |pending_keys_|. | 179 // stored in the |pending_keys_|. |
| 180 UpdateResult Update(const sync_pb::NigoriSpecifics& nigori); | 180 UpdateResult Update(const sync_pb::NigoriSpecifics& nigori); |
| 181 | 181 |
| 182 // Set the keystore-derived nigori from the provided key. |
| 183 // Returns true if we succesfully create the keystore derived nigori from the |
| 184 // provided key, false otherwise. |
| 185 bool SetKeystoreKey(const std::string& keystore_key); |
| 186 |
| 187 // Returns true if we currently have a keystore-derived nigori, false |
| 188 // otherwise. |
| 189 bool HasKeystoreKey(); |
| 190 |
| 182 // The set of types that are always encrypted. | 191 // The set of types that are always encrypted. |
| 183 static syncer::ModelTypeSet SensitiveTypes(); | 192 static syncer::ModelTypeSet SensitiveTypes(); |
| 184 | 193 |
| 185 // Reset our set of encrypted types based on the contents of the nigori | 194 // Reset our set of encrypted types based on the contents of the nigori |
| 186 // specifics. | 195 // specifics. |
| 187 void UpdateEncryptedTypesFromNigori(const sync_pb::NigoriSpecifics& nigori); | 196 void UpdateEncryptedTypesFromNigori(const sync_pb::NigoriSpecifics& nigori); |
| 188 | 197 |
| 189 // Update the nigori to reflect the current set of encrypted types. | 198 // Update the nigori to reflect the current set of encrypted types. |
| 190 void UpdateNigoriFromEncryptedTypes(sync_pb::NigoriSpecifics* nigori) const; | 199 void UpdateNigoriFromEncryptedTypes(sync_pb::NigoriSpecifics* nigori) const; |
| 191 | 200 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // persistence by sync infrastructure. | 239 // persistence by sync infrastructure. |
| 231 bool PackBootstrapToken(const Nigori* nigori, std::string* pack_into) const; | 240 bool PackBootstrapToken(const Nigori* nigori, std::string* pack_into) const; |
| 232 Nigori* UnpackBootstrapToken(const std::string& token) const; | 241 Nigori* UnpackBootstrapToken(const std::string& token) const; |
| 233 | 242 |
| 234 Encryptor* const encryptor_; | 243 Encryptor* const encryptor_; |
| 235 | 244 |
| 236 ObserverList<Observer> observers_; | 245 ObserverList<Observer> observers_; |
| 237 | 246 |
| 238 NigoriMap nigoris_; // The Nigoris we know about, mapped by key name. | 247 NigoriMap nigoris_; // The Nigoris we know about, mapped by key name. |
| 239 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption. | 248 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption. |
| 249 NigoriMap::value_type* keystore_nigori_; // Nigori generated from keystore. |
| 240 | 250 |
| 241 scoped_ptr<sync_pb::EncryptedData> pending_keys_; | 251 scoped_ptr<sync_pb::EncryptedData> pending_keys_; |
| 242 | 252 |
| 243 syncer::ModelTypeSet encrypted_types_; | 253 syncer::ModelTypeSet encrypted_types_; |
| 244 bool encrypt_everything_; | 254 bool encrypt_everything_; |
| 245 | 255 |
| 246 DISALLOW_COPY_AND_ASSIGN(Cryptographer); | 256 DISALLOW_COPY_AND_ASSIGN(Cryptographer); |
| 247 }; | 257 }; |
| 248 | 258 |
| 249 } // namespace syncer | 259 } // namespace syncer |
| 250 | 260 |
| 251 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_ | 261 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_ |
| OLD | NEW |