| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 std::string unencrypted_token = GetDefaultNigoriKey(); | 254 std::string unencrypted_token = GetDefaultNigoriKey(); |
| 255 if (unencrypted_token.empty()) | 255 if (unencrypted_token.empty()) |
| 256 return false; | 256 return false; |
| 257 | 257 |
| 258 std::string encrypted_token; | 258 std::string encrypted_token; |
| 259 if (!encryptor_->EncryptString(unencrypted_token, &encrypted_token)) { | 259 if (!encryptor_->EncryptString(unencrypted_token, &encrypted_token)) { |
| 260 NOTREACHED(); | 260 NOTREACHED(); |
| 261 return false; | 261 return false; |
| 262 } | 262 } |
| 263 | 263 |
| 264 if (!base::Base64Encode(encrypted_token, token)) { | 264 base::Base64Encode(encrypted_token, token); |
| 265 NOTREACHED(); | 265 |
| 266 return false; | |
| 267 } | |
| 268 return true; | 266 return true; |
| 269 } | 267 } |
| 270 | 268 |
| 271 std::string Cryptographer::UnpackBootstrapToken( | 269 std::string Cryptographer::UnpackBootstrapToken( |
| 272 const std::string& token) const { | 270 const std::string& token) const { |
| 273 if (token.empty()) | 271 if (token.empty()) |
| 274 return std::string(); | 272 return std::string(); |
| 275 | 273 |
| 276 std::string encrypted_data; | 274 std::string encrypted_data; |
| 277 if (!base::Base64Decode(token, &encrypted_data)) { | 275 if (!base::Base64Decode(token, &encrypted_data)) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 NOTREACHED(); | 352 NOTREACHED(); |
| 355 return false; | 353 return false; |
| 356 } | 354 } |
| 357 | 355 |
| 358 if (!AddKeyImpl(nigori.Pass(), true)) | 356 if (!AddKeyImpl(nigori.Pass(), true)) |
| 359 return false; | 357 return false; |
| 360 return true; | 358 return true; |
| 361 } | 359 } |
| 362 | 360 |
| 363 } // namespace syncer | 361 } // namespace syncer |
| OLD | NEW |