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