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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 base::mac::CFCast<CFStringRef>(serial_number); | 111 base::mac::CFCast<CFStringRef>(serial_number); |
112 if (!serial_number_cfstring) | 112 if (!serial_number_cfstring) |
113 return NULL; | 113 return NULL; |
114 | 114 |
115 ignore_result(serial_number.release()); | 115 ignore_result(serial_number.release()); |
116 return serial_number_cfstring; | 116 return serial_number_cfstring; |
117 } | 117 } |
118 | 118 |
119 } // namespace | 119 } // namespace |
120 | 120 |
121 bool GetRawMachineId(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 += ASCIIToUTF16(base::StringPrintf("mac:%02x%02x%02x%02x%02x%02x", |
127 mac_address[0], mac_address[1], mac_address[2], | 127 mac_address[0], mac_address[1], mac_address[2], |
128 mac_address[3], mac_address[4], mac_address[5])); | 128 mac_address[3], mac_address[4], mac_address[5])); |
129 } | 129 } |
130 | 130 |
131 // A MAC address is enough to uniquely identify a machine, but it's only 6 | 131 // 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 | 132 // bytes, 3 of which are manufacturer-determined. To make brute-forcing the |
133 // SHA1 of this harder, also append the system's serial number. | 133 // SHA1 of this harder, also append the system's serial number. |
134 CFStringRef serial = CopySerialNumber(); | 134 CFStringRef serial = CopySerialNumber(); |
135 if (serial) { | 135 if (serial) { |
136 if (!data->empty()) | 136 if (!data->empty()) |
137 *data += UTF8ToUTF16(" "); | 137 *data += UTF8ToUTF16(" "); |
138 *data += UTF8ToUTF16("serial:") + base::SysCFStringRefToUTF16(serial); | 138 *data += UTF8ToUTF16("serial:") + base::SysCFStringRefToUTF16(serial); |
139 CFRelease(serial); | 139 CFRelease(serial); |
140 } | 140 } |
141 | 141 |
142 // On windows, this is set to the volume id. Since it's not scrambled before | 142 // On windows, this is set to the volume id. Since it's not scrambled before |
143 // being sent, just set it to 1. | 143 // being sent, just set it to 1. |
144 *more_data = 1; | 144 *more_data = 1; |
145 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
148 } // namespace rlz_lib | 148 } // namespace rlz_lib |
OLD | NEW |