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

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

Issue 1547093002: Switch to standard integer types in chrome/browser/chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 <stddef.h>
8 #include <stdint.h>
9
7 #include <vector> 10 #include <vector>
8 11
9 #include "base/logging.h" 12 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
12 #include "base/sys_info.h" 15 #include "base/sys_info.h"
13 #include "chromeos/cryptohome/system_salt_getter.h" 16 #include "chromeos/cryptohome/system_salt_getter.h"
14 #include "crypto/encryptor.h" 17 #include "crypto/encryptor.h"
15 #include "crypto/nss_util.h" 18 #include "crypto/nss_util.h"
16 #include "crypto/sha2.h" 19 #include "crypto/sha2.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 return base::ToLowerASCII( 94 return base::ToLowerASCII(
92 base::HexEncode(reinterpret_cast<const void*>(encoded_token.data()), 95 base::HexEncode(reinterpret_cast<const void*>(encoded_token.data()),
93 encoded_token.size())); 96 encoded_token.size()));
94 } 97 }
95 98
96 std::string CryptohomeTokenEncryptor::DecryptTokenWithKey( 99 std::string CryptohomeTokenEncryptor::DecryptTokenWithKey(
97 crypto::SymmetricKey* key, 100 crypto::SymmetricKey* key,
98 const std::string& salt, 101 const std::string& salt,
99 const std::string& encrypted_token_hex) { 102 const std::string& encrypted_token_hex) {
100 std::vector<uint8> encrypted_token_bytes; 103 std::vector<uint8_t> encrypted_token_bytes;
101 if (!base::HexStringToBytes(encrypted_token_hex, &encrypted_token_bytes)) { 104 if (!base::HexStringToBytes(encrypted_token_hex, &encrypted_token_bytes)) {
102 LOG(WARNING) << "Corrupt encrypted token found."; 105 LOG(WARNING) << "Corrupt encrypted token found.";
103 return std::string(); 106 return std::string();
104 } 107 }
105 108
106 std::string encrypted_token( 109 std::string encrypted_token(
107 reinterpret_cast<char*>(encrypted_token_bytes.data()), 110 reinterpret_cast<char*>(encrypted_token_bytes.data()),
108 encrypted_token_bytes.size()); 111 encrypted_token_bytes.size());
109 crypto::Encryptor encryptor; 112 crypto::Encryptor encryptor;
110 if (!encryptor.Init(key, crypto::Encryptor::CTR, std::string())) { 113 if (!encryptor.Init(key, crypto::Encryptor::CTR, std::string())) {
111 LOG(WARNING) << "Failed to initialize Encryptor."; 114 LOG(WARNING) << "Failed to initialize Encryptor.";
112 return std::string(); 115 return std::string();
113 } 116 }
114 117
115 std::string nonce = salt.substr(0, kNonceSize); 118 std::string nonce = salt.substr(0, kNonceSize);
116 std::string token; 119 std::string token;
117 CHECK(encryptor.SetCounter(nonce)); 120 CHECK(encryptor.SetCounter(nonce));
118 if (!encryptor.Decrypt(encrypted_token, &token)) { 121 if (!encryptor.Decrypt(encrypted_token, &token)) {
119 LOG(WARNING) << "Failed to decrypt token."; 122 LOG(WARNING) << "Failed to decrypt token.";
120 return std::string(); 123 return std::string();
121 } 124 }
122 return token; 125 return token;
123 } 126 }
124 127
125 } // namespace chromeos 128 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/token_encryptor.h ('k') | chrome/browser/chromeos/sim_dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698