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

Side by Side Diff: chromeos/login/auth/key.cc

Issue 515153002: Add new Chrome OS key type: Salted SHA256 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@d_2_367847_add_get_key_data_ex_call
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chromeos/login/auth/key.h ('k') | chromeos/login/auth/key_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
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));
98 std::string raw_secret; 98 std::string raw_secret;
99 key->GetRawKey(&raw_secret); 99 key->GetRawKey(&raw_secret);
100 base::Base64Encode(raw_secret, &secret_); 100 base::Base64Encode(raw_secret, &secret_);
101 break; 101 break;
102 } 102 }
103 case KEY_TYPE_SALTED_SHA256:
104 base::Base64Encode(crypto::SHA256HashString(salt + secret_), &secret_);
105 break;
106
103 default: 107 default:
104 // The resulting key will be sent to cryptohomed. It should always be 108 // The resulting key will be sent to cryptohomed. It should always be
105 // 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.
106 CHECK(false); 110 CHECK(false);
107 return; 111 return;
108 } 112 }
109 113
110 key_type_ = target_key_type; 114 key_type_ = target_key_type;
111 salt_ = salt; 115 salt_ = salt;
112 } 116 }
113 117
114 } // namespace chromeos 118 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/auth/key.h ('k') | chromeos/login/auth/key_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698