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 "components/sync/core_impl/sync_encryption_handler_impl.h" | 5 #include "components/sync/core_impl/sync_encryption_handler_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <queue> | 11 #include <queue> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/base64.h" | 14 #include "base/base64.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/json/json_string_value_serializer.h" | 16 #include "base/json/json_string_value_serializer.h" |
17 #include "base/location.h" | 17 #include "base/location.h" |
18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "base/tracked_objects.h" | 22 #include "base/tracked_objects.h" |
23 #include "components/sync/base/cryptographer.h" | 23 #include "components/sync/base/cryptographer.h" |
24 #include "components/sync/base/encryptor.h" | 24 #include "components/sync/base/encryptor.h" |
25 #include "components/sync/base/experiments.h" | 25 #include "components/sync/base/experiments.h" |
| 26 #include "components/sync/base/passphrase_type.h" |
26 #include "components/sync/base/time.h" | 27 #include "components/sync/base/time.h" |
27 #include "components/sync/core/read_node.h" | 28 #include "components/sync/core/read_node.h" |
28 #include "components/sync/core/read_transaction.h" | 29 #include "components/sync/core/read_transaction.h" |
29 #include "components/sync/core/user_share.h" | 30 #include "components/sync/core/user_share.h" |
30 #include "components/sync/core/write_node.h" | 31 #include "components/sync/core/write_node.h" |
31 #include "components/sync/core/write_transaction.h" | 32 #include "components/sync/core/write_transaction.h" |
32 #include "components/sync/engine/sync_string_conversions.h" | 33 #include "components/sync/engine/sync_string_conversions.h" |
33 #include "components/sync/protocol/encryption.pb.h" | 34 #include "components/sync/protocol/encryption.pb.h" |
34 #include "components/sync/protocol/nigori_specifics.pb.h" | 35 #include "components/sync/protocol/nigori_specifics.pb.h" |
35 #include "components/sync/protocol/sync.pb.h" | 36 #include "components/sync/protocol/sync.pb.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 case PassphraseType::CUSTOM_PASSPHRASE: | 121 case PassphraseType::CUSTOM_PASSPHRASE: |
121 return sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE; | 122 return sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE; |
122 case PassphraseType::FROZEN_IMPLICIT_PASSPHRASE: | 123 case PassphraseType::FROZEN_IMPLICIT_PASSPHRASE: |
123 return sync_pb::NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE; | 124 return sync_pb::NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE; |
124 default: | 125 default: |
125 NOTREACHED(); | 126 NOTREACHED(); |
126 return sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE; | 127 return sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE; |
127 } | 128 } |
128 } | 129 } |
129 | 130 |
130 bool IsExplicitPassphrase(PassphraseType type) { | |
131 return type == PassphraseType::CUSTOM_PASSPHRASE || | |
132 type == PassphraseType::FROZEN_IMPLICIT_PASSPHRASE; | |
133 } | |
134 | |
135 // Keystore Bootstrap Token helper methods. | 131 // Keystore Bootstrap Token helper methods. |
136 // The bootstrap is a base64 encoded, encrypted, ListValue of keystore key | 132 // The bootstrap is a base64 encoded, encrypted, ListValue of keystore key |
137 // strings, with the current keystore key as the last value in the list. | 133 // strings, with the current keystore key as the last value in the list. |
138 std::string PackKeystoreBootstrapToken( | 134 std::string PackKeystoreBootstrapToken( |
139 const std::vector<std::string>& old_keystore_keys, | 135 const std::vector<std::string>& old_keystore_keys, |
140 const std::string& current_keystore_key, | 136 const std::string& current_keystore_key, |
141 Encryptor* encryptor) { | 137 Encryptor* encryptor) { |
142 if (current_keystore_key.empty()) | 138 if (current_keystore_key.empty()) |
143 return std::string(); | 139 return std::string(); |
144 | 140 |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 | 1641 |
1646 base::Time SyncEncryptionHandlerImpl::GetExplicitPassphraseTime() const { | 1642 base::Time SyncEncryptionHandlerImpl::GetExplicitPassphraseTime() const { |
1647 if (passphrase_type_ == PassphraseType::FROZEN_IMPLICIT_PASSPHRASE) | 1643 if (passphrase_type_ == PassphraseType::FROZEN_IMPLICIT_PASSPHRASE) |
1648 return migration_time(); | 1644 return migration_time(); |
1649 else if (passphrase_type_ == PassphraseType::CUSTOM_PASSPHRASE) | 1645 else if (passphrase_type_ == PassphraseType::CUSTOM_PASSPHRASE) |
1650 return custom_passphrase_time(); | 1646 return custom_passphrase_time(); |
1651 return base::Time(); | 1647 return base::Time(); |
1652 } | 1648 } |
1653 | 1649 |
1654 } // namespace syncer | 1650 } // namespace syncer |
OLD | NEW |