| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <CoreFoundation/CoreFoundation.h> | 5 #include <CoreFoundation/CoreFoundation.h> |
| 6 #include <IOKit/IOKitLib.h> | 6 #include <IOKit/IOKitLib.h> |
| 7 #include <IOKit/network/IOEthernetController.h> | 7 #include <IOKit/network/IOEthernetController.h> |
| 8 #include <IOKit/network/IOEthernetInterface.h> | 8 #include <IOKit/network/IOEthernetInterface.h> |
| 9 #include <IOKit/network/IONetworkInterface.h> | 9 #include <IOKit/network/IONetworkInterface.h> |
| 10 | 10 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 return serial_number_cfstring; | 116 return serial_number_cfstring; |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace | 119 } // namespace |
| 120 | 120 |
| 121 bool GetRawMachineId(base::string16* data, int* more_data) { | 121 bool GetRawMachineId(base::string16* data, int* more_data) { |
| 122 uint8_t mac_address[kIOEthernetAddressSize]; | 122 uint8_t mac_address[kIOEthernetAddressSize]; |
| 123 | 123 |
| 124 data->clear(); | 124 data->clear(); |
| 125 if (GetMacAddress(mac_address, sizeof(mac_address))) { | 125 if (GetMacAddress(mac_address, sizeof(mac_address))) { |
| 126 *data += ASCIIToUTF16(base::StringPrintf("mac:%02x%02x%02x%02x%02x%02x", | 126 *data += base::ASCIIToUTF16( |
| 127 mac_address[0], mac_address[1], mac_address[2], | 127 base::StringPrintf("mac:%02x%02x%02x%02x%02x%02x", |
| 128 mac_address[3], mac_address[4], mac_address[5])); | 128 mac_address[0], mac_address[1], mac_address[2], |
| 129 mac_address[3], mac_address[4], mac_address[5])); |
| 129 } | 130 } |
| 130 | 131 |
| 131 // A MAC address is enough to uniquely identify a machine, but it's only 6 | 132 // A MAC address is enough to uniquely identify a machine, but it's only 6 |
| 132 // bytes, 3 of which are manufacturer-determined. To make brute-forcing the | 133 // bytes, 3 of which are manufacturer-determined. To make brute-forcing the |
| 133 // SHA1 of this harder, also append the system's serial number. | 134 // SHA1 of this harder, also append the system's serial number. |
| 134 CFStringRef serial = CopySerialNumber(); | 135 CFStringRef serial = CopySerialNumber(); |
| 135 if (serial) { | 136 if (serial) { |
| 136 if (!data->empty()) | 137 if (!data->empty()) |
| 137 *data += UTF8ToUTF16(" "); | 138 *data += base::UTF8ToUTF16(" "); |
| 138 *data += UTF8ToUTF16("serial:") + base::SysCFStringRefToUTF16(serial); | 139 *data += base::UTF8ToUTF16("serial:") + base::SysCFStringRefToUTF16(serial); |
| 139 CFRelease(serial); | 140 CFRelease(serial); |
| 140 } | 141 } |
| 141 | 142 |
| 142 // On windows, this is set to the volume id. Since it's not scrambled before | 143 // On windows, this is set to the volume id. Since it's not scrambled before |
| 143 // being sent, just set it to 1. | 144 // being sent, just set it to 1. |
| 144 *more_data = 1; | 145 *more_data = 1; |
| 145 return true; | 146 return true; |
| 146 } | 147 } |
| 147 | 148 |
| 148 } // namespace rlz_lib | 149 } // namespace rlz_lib |
| OLD | NEW |