| 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 "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 char result[kSaltSize]; | 40 char result[kSaltSize]; |
| 41 crypto::RandBytes(&result, sizeof(result)); | 41 crypto::RandBytes(&result, sizeof(result)); |
| 42 return base::ToLowerASCII( | 42 return base::ToLowerASCII( |
| 43 base::HexEncode(reinterpret_cast<const void*>(result), sizeof(result))); | 43 base::HexEncode(reinterpret_cast<const void*>(result), sizeof(result))); |
| 44 } | 44 } |
| 45 | 45 |
| 46 std::string BuildRawHMACKey() { | 46 std::string BuildRawHMACKey() { |
| 47 std::unique_ptr<crypto::SymmetricKey> key( | 47 std::unique_ptr<crypto::SymmetricKey> key( |
| 48 crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, | 48 crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, |
| 49 kHMACKeySizeInBits)); | 49 kHMACKeySizeInBits)); |
| 50 std::string raw_result, result; | 50 std::string result; |
| 51 key->GetRawKey(&raw_result); | 51 base::Base64Encode(key->key(), &result); |
| 52 base::Base64Encode(raw_result, &result); | |
| 53 return result; | 52 return result; |
| 54 } | 53 } |
| 55 | 54 |
| 56 base::DictionaryValue* LoadPasswordData(base::FilePath profile_dir) { | 55 base::DictionaryValue* LoadPasswordData(base::FilePath profile_dir) { |
| 57 JSONFileValueDeserializer deserializer( | 56 JSONFileValueDeserializer deserializer( |
| 58 profile_dir.Append(kPasswordUpdateFile)); | 57 profile_dir.Append(kPasswordUpdateFile)); |
| 59 std::string error_message; | 58 std::string error_message; |
| 60 int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; | 59 int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; |
| 61 std::unique_ptr<base::Value> value = | 60 std::unique_ptr<base::Value> value = |
| 62 deserializer.Deserialize(&error_code, &error_message); | 61 deserializer.Deserialize(&error_code, &error_message); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 LOG(FATAL) << "HMAC::Sign failed"; | 317 LOG(FATAL) << "HMAC::Sign failed"; |
| 319 | 318 |
| 320 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes)); | 319 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes)); |
| 321 | 320 |
| 322 std::string result; | 321 std::string result; |
| 323 base::Base64Encode(raw_result, &result); | 322 base::Base64Encode(raw_result, &result); |
| 324 return result; | 323 return result; |
| 325 } | 324 } |
| 326 | 325 |
| 327 } // namespace chromeos | 326 } // namespace chromeos |
| OLD | NEW |