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