| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "sync/internal_api/sync_encryption_handler_impl.h" | 5 #include "sync/internal_api/sync_encryption_handler_impl.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 if (keys.size() == 0) | 685 if (keys.size() == 0) |
| 686 return false; | 686 return false; |
| 687 // The last key in the vector is the current keystore key. The others are kept | 687 // The last key in the vector is the current keystore key. The others are kept |
| 688 // around for decryption only. | 688 // around for decryption only. |
| 689 const std::string& raw_keystore_key = keys.Get(keys.size() - 1); | 689 const std::string& raw_keystore_key = keys.Get(keys.size() - 1); |
| 690 if (raw_keystore_key.empty()) | 690 if (raw_keystore_key.empty()) |
| 691 return false; | 691 return false; |
| 692 | 692 |
| 693 // Note: in order to Pack the keys, they must all be base64 encoded (else | 693 // Note: in order to Pack the keys, they must all be base64 encoded (else |
| 694 // JSON serialization fails). | 694 // JSON serialization fails). |
| 695 base::Base64Encode(raw_keystore_key, &keystore_key_); | 695 if (!base::Base64Encode(raw_keystore_key, &keystore_key_)) |
| 696 return false; |
| 696 | 697 |
| 697 // Go through and save the old keystore keys. We always persist all keystore | 698 // Go through and save the old keystore keys. We always persist all keystore |
| 698 // keys the server sends us. | 699 // keys the server sends us. |
| 699 old_keystore_keys_.resize(keys.size() - 1); | 700 old_keystore_keys_.resize(keys.size() - 1); |
| 700 for (int i = 0; i < keys.size() - 1; ++i) | 701 for (int i = 0; i < keys.size() - 1; ++i) |
| 701 base::Base64Encode(keys.Get(i), &old_keystore_keys_[i]); | 702 base::Base64Encode(keys.Get(i), &old_keystore_keys_[i]); |
| 702 | 703 |
| 703 Cryptographer* cryptographer = &UnlockVaultMutable(trans)->cryptographer; | 704 Cryptographer* cryptographer = &UnlockVaultMutable(trans)->cryptographer; |
| 704 | 705 |
| 705 // Update the bootstrap token. If this fails, we persist an empty string, | 706 // Update the bootstrap token. If this fails, we persist an empty string, |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 | 1643 |
| 1643 base::Time SyncEncryptionHandlerImpl::GetExplicitPassphraseTime() const { | 1644 base::Time SyncEncryptionHandlerImpl::GetExplicitPassphraseTime() const { |
| 1644 if (passphrase_type_ == FROZEN_IMPLICIT_PASSPHRASE) | 1645 if (passphrase_type_ == FROZEN_IMPLICIT_PASSPHRASE) |
| 1645 return migration_time(); | 1646 return migration_time(); |
| 1646 else if (passphrase_type_ == CUSTOM_PASSPHRASE) | 1647 else if (passphrase_type_ == CUSTOM_PASSPHRASE) |
| 1647 return custom_passphrase_time(); | 1648 return custom_passphrase_time(); |
| 1648 return base::Time(); | 1649 return base::Time(); |
| 1649 } | 1650 } |
| 1650 | 1651 |
| 1651 } // namespace browser_sync | 1652 } // namespace browser_sync |
| OLD | NEW |