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 // Various utility methods for nigori-based multi-type encryption. | 5 // Various utility methods for nigori-based multi-type encryption. |
6 | 6 |
7 #ifndef COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ | 7 #ifndef COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ |
8 #define COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ | 8 #define COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "components/sync/base/model_type.h" | 11 #include "components/sync/base/model_type.h" |
| 12 #include "components/sync/base/passphrase_type.h" |
12 #include "components/sync/protocol/nigori_specifics.pb.h" | 13 #include "components/sync/protocol/nigori_specifics.pb.h" |
13 | 14 |
14 namespace sync_pb { | 15 namespace sync_pb { |
15 class EntitySpecifics; | 16 class EntitySpecifics; |
16 } | 17 } |
17 | 18 |
18 namespace syncer { | 19 namespace syncer { |
19 class Cryptographer; | 20 class Cryptographer; |
20 | 21 |
21 namespace syncable { | 22 namespace syncable { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 ModelType type, | 55 ModelType type, |
55 bool is_encrypted) WARN_UNUSED_RESULT; | 56 bool is_encrypted) WARN_UNUSED_RESULT; |
56 | 57 |
57 // Stores |new_specifics| into |entry|, encrypting if necessary. | 58 // Stores |new_specifics| into |entry|, encrypting if necessary. |
58 // Returns false if an error encrypting occurred (does not modify |entry|). | 59 // Returns false if an error encrypting occurred (does not modify |entry|). |
59 // Note: gracefully handles new_specifics aliasing with entry->GetSpecifics(). | 60 // Note: gracefully handles new_specifics aliasing with entry->GetSpecifics(). |
60 bool UpdateEntryWithEncryption(BaseTransaction* const trans, | 61 bool UpdateEntryWithEncryption(BaseTransaction* const trans, |
61 const sync_pb::EntitySpecifics& new_specifics, | 62 const sync_pb::EntitySpecifics& new_specifics, |
62 MutableEntry* entry); | 63 MutableEntry* entry); |
63 | 64 |
| 65 // Same as |UpdateEntryWithEncryption|, but with explicit |passphrase_type| |
| 66 // which will be used to decide if the sensitive data should be removed before |
| 67 // re-enctypting. |
| 68 bool UpdateEntryWithEncryption(BaseTransaction* const trans, |
| 69 const sync_pb::EntitySpecifics& new_specifics, |
| 70 MutableEntry* entry, |
| 71 PassphraseType passphrase_type); |
| 72 |
64 // Updates |nigori| to match the encryption state specified by |encrypted_types| | 73 // Updates |nigori| to match the encryption state specified by |encrypted_types| |
65 // and |encrypt_everything|. | 74 // and |encrypt_everything|. |
66 void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, | 75 void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, |
67 bool encrypt_everything, | 76 bool encrypt_everything, |
68 sync_pb::NigoriSpecifics* nigori); | 77 sync_pb::NigoriSpecifics* nigori); |
69 | 78 |
70 // Extracts the set of encrypted types from a nigori node. | 79 // Extracts the set of encrypted types from a nigori node. |
71 ModelTypeSet GetEncryptedTypesFromNigori( | 80 ModelTypeSet GetEncryptedTypesFromNigori( |
72 const sync_pb::NigoriSpecifics& nigori); | 81 const sync_pb::NigoriSpecifics& nigori); |
73 | 82 |
74 } // namespace syncable | 83 } // namespace syncable |
75 } // namespace syncer | 84 } // namespace syncer |
76 | 85 |
77 #endif // COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ | 86 #endif // COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ |
OLD | NEW |