| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 SYNC_SYNCABLE_NIGORI_UTIL_H_ | 7 #ifndef SYNC_SYNCABLE_NIGORI_UTIL_H_ |
| 8 #define SYNC_SYNCABLE_NIGORI_UTIL_H_ | 8 #define SYNC_SYNCABLE_NIGORI_UTIL_H_ |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // false if some unsynced changes need to be encrypted. | 33 // false if some unsynced changes need to be encrypted. |
| 34 // This method is similar to ProcessUnsyncedChangesForEncryption but does not | 34 // This method is similar to ProcessUnsyncedChangesForEncryption but does not |
| 35 // modify the data and does not care if data is unnecessarily encrypted. | 35 // modify the data and does not care if data is unnecessarily encrypted. |
| 36 bool VerifyUnsyncedChangesAreEncrypted( | 36 bool VerifyUnsyncedChangesAreEncrypted( |
| 37 BaseTransaction* const trans, | 37 BaseTransaction* const trans, |
| 38 ModelTypeSet encrypted_types); | 38 ModelTypeSet encrypted_types); |
| 39 | 39 |
| 40 // Processes all unsynced changes and ensures they are appropriately encrypted | 40 // Processes all unsynced changes and ensures they are appropriately encrypted |
| 41 // or unencrypted, based on |encrypted_types|. | 41 // or unencrypted, based on |encrypted_types|. |
| 42 bool ProcessUnsyncedChangesForEncryption( | 42 bool ProcessUnsyncedChangesForEncryption( |
| 43 WriteTransaction* const trans, | 43 WriteTransaction* const trans); |
| 44 Cryptographer* cryptographer); | |
| 45 | 44 |
| 46 // Returns true if the entry requires encryption but is not encrypted, false | 45 // Returns true if the entry requires encryption but is not encrypted, false |
| 47 // otherwise. Note: this does not check that already encrypted entries are | 46 // otherwise. Note: this does not check that already encrypted entries are |
| 48 // encrypted with the proper key. | 47 // encrypted with the proper key. |
| 49 bool EntryNeedsEncryption(ModelTypeSet encrypted_types, | 48 bool EntryNeedsEncryption(ModelTypeSet encrypted_types, |
| 50 const Entry& entry); | 49 const Entry& entry); |
| 51 | 50 |
| 52 // Same as EntryNeedsEncryption, but looks at specifics. | 51 // Same as EntryNeedsEncryption, but looks at specifics. |
| 53 bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types, | 52 bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types, |
| 54 const sync_pb::EntitySpecifics& specifics); | 53 const sync_pb::EntitySpecifics& specifics); |
| 55 | 54 |
| 56 // Verifies all data of type |type| is encrypted appropriately. | 55 // Verifies all data of type |type| is encrypted appropriately. |
| 57 bool VerifyDataTypeEncryptionForTest( | 56 bool VerifyDataTypeEncryptionForTest( |
| 58 BaseTransaction* const trans, | 57 BaseTransaction* const trans, |
| 59 Cryptographer* cryptographer, | |
| 60 ModelType type, | 58 ModelType type, |
| 61 bool is_encrypted) WARN_UNUSED_RESULT; | 59 bool is_encrypted) WARN_UNUSED_RESULT; |
| 62 | 60 |
| 63 // Stores |new_specifics| into |entry|, encrypting if necessary. | 61 // Stores |new_specifics| into |entry|, encrypting if necessary. |
| 64 // Returns false if an error encrypting occurred (does not modify |entry|). | 62 // Returns false if an error encrypting occurred (does not modify |entry|). |
| 65 // Note: gracefully handles new_specifics aliasing with entry->Get(SPECIFICS). | 63 // Note: gracefully handles new_specifics aliasing with entry->Get(SPECIFICS). |
| 66 bool UpdateEntryWithEncryption( | 64 bool UpdateEntryWithEncryption( |
| 67 Cryptographer* cryptographer, | 65 BaseTransaction* const trans, |
| 68 const sync_pb::EntitySpecifics& new_specifics, | 66 const sync_pb::EntitySpecifics& new_specifics, |
| 69 MutableEntry* entry); | 67 MutableEntry* entry); |
| 70 | 68 |
| 71 // Updates |nigori| to match the encryption state specified by |encrypted_types| | 69 // Updates |nigori| to match the encryption state specified by |encrypted_types| |
| 72 // and |encrypt_everything|. | 70 // and |encrypt_everything|. |
| 73 void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, | 71 void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, |
| 74 bool encrypt_everything, | 72 bool encrypt_everything, |
| 75 sync_pb::NigoriSpecifics* nigori); | 73 sync_pb::NigoriSpecifics* nigori); |
| 76 | 74 |
| 77 // Extracts the set of encrypted types from a nigori node. | 75 // Extracts the set of encrypted types from a nigori node. |
| 78 ModelTypeSet GetEncryptedTypesFromNigori( | 76 ModelTypeSet GetEncryptedTypesFromNigori( |
| 79 const sync_pb::NigoriSpecifics& nigori); | 77 const sync_pb::NigoriSpecifics& nigori); |
| 80 | 78 |
| 81 } // namespace syncable | 79 } // namespace syncable |
| 82 } // namespace syncer | 80 } // namespace syncer |
| 83 | 81 |
| 84 #endif // SYNC_SYNCABLE_NIGORI_UTIL_H_ | 82 #endif // SYNC_SYNCABLE_NIGORI_UTIL_H_ |
| OLD | NEW |