OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Various utility methods for nigori-based multi-type encryption. | |
6 | |
7 #ifndef CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_ | |
8 #define CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_ | |
9 #pragma once | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "chrome/browser/sync/syncable/model_type.h" | |
13 #include "sync/protocol/nigori_specifics.pb.h" | |
14 | |
15 namespace browser_sync { | |
16 class Cryptographer; | |
17 } | |
18 | |
19 namespace sync_pb { | |
20 class EntitySpecifics; | |
21 } | |
22 | |
23 namespace syncable { | |
24 | |
25 const char kEncryptedString[] = "encrypted"; | |
26 | |
27 class BaseTransaction; | |
28 class Entry; | |
29 class WriteTransaction; | |
30 | |
31 // Check if our unsyced changes are encrypted if they need to be based on | |
32 // |encrypted_types|. | |
33 // Returns: true if all unsynced data that should be encrypted is. | |
34 // false if some unsynced changes need to be encrypted. | |
35 // This method is similar to ProcessUnsyncedChangesForEncryption but does not | |
36 // modify the data and does not care if data is unnecessarily encrypted. | |
37 bool VerifyUnsyncedChangesAreEncrypted( | |
38 BaseTransaction* const trans, | |
39 ModelTypeSet encrypted_types); | |
40 | |
41 // Processes all unsynced changes and ensures they are appropriately encrypted | |
42 // or unencrypted, based on |encrypted_types|. | |
43 bool ProcessUnsyncedChangesForEncryption( | |
44 WriteTransaction* const trans, | |
45 browser_sync::Cryptographer* cryptographer); | |
46 | |
47 // Returns true if the entry requires encryption but is not encrypted, false | |
48 // otherwise. Note: this does not check that already encrypted entries are | |
49 // encrypted with the proper key. | |
50 bool EntryNeedsEncryption(ModelTypeSet encrypted_types, | |
51 const Entry& entry); | |
52 | |
53 // Same as EntryNeedsEncryption, but looks at specifics. | |
54 bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types, | |
55 const sync_pb::EntitySpecifics& specifics); | |
56 | |
57 // Verifies all data of type |type| is encrypted appropriately. | |
58 bool VerifyDataTypeEncryptionForTest( | |
59 BaseTransaction* const trans, | |
60 browser_sync::Cryptographer* cryptographer, | |
61 ModelType type, | |
62 bool is_encrypted) WARN_UNUSED_RESULT; | |
63 | |
64 } // namespace syncable | |
65 | |
66 #endif // CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_ | |
OLD | NEW |