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/util/cryptographer.h" | 5 #include "sync/util/cryptographer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 if (!Decrypt(encrypted_bag, &bag)) { | 317 if (!Decrypt(encrypted_bag, &bag)) { |
318 LOG(ERROR) << "Failed to decrypt keybag for stale check. " | 318 LOG(ERROR) << "Failed to decrypt keybag for stale check. " |
319 << "Assuming keybag is corrupted."; | 319 << "Assuming keybag is corrupted."; |
320 return true; | 320 return true; |
321 } | 321 } |
322 if (static_cast<size_t>(bag.key_size()) < nigoris_.size()) | 322 if (static_cast<size_t>(bag.key_size()) < nigoris_.size()) |
323 return true; | 323 return true; |
324 return false; | 324 return false; |
325 } | 325 } |
326 | 326 |
| 327 std::string Cryptographer::GetDefaultKeyName() const { |
| 328 return default_nigori_name_; |
| 329 } |
| 330 |
327 std::string Cryptographer::GetDefaultNigoriKey() const { | 331 std::string Cryptographer::GetDefaultNigoriKey() const { |
328 if (!is_initialized()) | 332 if (!is_initialized()) |
329 return std::string(); | 333 return std::string(); |
330 NigoriMap::const_iterator iter = nigoris_.find(default_nigori_name_); | 334 NigoriMap::const_iterator iter = nigoris_.find(default_nigori_name_); |
331 if (iter == nigoris_.end()) | 335 if (iter == nigoris_.end()) |
332 return std::string(); | 336 return std::string(); |
333 sync_pb::NigoriKey key; | 337 sync_pb::NigoriKey key; |
334 if (!iter->second->ExportKeys(key.mutable_user_key(), | 338 if (!iter->second->ExportKeys(key.mutable_user_key(), |
335 key.mutable_encryption_key(), | 339 key.mutable_encryption_key(), |
336 key.mutable_mac_key())) | 340 key.mutable_mac_key())) |
(...skipping 15 matching lines...) Expand all Loading... |
352 NOTREACHED(); | 356 NOTREACHED(); |
353 return false; | 357 return false; |
354 } | 358 } |
355 | 359 |
356 if (!AddKeyImpl(nigori.Pass(), true)) | 360 if (!AddKeyImpl(nigori.Pass(), true)) |
357 return false; | 361 return false; |
358 return true; | 362 return true; |
359 } | 363 } |
360 | 364 |
361 } // namespace syncer | 365 } // namespace syncer |
OLD | NEW |