Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: chrome/browser/chromeos/settings/token_encryptor.cc

Issue 1279123004: Replace ToLower calls to the new format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/settings/token_encryptor.h" 5 #include "chrome/browser/chromeos/settings/token_encryptor.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return std::string(); 81 return std::string();
82 } 82 }
83 std::string nonce = salt.substr(0, kNonceSize); 83 std::string nonce = salt.substr(0, kNonceSize);
84 std::string encoded_token; 84 std::string encoded_token;
85 CHECK(encryptor.SetCounter(nonce)); 85 CHECK(encryptor.SetCounter(nonce));
86 if (!encryptor.Encrypt(token, &encoded_token)) { 86 if (!encryptor.Encrypt(token, &encoded_token)) {
87 LOG(WARNING) << "Failed to encrypt token."; 87 LOG(WARNING) << "Failed to encrypt token.";
88 return std::string(); 88 return std::string();
89 } 89 }
90 90
91 return base::StringToLowerASCII(base::HexEncode( 91 return base::ToLowerASCII(
92 reinterpret_cast<const void*>(encoded_token.data()), 92 base::HexEncode(reinterpret_cast<const void*>(encoded_token.data()),
93 encoded_token.size())); 93 encoded_token.size()));
94 } 94 }
95 95
96 std::string CryptohomeTokenEncryptor::DecryptTokenWithKey( 96 std::string CryptohomeTokenEncryptor::DecryptTokenWithKey(
97 crypto::SymmetricKey* key, 97 crypto::SymmetricKey* key,
98 const std::string& salt, 98 const std::string& salt,
99 const std::string& encrypted_token_hex) { 99 const std::string& encrypted_token_hex) {
100 std::vector<uint8> encrypted_token_bytes; 100 std::vector<uint8> encrypted_token_bytes;
101 if (!base::HexStringToBytes(encrypted_token_hex, &encrypted_token_bytes)) { 101 if (!base::HexStringToBytes(encrypted_token_hex, &encrypted_token_bytes)) {
102 LOG(WARNING) << "Corrupt encrypted token found."; 102 LOG(WARNING) << "Corrupt encrypted token found.";
103 return std::string(); 103 return std::string();
(...skipping 12 matching lines...) Expand all
116 std::string token; 116 std::string token;
117 CHECK(encryptor.SetCounter(nonce)); 117 CHECK(encryptor.SetCounter(nonce));
118 if (!encryptor.Decrypt(encrypted_token, &token)) { 118 if (!encryptor.Decrypt(encrypted_token, &token)) {
119 LOG(WARNING) << "Failed to decrypt token."; 119 LOG(WARNING) << "Failed to decrypt token.";
120 return std::string(); 120 return std::string();
121 } 121 }
122 return token; 122 return token;
123 } 123 }
124 124
125 } // namespace chromeos 125 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698