Chromium Code Reviews| Index: sync/util/cryptographer.cc |
| diff --git a/sync/util/cryptographer.cc b/sync/util/cryptographer.cc |
| index 92f97954fa0e741fe1368ebd6ad021448f775ee8..1c9684d16a362da422f7b48c6043af492f422c6f 100644 |
| --- a/sync/util/cryptographer.cc |
| +++ b/sync/util/cryptographer.cc |
| @@ -23,8 +23,7 @@ const char kNigoriKeyName[] = "nigori-key"; |
| Cryptographer::Cryptographer(Encryptor* encryptor) |
| : encryptor_(encryptor), |
| - default_nigori_(NULL), |
| - keystore_nigori_(NULL) { |
| + default_nigori_(NULL) { |
| DCHECK(encryptor); |
| } |
| @@ -39,19 +38,7 @@ void Cryptographer::Bootstrap(const std::string& restored_bootstrap_token) { |
| scoped_ptr<Nigori> nigori(UnpackBootstrapToken(restored_bootstrap_token)); |
| if (nigori.get()) |
| - AddKeyImpl(nigori.release(), false); |
| -} |
| - |
| -void Cryptographer::BootstrapKeystoreKey( |
| - const std::string& restored_bootstrap_token) { |
| - if (keystore_nigori_) { |
| - NOTREACHED(); |
| - return; |
| - } |
| - |
| - scoped_ptr<Nigori> nigori(UnpackBootstrapToken(restored_bootstrap_token)); |
| - if (nigori.get()) |
| - AddKeyImpl(nigori.release(), true); |
| + AddKeyImpl(nigori.release()); |
|
akalin
2012/08/22 22:09:34
consider making AddKeyImpl take a scoped_ptr<>?
Nicolas Zea
2012/08/22 22:48:59
Done.
|
| } |
| bool Cryptographer::CanDecrypt(const sync_pb::EncryptedData& data) const { |
| @@ -147,7 +134,7 @@ bool Cryptographer::AddKey(const KeyParams& params) { |
| NOTREACHED(); // Invalid username or password. |
| return false; |
| } |
| - return AddKeyImpl(nigori.release(), false); |
| + return AddKeyImpl(nigori.release()); |
| } |
| bool Cryptographer::AddKeyFromBootstrapToken( |
| @@ -156,11 +143,10 @@ bool Cryptographer::AddKeyFromBootstrapToken( |
| scoped_ptr<Nigori> nigori(UnpackBootstrapToken(restored_bootstrap_token)); |
| if (!nigori.get()) |
| return false; |
| - return AddKeyImpl(nigori.release(), false); |
| + return AddKeyImpl(nigori.release()); |
| } |
| -bool Cryptographer::AddKeyImpl(Nigori* initialized_nigori, |
| - bool is_keystore_key) { |
| +bool Cryptographer::AddKeyImpl(Nigori* initialized_nigori) { |
| scoped_ptr<Nigori> nigori(initialized_nigori); |
| std::string name; |
| if (!nigori->Permute(Nigori::Password, kNigoriKeyName, &name)) { |
| @@ -168,10 +154,7 @@ bool Cryptographer::AddKeyImpl(Nigori* initialized_nigori, |
| return false; |
| } |
| nigoris_[name] = make_linked_ptr(nigori.release()); |
| - if (is_keystore_key) |
| - keystore_nigori_ = &*nigoris_.find(name); |
| - else |
| - default_nigori_ = &*nigoris_.find(name); |
| + default_nigori_ = &*nigoris_.find(name); |
| return true; |
| } |
| @@ -234,15 +217,6 @@ bool Cryptographer::GetBootstrapToken(std::string* token) const { |
| return PackBootstrapToken(default_nigori_->second.get(), token); |
| } |
| -bool Cryptographer::GetKeystoreKeyBootstrapToken( |
| - std::string* token) const { |
| - DCHECK(token); |
| - if (!HasKeystoreKey()) |
| - return false; |
| - |
| - return PackBootstrapToken(keystore_nigori_->second.get(), token); |
| -} |
| - |
| bool Cryptographer::PackBootstrapToken(const Nigori* nigori, |
| std::string* pack_into) const { |
| DCHECK(pack_into); |
| @@ -307,27 +281,6 @@ Nigori* Cryptographer::UnpackBootstrapToken(const std::string& token) const { |
| return nigori.release(); |
| } |
| -bool Cryptographer::SetKeystoreKey(const std::string& keystore_key) { |
| - if (keystore_key.empty()) |
| - return false; |
| - KeyParams params = {"localhost", "dummy", keystore_key}; |
| - |
| - // Create the new Nigori and make it the default keystore encryptor. |
| - scoped_ptr<Nigori> nigori(new Nigori); |
| - if (!nigori->InitByDerivation(params.hostname, |
| - params.username, |
| - params.password)) { |
| - NOTREACHED(); // Invalid username or password. |
| - return false; |
| - } |
| - |
| - return AddKeyImpl(nigori.release(), true); |
| -} |
| - |
| -bool Cryptographer::HasKeystoreKey() const { |
| - return keystore_nigori_ != NULL; |
| -} |
| - |
| void Cryptographer::InstallKeyBag(const sync_pb::NigoriKeyBag& bag) { |
| int key_size = bag.key_size(); |
| for (int i = 0; i < key_size; ++i) { |