| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |