diff options
author | zysxqn@google.com <zysxqn@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 00:28:46 +0000 |
---|---|---|
committer | zysxqn@google.com <zysxqn@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 00:28:46 +0000 |
commit | 5eff57ede25d7fe51c3bb964aaba2745e3fb1896 (patch) | |
tree | f8cb338f8e22ce99a77903d4214dfda581857e38 /rlz/lib/machine_id.cc | |
parent | 2be6abf3a4fb590a1b59586858d1e49ea61f0708 (diff) | |
download | chromium_src-5eff57ede25d7fe51c3bb964aaba2745e3fb1896.zip chromium_src-5eff57ede25d7fe51c3bb964aaba2745e3fb1896.tar.gz chromium_src-5eff57ede25d7fe51c3bb964aaba2745e3fb1896.tar.bz2 |
Add a regenerate button to regenerate the password in Windows.
BUG=120480
TEST=Not tested.
Review URL: https://chromiumcodereview.appspot.com/10642009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144071 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'rlz/lib/machine_id.cc')
-rw-r--r-- | rlz/lib/machine_id.cc | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/rlz/lib/machine_id.cc b/rlz/lib/machine_id.cc deleted file mode 100644 index b8c10f0..0000000 --- a/rlz/lib/machine_id.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "rlz/lib/machine_id.h" - -#include "base/sha1.h" -#include "rlz/lib/assert.h" -#include "rlz/lib/crc8.h" -#include "rlz/lib/string_utils.h" - -namespace rlz_lib { - -bool GetMachineId(std::string* machine_id) { - if (!machine_id) - return false; - - static std::string calculated_id; - static bool calculated = false; - if (calculated) { - *machine_id = calculated_id; - return true; - } - - string16 sid_string; - int volume_id; - if (!GetRawMachineId(&sid_string, &volume_id)) - return false; - - if (!testing::GetMachineIdImpl(sid_string, volume_id, machine_id)) - return false; - - calculated = true; - calculated_id = *machine_id; - return true; -} - -namespace testing { - -bool GetMachineIdImpl(const string16& sid_string, - int volume_id, - std::string* machine_id) { - machine_id->clear(); - - // The ID should be the SID hash + the Hard Drive SNo. + checksum byte. - static const int kSizeWithoutChecksum = base::kSHA1Length + sizeof(int); - std::basic_string<unsigned char> id_binary(kSizeWithoutChecksum + 1, 0); - - if (!sid_string.empty()) { - // In order to be compatible with the old version of RLZ, the hash of the - // SID must be done with all the original bytes from the unicode string. - // However, the chromebase SHA1 hash function takes only an std::string as - // input, so the unicode string needs to be converted to std::string - // "as is". - size_t byte_count = sid_string.size() * sizeof(string16::value_type); - const char* buffer = reinterpret_cast<const char*>(sid_string.c_str()); - std::string sid_string_buffer(buffer, byte_count); - - // Note that digest can have embedded nulls. - std::string digest(base::SHA1HashString(sid_string_buffer)); - VERIFY(digest.size() == base::kSHA1Length); - std::copy(digest.begin(), digest.end(), id_binary.begin()); - } - - // Convert from int to binary (makes big-endian). - for (size_t i = 0; i < sizeof(int); i++) { - int shift_bits = 8 * (sizeof(int) - i - 1); - id_binary[base::kSHA1Length + i] = static_cast<unsigned char>( - (volume_id >> shift_bits) & 0xFF); - } - - // Append the checksum byte. - if (!sid_string.empty() || (0 != volume_id)) - rlz_lib::Crc8::Generate(id_binary.c_str(), - kSizeWithoutChecksum, - &id_binary[kSizeWithoutChecksum]); - - return rlz_lib::BytesToString( - id_binary.c_str(), kSizeWithoutChecksum + 1, machine_id); -} - -} // namespace testing - -} // namespace rlz_lib |