| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/engine/nigori_util.h" | 5 #include "chrome/browser/sync/engine/nigori_util.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 if (EntryNeedsEncryption(encrypted_types, entry)) | 52 if (EntryNeedsEncryption(encrypted_types, entry)) |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool EntryNeedsEncryption(const ModelTypeSet& encrypted_types, | 58 bool EntryNeedsEncryption(const ModelTypeSet& encrypted_types, |
| 59 const Entry& entry) { | 59 const Entry& entry) { |
| 60 if (!entry.Get(UNIQUE_SERVER_TAG).empty()) | 60 if (!entry.Get(UNIQUE_SERVER_TAG).empty()) |
| 61 return false; // We don't encrypt unique server nodes. | 61 return false; // We don't encrypt unique server nodes. |
| 62 return SpecificsNeedsEncryption(encrypted_types, entry.Get(SPECIFICS)); | 62 syncable::ModelType type = entry.GetModelType(); |
| 63 if (type == PASSWORDS || type == NIGORI) |
| 64 return false; |
| 65 // Checking NON_UNIQUE_NAME is not necessary for the correctness of encrypting |
| 66 // the data, nor for determining if data is encrypted. We simply ensure it has |
| 67 // been overwritten to avoid any possible leaks of sensitive data. |
| 68 return SpecificsNeedsEncryption(encrypted_types, entry.Get(SPECIFICS)) || |
| 69 (encrypted_types.count(type) > 0 && |
| 70 entry.Get(NON_UNIQUE_NAME) != kEncryptedString); |
| 63 } | 71 } |
| 64 | 72 |
| 65 bool SpecificsNeedsEncryption(const ModelTypeSet& encrypted_types, | 73 bool SpecificsNeedsEncryption(const ModelTypeSet& encrypted_types, |
| 66 const sync_pb::EntitySpecifics& specifics) { | 74 const sync_pb::EntitySpecifics& specifics) { |
| 67 ModelType type = GetModelTypeFromSpecifics(specifics); | 75 ModelType type = GetModelTypeFromSpecifics(specifics); |
| 68 if (type == PASSWORDS || type == NIGORI) | 76 if (type == PASSWORDS || type == NIGORI) |
| 69 return false; // These types have their own encryption schemes. | 77 return false; // These types have their own encryption schemes. |
| 70 if (encrypted_types.count(type) == 0) | 78 if (encrypted_types.count(type) == 0) |
| 71 return false; // This type does not require encryption | 79 return false; // This type does not require encryption |
| 72 return !specifics.has_encrypted(); | 80 return !specifics.has_encrypted(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return false; | 130 return false; |
| 123 } | 131 } |
| 124 } | 132 } |
| 125 // Push the successor. | 133 // Push the successor. |
| 126 to_visit.push(child.Get(NEXT_ID)); | 134 to_visit.push(child.Get(NEXT_ID)); |
| 127 } | 135 } |
| 128 return true; | 136 return true; |
| 129 } | 137 } |
| 130 | 138 |
| 131 } // namespace syncable | 139 } // namespace syncable |
| OLD | NEW |