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

Side by Side Diff: chromeos/login/auth/key.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromeos/login/auth/key.h" 5 #include "chromeos/login/auth/key.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 switch (target_key_type) { 77 switch (target_key_type) {
78 case KEY_TYPE_SALTED_SHA256_TOP_HALF: { 78 case KEY_TYPE_SALTED_SHA256_TOP_HALF: {
79 // TODO(stevenjb/nkostylev): Handle empty salt gracefully. 79 // TODO(stevenjb/nkostylev): Handle empty salt gracefully.
80 CHECK(!salt.empty()); 80 CHECK(!salt.empty());
81 char hash[crypto::kSHA256Length]; 81 char hash[crypto::kSHA256Length];
82 crypto::SHA256HashString(salt + secret_, &hash, sizeof(hash)); 82 crypto::SHA256HashString(salt + secret_, &hash, sizeof(hash));
83 83
84 // Keep only the first half of the hash for 'weak' hashing so that the 84 // Keep only the first half of the hash for 'weak' hashing so that the
85 // plain text secret cannot be reconstructed even if the hashing is 85 // plain text secret cannot be reconstructed even if the hashing is
86 // reversed. 86 // reversed.
87 secret_ = base::StringToLowerASCII(base::HexEncode( 87 secret_ = base::ToLowerASCII(base::HexEncode(
88 reinterpret_cast<const void*>(hash), sizeof(hash) / 2)); 88 reinterpret_cast<const void*>(hash), sizeof(hash) / 2));
89 break; 89 break;
90 } 90 }
91 case KEY_TYPE_SALTED_PBKDF2_AES256_1234: { 91 case KEY_TYPE_SALTED_PBKDF2_AES256_1234: {
92 scoped_ptr<crypto::SymmetricKey> key( 92 scoped_ptr<crypto::SymmetricKey> key(
93 crypto::SymmetricKey::DeriveKeyFromPassword(crypto::SymmetricKey::AES, 93 crypto::SymmetricKey::DeriveKeyFromPassword(crypto::SymmetricKey::AES,
94 secret_, 94 secret_,
95 salt, 95 salt,
96 kNumIterations, 96 kNumIterations,
97 kKeySizeInBits)); 97 kKeySizeInBits));
(...skipping 11 matching lines...) Expand all
109 // hashed. If hashing fails, crash instead of sending a plain-text key. 109 // hashed. If hashing fails, crash instead of sending a plain-text key.
110 CHECK(false); 110 CHECK(false);
111 return; 111 return;
112 } 112 }
113 113
114 key_type_ = target_key_type; 114 key_type_ = target_key_type;
115 salt_ = salt; 115 salt_ = salt;
116 } 116 }
117 117
118 } // namespace chromeos 118 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/cryptohome/system_salt_getter.cc ('k') | cloud_print/gcp20/prototype/print_job_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698