| 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 #include "sync/internal_api/syncapi_internal.h" | 5 #include "sync/internal_api/syncapi_internal.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "sync/protocol/password_specifics.pb.h" | 8 #include "sync/protocol/password_specifics.pb.h" |
| 9 #include "sync/protocol/sync.pb.h" | 9 #include "sync/protocol/sync.pb.h" |
| 10 #include "sync/util/cryptographer.h" | 10 #include "sync/util/cryptographer.h" |
| 11 | 11 |
| 12 using syncer::Cryptographer; | |
| 13 | |
| 14 namespace syncer { | 12 namespace syncer { |
| 15 | 13 |
| 16 sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics( | 14 sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics( |
| 17 const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto) { | 15 const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto) { |
| 18 if (!specifics.has_password()) | 16 if (!specifics.has_password()) |
| 19 return NULL; | 17 return NULL; |
| 20 const sync_pb::PasswordSpecifics& password_specifics = specifics.password(); | 18 const sync_pb::PasswordSpecifics& password_specifics = specifics.password(); |
| 21 if (!password_specifics.has_encrypted()) | 19 if (!password_specifics.has_encrypted()) |
| 22 return NULL; | 20 return NULL; |
| 23 const sync_pb::EncryptedData& encrypted = password_specifics.encrypted(); | 21 const sync_pb::EncryptedData& encrypted = password_specifics.encrypted(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 bool IsNameServerIllegalAfterTrimming(const std::string& name) { | 45 bool IsNameServerIllegalAfterTrimming(const std::string& name) { |
| 48 size_t untrimmed_count = name.find_last_not_of(' ') + 1; | 46 size_t untrimmed_count = name.find_last_not_of(' ') + 1; |
| 49 for (size_t i = 0; i < arraysize(kForbiddenServerNames); ++i) { | 47 for (size_t i = 0; i < arraysize(kForbiddenServerNames); ++i) { |
| 50 if (name.compare(0, untrimmed_count, kForbiddenServerNames[i]) == 0) | 48 if (name.compare(0, untrimmed_count, kForbiddenServerNames[i]) == 0) |
| 51 return true; | 49 return true; |
| 52 } | 50 } |
| 53 return false; | 51 return false; |
| 54 } | 52 } |
| 55 | 53 |
| 56 // Compare the values of two EntitySpecifics, accounting for encryption. | 54 // Compare the values of two EntitySpecifics, accounting for encryption. |
| 57 bool AreSpecificsEqual(const syncer::Cryptographer* cryptographer, | 55 bool AreSpecificsEqual(const Cryptographer* cryptographer, |
| 58 const sync_pb::EntitySpecifics& left, | 56 const sync_pb::EntitySpecifics& left, |
| 59 const sync_pb::EntitySpecifics& right) { | 57 const sync_pb::EntitySpecifics& right) { |
| 60 // Note that we can't compare encrypted strings directly as they are seeded | 58 // Note that we can't compare encrypted strings directly as they are seeded |
| 61 // with a random value. | 59 // with a random value. |
| 62 std::string left_plaintext, right_plaintext; | 60 std::string left_plaintext, right_plaintext; |
| 63 if (left.has_encrypted()) { | 61 if (left.has_encrypted()) { |
| 64 if (!cryptographer->CanDecrypt(left.encrypted())) { | 62 if (!cryptographer->CanDecrypt(left.encrypted())) { |
| 65 NOTREACHED() << "Attempting to compare undecryptable data."; | 63 NOTREACHED() << "Attempting to compare undecryptable data."; |
| 66 return false; | 64 return false; |
| 67 } | 65 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 78 } else { | 76 } else { |
| 79 right_plaintext = right.SerializeAsString(); | 77 right_plaintext = right.SerializeAsString(); |
| 80 } | 78 } |
| 81 if (left_plaintext == right_plaintext) { | 79 if (left_plaintext == right_plaintext) { |
| 82 return true; | 80 return true; |
| 83 } | 81 } |
| 84 return false; | 82 return false; |
| 85 } | 83 } |
| 86 | 84 |
| 87 } // namespace syncer | 85 } // namespace syncer |
| OLD | NEW |