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