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

Side by Side Diff: sync/util/cryptographer.h

Issue 10540149: [Sync] Persist keystore key across restarts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Cryptographer instance into the ready state (is_ready will be true). 92 // Cryptographer instance into the ready state (is_ready will be true).
93 // It must be a string that was previously built by the 93 // It must be a string that was previously built by the
94 // GetSerializedBootstrapToken function. It is possible that the token is no 94 // GetSerializedBootstrapToken function. It is possible that the token is no
95 // longer valid (due to server key change), in which case the normal 95 // longer valid (due to server key change), in which case the normal
96 // decryption code paths will fail and the user will need to provide a new 96 // decryption code paths will fail and the user will need to provide a new
97 // passphrase. 97 // passphrase.
98 // It is an error to call this if is_ready() == true, though it is fair to 98 // It is an error to call this if is_ready() == true, though it is fair to
99 // never call Bootstrap at all. 99 // never call Bootstrap at all.
100 void Bootstrap(const std::string& restored_bootstrap_token); 100 void Bootstrap(const std::string& restored_bootstrap_token);
101 101
102 // Bootstrap the keystore key.
103 void BootstrapKeystoreKey(
104 const std::string& restored_keystore_bootstrap_token);
105
102 // Returns whether we can decrypt |encrypted| using the keys we currently know 106 // Returns whether we can decrypt |encrypted| using the keys we currently know
103 // about. 107 // about.
104 bool CanDecrypt(const sync_pb::EncryptedData& encrypted) const; 108 bool CanDecrypt(const sync_pb::EncryptedData& encrypted) const;
105 109
106 // Returns whether |encrypted| can be decrypted using the default encryption 110 // Returns whether |encrypted| can be decrypted using the default encryption
107 // key. 111 // key.
108 bool CanDecryptUsingDefaultKey(const sync_pb::EncryptedData& encrypted) const; 112 bool CanDecryptUsingDefaultKey(const sync_pb::EncryptedData& encrypted) const;
109 113
110 // Encrypts |message| into |encrypted|. Does not overwrite |encrypted| if 114 // Encrypts |message| into |encrypted|. Does not overwrite |encrypted| if
111 // |message| already matches the decrypted data within |encrypted| and 115 // |message| already matches the decrypted data within |encrypted| and
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 has_pending_keys() == false; } 167 has_pending_keys() == false; }
164 168
165 // Returns whether there is a pending set of keys that needs to be decrypted. 169 // Returns whether there is a pending set of keys that needs to be decrypted.
166 bool has_pending_keys() const { return NULL != pending_keys_.get(); } 170 bool has_pending_keys() const { return NULL != pending_keys_.get(); }
167 171
168 // Obtain a token that can be provided on construction to a future 172 // Obtain a token that can be provided on construction to a future
169 // Cryptographer instance to bootstrap itself. Returns false if such a token 173 // Cryptographer instance to bootstrap itself. Returns false if such a token
170 // can't be created (i.e. if this Cryptograhper doesn't have valid keys). 174 // can't be created (i.e. if this Cryptograhper doesn't have valid keys).
171 bool GetBootstrapToken(std::string* token) const; 175 bool GetBootstrapToken(std::string* token) const;
172 176
177 // Obtain the bootstrap token based on the keystore encryption key.
178 bool GetKeystoreKeyBootstrapToken(std::string* token) const;
179
173 // Update the cryptographer based on the contents of the nigori specifics. 180 // Update the cryptographer based on the contents of the nigori specifics.
174 // This updates both the encryption keys and the set of encrypted types. 181 // This updates both the encryption keys and the set of encrypted types.
175 // Returns NEEDS_PASSPHRASE if was unable to decrypt the pending keys, 182 // Returns NEEDS_PASSPHRASE if was unable to decrypt the pending keys,
176 // SUCCESS otherwise. 183 // SUCCESS otherwise.
177 // Note: will not change the default key. If the nigori's keybag 184 // Note: will not change the default key. If the nigori's keybag
178 // is decryptable, all keys are added to the local keybag and the current 185 // is decryptable, all keys are added to the local keybag and the current
179 // default is preserved. If the nigori's keybag is not decryptable, it is 186 // default is preserved. If the nigori's keybag is not decryptable, it is
180 // stored in the |pending_keys_|. 187 // stored in the |pending_keys_|.
181 UpdateResult Update(const sync_pb::NigoriSpecifics& nigori); 188 UpdateResult Update(const sync_pb::NigoriSpecifics& nigori);
182 189
183 // Set the keystore-derived nigori from the provided key. 190 // Set the keystore-derived nigori from the provided key.
184 // Returns true if we succesfully create the keystore derived nigori from the 191 // Returns true if we succesfully create the keystore derived nigori from the
185 // provided key, false otherwise. 192 // provided key, false otherwise.
186 bool SetKeystoreKey(const std::string& keystore_key); 193 bool SetKeystoreKey(const std::string& keystore_key);
187 194
188 // Returns true if we currently have a keystore-derived nigori, false 195 // Returns true if we currently have a keystore-derived nigori, false
189 // otherwise. 196 // otherwise.
190 bool HasKeystoreKey(); 197 bool HasKeystoreKey() const;
191 198
192 // The set of types that are always encrypted. 199 // The set of types that are always encrypted.
193 static syncable::ModelTypeSet SensitiveTypes(); 200 static syncable::ModelTypeSet SensitiveTypes();
194 201
195 // Reset our set of encrypted types based on the contents of the nigori 202 // Reset our set of encrypted types based on the contents of the nigori
196 // specifics. 203 // specifics.
197 void UpdateEncryptedTypesFromNigori(const sync_pb::NigoriSpecifics& nigori); 204 void UpdateEncryptedTypesFromNigori(const sync_pb::NigoriSpecifics& nigori);
198 205
199 // Update the nigori to reflect the current set of encrypted types. 206 // Update the nigori to reflect the current set of encrypted types.
200 void UpdateNigoriFromEncryptedTypes(sync_pb::NigoriSpecifics* nigori) const; 207 void UpdateNigoriFromEncryptedTypes(sync_pb::NigoriSpecifics* nigori) const;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 261
255 syncable::ModelTypeSet encrypted_types_; 262 syncable::ModelTypeSet encrypted_types_;
256 bool encrypt_everything_; 263 bool encrypt_everything_;
257 264
258 DISALLOW_COPY_AND_ASSIGN(Cryptographer); 265 DISALLOW_COPY_AND_ASSIGN(Cryptographer);
259 }; 266 };
260 267
261 } // namespace browser_sync 268 } // namespace browser_sync
262 269
263 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_ 270 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698