summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpneubeck <pneubeck@chromium.org>2015-01-13 09:14:27 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-13 17:16:01 +0000
commit63f02baf9abbb2f28e2f1676ed10310fcf22eeb2 (patch)
treefee99e352b89336b66261f25ff017017d12d6cb0
parentd8c8e56321d4c9135ad7d5015db99fbb0e2ec4c2 (diff)
downloadchromium_src-63f02baf9abbb2f28e2f1676ed10310fcf22eeb2.zip
chromium_src-63f02baf9abbb2f28e2f1676ed10310fcf22eeb2.tar.gz
chromium_src-63f02baf9abbb2f28e2f1676ed10310fcf22eeb2.tar.bz2
ONC: Use HexSSID instead of SSID.
- Comparison of a network policy with network will use HexSSID now. - Translation from ONC to Shill now copies the HexSSID instead of translating SSID. - Fix ONC validation of HexSSID/SSID to be case insensitive. - When setting an ONC: SSID will be ignored if HexSSID is present - Reading network properties reports a HexSSID in ONC. BUG=432546 Review URL: https://codereview.chromium.org/823633004 Cr-Commit-Position: refs/heads/master@{#311281}
-rw-r--r--chrome/browser/chromeos/policy/network_configuration_updater_unittest.cc4
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc2
-rw-r--r--chrome/test/data/extensions/api_test/networking/test.js7
-rw-r--r--chromeos/network/auto_connect_handler_unittest.cc4
-rw-r--r--chromeos/network/onc/onc_translation_tables.cc3
-rw-r--r--chromeos/network/onc/onc_translator_onc_to_shill.cc5
-rw-r--r--chromeos/network/onc/onc_translator_shill_to_onc.cc9
-rw-r--r--chromeos/network/onc/onc_translator_unittest.cc5
-rw-r--r--chromeos/network/onc/onc_utils.cc15
-rw-r--r--chromeos/network/onc/onc_validator.cc64
-rw-r--r--chromeos/network/onc/onc_validator.h2
-rw-r--r--chromeos/network/onc/onc_validator_unittest.cc16
-rw-r--r--chromeos/network/policy_util.cc6
-rw-r--r--chromeos/network/shill_property_util.h2
-rw-r--r--chromeos/test/data/network/invalid_settings_with_repairs.json37
-rw-r--r--chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc3
-rw-r--r--chromeos/test/data/network/policy/policy_wifi1.onc1
-rw-r--r--chromeos/test/data/network/repaired_toplevel_partially_invalid.onc10
-rw-r--r--chromeos/test/data/network/shill_wifi_clientcert.json2
-rw-r--r--chromeos/test/data/network/shill_wifi_clientref.json2
-rw-r--r--chromeos/test/data/network/shill_wifi_non_utf8_ssid.json11
-rw-r--r--chromeos/test/data/network/toplevel_partially_invalid.onc9
-rw-r--r--chromeos/test/data/network/toplevel_wifi_ssid_and_hexssid.onc3
-rw-r--r--chromeos/test/data/network/translation_of_shill_wifi_clientcert.onc3
-rw-r--r--chromeos/test/data/network/translation_of_shill_wifi_non_utf8_ssid.onc12
-rw-r--r--chromeos/test/data/network/translation_of_shill_wifi_with_state.onc1
-rw-r--r--chromeos/test/data/network/valid_wifi_clientref.onc2
-rw-r--r--chromeos/test/data/network/valid_wifi_psk.onc2
-rw-r--r--chromeos/test/data/network/wifi_clientcert_with_cert_pems.onc2
-rw-r--r--chromeos/test/data/network/wifi_dhcp.onc2
-rw-r--r--components/onc/docs/onc_spec.html23
-rw-r--r--components/wifi/network_properties.cc3
-rw-r--r--components/wifi/network_properties.h1
33 files changed, 196 insertions, 77 deletions
diff --git a/chrome/browser/chromeos/policy/network_configuration_updater_unittest.cc b/chrome/browser/chromeos/policy/network_configuration_updater_unittest.cc
index 18650cd..6291c81 100644
--- a/chrome/browser/chromeos/policy/network_configuration_updater_unittest.cc
+++ b/chrome/browser/chromeos/policy/network_configuration_updater_unittest.cc
@@ -150,7 +150,7 @@ const char kFakeONC[] =
" \"Type\": \"WiFi\","
" \"Name\": \"My WiFi Network\","
" \"WiFi\": {"
- " \"SSID\": \"ssid-none\","
+ " \"HexSSID\": \"737369642D6E6F6E65\"," // "ssid-none"
" \"Security\": \"None\" }"
" }"
" ],"
@@ -160,7 +160,7 @@ const char kFakeONC[] =
" \"Certificates\": ["
" { \"GUID\": \"{f998f760-272b-6939-4c2beffe428697ac}\","
" \"PKCS12\": \"abc\","
- " \"Type\": \"Client\" }"
+ " \"Type\": \"Client\" }"
" ],"
" \"Type\": \"UnencryptedConfiguration\""
"}";
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
index d708c2b..ac57b5d 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
@@ -448,9 +448,9 @@ IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest, GetManagedProperties) {
" \"Type\": \"WiFi\","
" \"Name\": \"My WiFi Network\","
" \"WiFi\": {"
+ " \"HexSSID\": \"77696669325F50534B\"," // "wifi2_PSK"
" \"Passphrase\": \"passphrase\","
" \"Recommended\": [ \"AutoConnect\", \"Passphrase\" ],"
- " \"SSID\": \"wifi2_PSK\","
" \"Security\": \"WPA-PSK\" }"
" }"
" ],"
diff --git a/chrome/test/data/extensions/api_test/networking/test.js b/chrome/test/data/extensions/api_test/networking/test.js
index eb08d1b..9024129 100644
--- a/chrome/test/data/extensions/api_test/networking/test.js
+++ b/chrome/test/data/extensions/api_test/networking/test.js
@@ -300,6 +300,7 @@ var availableTests = [
},
"Type": "WiFi",
"WiFi": {
+ "HexSSID": "7769666931", // "wifi1"
"Frequency": 2400,
"FrequencyList": [2400],
"SSID": "wifi1",
@@ -356,6 +357,11 @@ var availableTests = [
"Active": false,
"UserEditable": true
},
+ "HexSSID": {
+ "Active": "77696669325F50534B", // "wifi2_PSK"
+ "Effective": "UserPolicy",
+ "UserPolicy": "77696669325F50534B"
+ },
"Frequency" : 5000,
"FrequencyList" : [2400, 5000],
"Passphrase": {
@@ -366,7 +372,6 @@ var availableTests = [
"SSID": {
"Active": "wifi2_PSK",
"Effective": "UserPolicy",
- "UserPolicy": "wifi2_PSK"
},
"Security": {
"Active": "WPA-PSK",
diff --git a/chromeos/network/auto_connect_handler_unittest.cc b/chromeos/network/auto_connect_handler_unittest.cc
index e691d3f..47cf9f9 100644
--- a/chromeos/network/auto_connect_handler_unittest.cc
+++ b/chromeos/network/auto_connect_handler_unittest.cc
@@ -269,7 +269,7 @@ const char* kPolicy =
" \"Type\": \"WiFi\","
" \"WiFi\": {"
" \"Security\": \"WPA-PSK\","
- " \"SSID\": \"wifi1\","
+ " \"HexSSID\": \"7769666931\"," // "wifi1"
" \"Passphrase\": \"passphrase\""
" }"
"} ]";
@@ -280,7 +280,7 @@ const char* kPolicyCertPattern =
" \"Type\": \"WiFi\","
" \"WiFi\": {"
" \"Security\": \"WPA-EAP\","
- " \"SSID\": \"wifi1\","
+ " \"HexSSID\": \"7769666931\"," // "wifi1"
" \"EAP\": {"
" \"Outer\": \"EAP-TLS\","
" \"ClientCertType\": \"Pattern\","
diff --git a/chromeos/network/onc/onc_translation_tables.cc b/chromeos/network/onc/onc_translation_tables.cc
index 6d9ade3..0b3a07e 100644
--- a/chromeos/network/onc/onc_translation_tables.cc
+++ b/chromeos/network/onc/onc_translation_tables.cc
@@ -115,11 +115,10 @@ const FieldTranslationEntry wifi_fields[] = {
// { ::onc::wifi::kEAP, shill::kEap*},
{ ::onc::wifi::kFrequency, shill::kWifiFrequency},
{ ::onc::wifi::kFrequencyList, shill::kWifiFrequencyListProperty},
+ { ::onc::wifi::kHexSSID, shill::kWifiHexSsid},
{ ::onc::wifi::kHiddenSSID, shill::kWifiHiddenSsid},
{ ::onc::wifi::kPassphrase, shill::kPassphraseProperty},
// This field is converted during translation, see onc_translator_*.
- // { ::onc::wifi::kSSID, shill::kWifiHexSsid},
- // This field is converted during translation, see onc_translator_*.
// { ::onc::wifi::kSecurity, shill::kSecurityClassProperty },
{ ::onc::wifi::kSignalStrength, shill::kSignalStrengthProperty},
{NULL}};
diff --git a/chromeos/network/onc/onc_translator_onc_to_shill.cc b/chromeos/network/onc/onc_translator_onc_to_shill.cc
index c9d4151..9e1e53e 100644
--- a/chromeos/network/onc/onc_translator_onc_to_shill.cc
+++ b/chromeos/network/onc/onc_translator_onc_to_shill.cc
@@ -204,11 +204,6 @@ void LocalTranslator::TranslateWiFi() {
shill::kSecurityClassProperty);
}
- std::string ssid;
- onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSSID, &ssid);
- if (!ssid.empty())
- shill_property_util::SetSSID(ssid, shill_dictionary_);
-
// We currently only support managed and no adhoc networks.
shill_dictionary_->SetStringWithoutPathExpansion(shill::kModeProperty,
shill::kModeManaged);
diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc
index 1e7885f..4360d25 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -316,9 +316,10 @@ void ShillToONCTranslator::TranslateWiFiWithState() {
TranslateWithTableAndSet(shill::kSecurityClassProperty,
kWiFiSecurityTable,
::onc::wifi::kSecurity);
+ bool unknown_encoding = true;
std::string ssid = shill_property_util::GetSSIDFromProperties(
- *shill_dictionary_, NULL /* ignore unknown encoding */);
- if (!ssid.empty())
+ *shill_dictionary_, &unknown_encoding);
+ if (!unknown_encoding && !ssid.empty())
onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid);
bool link_monitor_disable;
@@ -663,8 +664,8 @@ void ShillToONCTranslator::CopyProperty(
return;
}
- onc_object_->SetWithoutPathExpansion(field_signature->onc_field_name,
- shill_value->DeepCopy());
+ onc_object_->SetWithoutPathExpansion(field_signature->onc_field_name,
+ shill_value->DeepCopy());
}
void ShillToONCTranslator::TranslateWithTableAndSet(
diff --git a/chromeos/network/onc/onc_translator_unittest.cc b/chromeos/network/onc/onc_translator_unittest.cc
index 5d4f3ce..9444614 100644
--- a/chromeos/network/onc/onc_translator_unittest.cc
+++ b/chromeos/network/onc/onc_translator_unittest.cc
@@ -4,6 +4,9 @@
#include "chromeos/network/onc/onc_translator.h"
+#include <string>
+#include <utility>
+
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "chromeos/network/onc/onc_signature.h"
@@ -97,6 +100,8 @@ INSTANTIATE_TEST_CASE_P(
"translation_of_shill_ethernet_with_ipconfig.onc"),
std::make_pair("shill_wifi_clientcert.json",
"translation_of_shill_wifi_clientcert.onc"),
+ std::make_pair("shill_wifi_non_utf8_ssid.json",
+ "translation_of_shill_wifi_non_utf8_ssid.onc"),
std::make_pair("shill_output_l2tpipsec.json",
"translation_of_shill_l2tpipsec.onc"),
std::make_pair("shill_output_openvpn.json",
diff --git a/chromeos/network/onc/onc_utils.cc b/chromeos/network/onc/onc_utils.cc
index 7b544cf..1eaee85 100644
--- a/chromeos/network/onc/onc_utils.cc
+++ b/chromeos/network/onc/onc_utils.cc
@@ -380,6 +380,16 @@ CertPEMsByGUIDMap GetServerAndCACertsByGUID(
return certs_by_guid;
}
+void FillInHexSSIDFieldsInNetworks(base::ListValue* network_configs) {
+ for (base::ListValue::iterator it = network_configs->begin();
+ it != network_configs->end(); ++it) {
+ base::DictionaryValue* network = NULL;
+ (*it)->GetAsDictionary(&network);
+ DCHECK(network);
+ FillInHexSSIDFieldsInOncObject(kNetworkConfigurationSignature, network);
+ }
+}
+
} // namespace
bool ParseAndValidateOncForImport(const std::string& onc_blob,
@@ -432,9 +442,6 @@ bool ParseAndValidateOncForImport(const std::string& onc_blob,
*toplevel_onc,
&validation_result);
- FillInHexSSIDFieldsInOncObject(kToplevelConfigurationSignature,
- toplevel_onc.get());
-
if (from_policy) {
UMA_HISTOGRAM_BOOLEAN("Enterprise.ONC.PolicyValidation",
validation_result == Validator::VALID);
@@ -460,6 +467,8 @@ bool ParseAndValidateOncForImport(const std::string& onc_blob,
base::ListValue* validated_networks = NULL;
if (toplevel_onc->GetListWithoutPathExpansion(
toplevel_config::kNetworkConfigurations, &validated_networks)) {
+ FillInHexSSIDFieldsInNetworks(validated_networks);
+
CertPEMsByGUIDMap server_and_ca_certs =
GetServerAndCACertsByGUID(*certificates);
diff --git a/chromeos/network/onc/onc_validator.cc b/chromeos/network/onc/onc_validator.cc
index a3374ee..d9c6263 100644
--- a/chromeos/network/onc/onc_validator.cc
+++ b/chromeos/network/onc/onc_validator.cc
@@ -253,7 +253,7 @@ bool Validator::ValidateRecommendedField(
for (const base::Value* entry : *recommended_list) {
std::string field_name;
if (!entry->GetAsString(&field_name)) {
- NOTREACHED(); // The types of field values are already verified.
+ NOTREACHED(); // The types of field values are already verified.
continue;
}
@@ -399,51 +399,62 @@ bool Validator::FieldExistsAndIsEmpty(const base::DictionaryValue& object,
return true;
}
-bool Validator::IsSSIDOrHexSSIDValid(const base::DictionaryValue& object) {
+bool Validator::ValidateSSIDAndHexSSID(base::DictionaryValue* object) {
// Check SSID validity.
std::string ssid_string;
- if (object.GetStringWithoutPathExpansion(::onc::wifi::kSSID, &ssid_string)) {
- if (ssid_string.size() <= 0 ||
- ssid_string.size() > kMaximumSSIDLengthInBytes) {
- LOG(ERROR) << MessageHeader() << ::onc::wifi::kSSID
- << " has an invalid length.";
- error_or_warning_found_ = true;
+ if (object->GetStringWithoutPathExpansion(::onc::wifi::kSSID, &ssid_string) &&
+ (ssid_string.size() <= 0 ||
+ ssid_string.size() > kMaximumSSIDLengthInBytes)) {
+ error_or_warning_found_ = true;
+ const std::string msg =
+ MessageHeader() + ::onc::wifi::kSSID + " has an invalid length.";
+ // If the HexSSID field is present, ignore errors in SSID because these
+ // might be caused by the usage of a non-UTF-8 encoding when the SSID
+ // field was automatically added (see FillInHexSSIDField).
+ if (object->HasKey(::onc::wifi::kHexSSID)) {
+ LOG(WARNING) << msg;
+ } else {
+ LOG(ERROR) << msg;
return false;
}
}
// Check HexSSID validity.
std::string hex_ssid_string;
- if (object.GetStringWithoutPathExpansion(::onc::wifi::kHexSSID,
- &hex_ssid_string)) {
- std::vector<uint8> bytes;
- if (!base::HexStringToBytes(hex_ssid_string, &bytes)) {
+ if (object->GetStringWithoutPathExpansion(::onc::wifi::kHexSSID,
+ &hex_ssid_string)) {
+ std::vector<uint8> decoded_ssid;
+ if (!base::HexStringToBytes(hex_ssid_string, &decoded_ssid)) {
LOG(ERROR) << MessageHeader() << "Field " << ::onc::wifi::kHexSSID
<< " is not a valid hex representation: \"" << hex_ssid_string
<< "\"";
error_or_warning_found_ = true;
return false;
}
- if (bytes.size() <= 0 || bytes.size() > kMaximumSSIDLengthInBytes) {
+ if (decoded_ssid.size() <= 0 ||
+ decoded_ssid.size() > kMaximumSSIDLengthInBytes) {
LOG(ERROR) << MessageHeader() << ::onc::wifi::kHexSSID
<< " has an invalid length.";
error_or_warning_found_ = true;
return false;
}
- }
- // If both SSID and HexSSID are set, ensure that they are consistent.
- if (ssid_string.length() > 0 && hex_ssid_string.length() > 0) {
- std::string hexified =
- base::HexEncode(ssid_string.c_str(), ssid_string.size());
- if (hexified != hex_ssid_string) {
- LOG(ERROR) << MessageHeader() << "Fields " << ::onc::wifi::kSSID
- << " and " << ::onc::wifi::kHexSSID
- << " contain inconsistent values.";
- error_or_warning_found_ = true;
- return false;
+
+ // If both SSID and HexSSID are set, check whether they are consistent, i.e.
+ // HexSSID contains the UTF-8 encoding of SSID. If not, remove the SSID
+ // field.
+ if (ssid_string.length() > 0) {
+ std::string decoded_ssid_string(
+ reinterpret_cast<const char*>(&decoded_ssid[0]), decoded_ssid.size());
+ if (ssid_string != decoded_ssid_string) {
+ LOG(WARNING) << MessageHeader() << "Fields " << ::onc::wifi::kSSID
+ << " and " << ::onc::wifi::kHexSSID
+ << " contain inconsistent values. Removing "
+ << ::onc::wifi::kSSID << ".";
+ error_or_warning_found_ = true;
+ object->RemoveWithoutPathExpansion(::onc::wifi::kSSID, nullptr);
+ }
}
}
-
return true;
}
@@ -645,8 +656,7 @@ bool Validator::ValidateWiFi(base::DictionaryValue* result) {
if (FieldExistsAndHasNoValidValue(*result, kSecurity, valid_securities))
return false;
- // Validate SSID and HexSSID fields, if present.
- if (!IsSSIDOrHexSSIDValid(*result))
+ if (!ValidateSSIDAndHexSSID(result))
return false;
bool all_required_exist = RequireField(*result, kSecurity);
diff --git a/chromeos/network/onc/onc_validator.h b/chromeos/network/onc/onc_validator.h
index 857f31e..5a5cf6a 100644
--- a/chromeos/network/onc/onc_validator.h
+++ b/chromeos/network/onc/onc_validator.h
@@ -182,7 +182,7 @@ class CHROMEOS_EXPORT Validator : public Mapper {
bool FieldExistsAndIsEmpty(const base::DictionaryValue& object,
const std::string& field_name);
- bool IsSSIDOrHexSSIDValid(const base::DictionaryValue& object);
+ bool ValidateSSIDAndHexSSID(base::DictionaryValue* object);
// Returns true if |key| is a key of |dict|. Otherwise, returns false and,
// depending on |error_on_missing_field_|, logs a message and sets
diff --git a/chromeos/network/onc/onc_validator_unittest.cc b/chromeos/network/onc/onc_validator_unittest.cc
index 4daa6a6..ad15269 100644
--- a/chromeos/network/onc/onc_validator_unittest.cc
+++ b/chromeos/network/onc/onc_validator_unittest.cc
@@ -428,6 +428,16 @@ INSTANTIATE_TEST_CASE_P(
false,
::onc::ONC_SOURCE_DEVICE_POLICY),
ExpectBothNotValid("toplevel-empty", "toplevel-empty")),
+ std::make_pair(OncParams("wifi-ssid-and-hexssid-inconsistent",
+ &kNetworkConfigurationSignature,
+ false),
+ ExpectBothNotValid("wifi-ssid-and-hexssid-repaired",
+ "wifi-ssid-and-hexssid-repaired")),
+ std::make_pair(OncParams("wifi-ssid-and-hexssid-partially-invalid",
+ &kNetworkConfigurationSignature,
+ false),
+ ExpectBothNotValid("wifi-ssid-and-hexssid-repaired",
+ "wifi-ssid-and-hexssid-repaired")),
std::make_pair(
OncParams("toplevel-with-server-and-ca-cert",
&kToplevelConfigurationSignature,
@@ -455,15 +465,15 @@ INSTANTIATE_TEST_CASE_P(
&kNetworkConfigurationSignature,
false),
ExpectBothNotValid("", "")),
- std::make_pair(OncParams("network-wifi-hexssid-invalid-length",
+ std::make_pair(OncParams("wifi-hexssid-invalid-length",
&kNetworkConfigurationSignature,
false),
ExpectBothNotValid("", "")),
- std::make_pair(OncParams("network-wifi-invalid-hexssid",
+ std::make_pair(OncParams("wifi-ssid-invalid-length",
&kNetworkConfigurationSignature,
false),
ExpectBothNotValid("", "")),
- std::make_pair(OncParams("network-wifi-ssid-and-hexssid-inconsistent",
+ std::make_pair(OncParams("wifi-invalid-hexssid",
&kNetworkConfigurationSignature,
false),
ExpectBothNotValid("", "")),
diff --git a/chromeos/network/policy_util.cc b/chromeos/network/policy_util.cc
index 1b14e7e..8ac4856 100644
--- a/chromeos/network/policy_util.cc
+++ b/chromeos/network/policy_util.cc
@@ -115,10 +115,10 @@ bool IsPolicyMatching(const base::DictionaryValue& policy,
return false;
std::string policy_ssid;
- policy_wifi->GetStringWithoutPathExpansion(::onc::wifi::kSSID,
+ policy_wifi->GetStringWithoutPathExpansion(::onc::wifi::kHexSSID,
&policy_ssid);
std::string actual_ssid;
- actual_wifi->GetStringWithoutPathExpansion(::onc::wifi::kSSID,
+ actual_wifi->GetStringWithoutPathExpansion(::onc::wifi::kHexSSID,
&actual_ssid);
return (policy_ssid == actual_ssid);
}
@@ -210,7 +210,7 @@ void ApplyGlobalAutoconnectPolicy(
std::string policy_source;
if (profile_type == NetworkProfile::TYPE_USER)
policy_source = ::onc::kAugmentationUserPolicy;
- else if(profile_type == NetworkProfile::TYPE_SHARED)
+ else if (profile_type == NetworkProfile::TYPE_SHARED)
policy_source = ::onc::kAugmentationDevicePolicy;
else
NOTREACHED();
diff --git a/chromeos/network/shill_property_util.h b/chromeos/network/shill_property_util.h
index 152e779..5694e793 100644
--- a/chromeos/network/shill_property_util.h
+++ b/chromeos/network/shill_property_util.h
@@ -36,7 +36,7 @@ CHROMEOS_EXPORT std::string GetSSIDFromProperties(
CHROMEOS_EXPORT std::string GetNetworkIdFromProperties(
const base::DictionaryValue& properties);
- // Returns the name for the network represented by the Shill |properties|. For
+// Returns the name for the network represented by the Shill |properties|. For
// WiFi it refers to the HexSSID.
CHROMEOS_EXPORT std::string GetNameFromProperties(
const std::string& service_path,
diff --git a/chromeos/test/data/network/invalid_settings_with_repairs.json b/chromeos/test/data/network/invalid_settings_with_repairs.json
index 5022c05..67c375be 100644
--- a/chromeos/test/data/network/invalid_settings_with_repairs.json
+++ b/chromeos/test/data/network/invalid_settings_with_repairs.json
@@ -158,7 +158,7 @@
},
"ConnectionState": "NotConnected"
},
- "network-wifi-hexssid-invalid-length": {
+ "wifi-hexssid-invalid-length": {
"GUID": "guid",
"Type": "WiFi",
"Name": "name",
@@ -168,7 +168,17 @@
"Security": "WPA-PSK"
}
},
- "network-wifi-invalid-hexssid": {
+ "wifi-ssid-invalid-length": {
+ "GUID": "guid",
+ "Type": "WiFi",
+ "Name": "name",
+ "WiFi": {
+ "Passphrase": "some passphrase",
+ "SSID": "a ssid longer than 32 bytes is invalid",
+ "Security": "WPA-PSK"
+ }
+ },
+ "wifi-invalid-hexssid": {
"GUID": "guid",
"Type": "WiFi",
"Name": "name",
@@ -178,7 +188,7 @@
"Security": "WPA-PSK"
}
},
- "network-wifi-ssid-and-hexssid-inconsistent": {
+ "wifi-ssid-and-hexssid-inconsistent": {
"GUID": "guid",
"Type": "WiFi",
"Name": "name",
@@ -189,6 +199,27 @@
"Security": "WPA-PSK"
}
},
+ "wifi-ssid-and-hexssid-partially-invalid": {
+ "GUID": "guid",
+ "Type": "WiFi",
+ "Name": "name",
+ "WiFi": {
+ "Passphrase": "some passphrase",
+ "SSID": "a ssid longer than 32 bytes is invalid",
+ "HexSSID": "FFFFFF",
+ "Security": "WPA-PSK"
+ }
+ },
+ "wifi-ssid-and-hexssid-repaired": {
+ "GUID": "guid",
+ "Type": "WiFi",
+ "Name": "name",
+ "WiFi": {
+ "Passphrase": "some passphrase",
+ "HexSSID": "FFFFFF",
+ "Security": "WPA-PSK"
+ }
+ },
"network-unknown-value": {
"GUID": "guid",
"Type": "LTE",
diff --git a/chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc b/chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc
index 3de8b23..a3c79ce 100644
--- a/chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc
+++ b/chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc
@@ -12,6 +12,9 @@
"Effective": "UserPolicy",
"UserPolicy": false
},
+ "HexSSID": {
+ "Active": "7769666932" // "wifi2"
+ },
"SSID": {
"Active": "wifi2"
},
diff --git a/chromeos/test/data/network/policy/policy_wifi1.onc b/chromeos/test/data/network/policy/policy_wifi1.onc
index e601c95..e2c4cfa 100644
--- a/chromeos/test/data/network/policy/policy_wifi1.onc
+++ b/chromeos/test/data/network/policy/policy_wifi1.onc
@@ -5,6 +5,7 @@
"Type": "WiFi",
"Name": "Managed wifi1",
"WiFi": {
+ "HexSSID": "7769666931", // "wifi1"
"Passphrase": "policy's passphrase",
"Recommended": [ "AutoConnect", "Passphrase" ],
"SSID": "wifi1",
diff --git a/chromeos/test/data/network/repaired_toplevel_partially_invalid.onc b/chromeos/test/data/network/repaired_toplevel_partially_invalid.onc
index 5c1c516..33b5b95 100644
--- a/chromeos/test/data/network/repaired_toplevel_partially_invalid.onc
+++ b/chromeos/test/data/network/repaired_toplevel_partially_invalid.onc
@@ -28,6 +28,16 @@
"IKEVersion": 1
}
}
+ },
+ {
+ "GUID": "456",
+ "Type": "WiFi",
+ "Name": "My WiFi Network",
+ "WiFi": {
+ "HexSSID": "4F70656E577274", // "OpenWrt"
+ "Security": "None",
+ "SSID": "OpenWrt"
+ }
}
],
"Certificates": [
diff --git a/chromeos/test/data/network/shill_wifi_clientcert.json b/chromeos/test/data/network/shill_wifi_clientcert.json
index 8a0bd7a..2b90e7f 100644
--- a/chromeos/test/data/network/shill_wifi_clientcert.json
+++ b/chromeos/test/data/network/shill_wifi_clientcert.json
@@ -7,5 +7,5 @@
"SaveCredentials": true,
"SecurityClass": "802_1x",
"Type": "wifi",
- "WiFi.HexSSID": "536F6D65576966692D5859" // "SomeWifi-XY"
+ "WiFi.HexSSID": "4F70656E577274" // "OpenWrt"
}
diff --git a/chromeos/test/data/network/shill_wifi_clientref.json b/chromeos/test/data/network/shill_wifi_clientref.json
index 65dfbdc..fb5be88 100644
--- a/chromeos/test/data/network/shill_wifi_clientref.json
+++ b/chromeos/test/data/network/shill_wifi_clientref.json
@@ -7,5 +7,5 @@
"SaveCredentials": true,
"SecurityClass": "802_1x",
"Type": "wifi",
- "WiFi.HexSSID": "536F6D65576966692D5859" // "SomeWifi-XY"
+ "WiFi.HexSSID": "4F70656E577274", // "OpenWrt"
}
diff --git a/chromeos/test/data/network/shill_wifi_non_utf8_ssid.json b/chromeos/test/data/network/shill_wifi_non_utf8_ssid.json
new file mode 100644
index 0000000..3058d84
--- /dev/null
+++ b/chromeos/test/data/network/shill_wifi_non_utf8_ssid.json
@@ -0,0 +1,11 @@
+{
+ "GUID":"{64c4f86b-cf6a-4e4a-8eff-456def}",
+ "Mode":"managed",
+ "Name":"OpenWrt",
+ "Passphrase":"some passphrase",
+ "SecurityClass":"psk",
+ "Type":"wifi",
+ // Hex of the latin-1, non UTF8 string "latin-1 \xc0\xcb\xcc\xd6\xfb"
+ "WiFi.HexSSID": "6C6174696E2D3120C0CBCCD6FB"
+}
+
diff --git a/chromeos/test/data/network/toplevel_partially_invalid.onc b/chromeos/test/data/network/toplevel_partially_invalid.onc
index 7bb1fb8..141d985 100644
--- a/chromeos/test/data/network/toplevel_partially_invalid.onc
+++ b/chromeos/test/data/network/toplevel_partially_invalid.onc
@@ -30,6 +30,15 @@
}
}
},
+ {
+ "GUID": "456",
+ "Type": "WiFi",
+ "Name": "My WiFi Network",
+ "WiFi": {
+ "Security": "None",
+ "SSID": "OpenWrt"
+ }
+ },
{ "GUID": "guid",
"Name": "name",
"Ethernet": {
diff --git a/chromeos/test/data/network/toplevel_wifi_ssid_and_hexssid.onc b/chromeos/test/data/network/toplevel_wifi_ssid_and_hexssid.onc
index 99be5bc..74fb658 100644
--- a/chromeos/test/data/network/toplevel_wifi_ssid_and_hexssid.onc
+++ b/chromeos/test/data/network/toplevel_wifi_ssid_and_hexssid.onc
@@ -1,4 +1,3 @@
-// Test ONC file for importing an open network.
{
"NetworkConfigurations": [
{
@@ -7,7 +6,7 @@
"Name": "My WiFi Network",
"WiFi": {
"SSID": "Google",
- "HexSSID": "476F6F676C65",
+ "HexSSID": "476f6F676C65",
"Security": "None"
}
}
diff --git a/chromeos/test/data/network/translation_of_shill_wifi_clientcert.onc b/chromeos/test/data/network/translation_of_shill_wifi_clientcert.onc
index 1f2956c..7a32530 100644
--- a/chromeos/test/data/network/translation_of_shill_wifi_clientcert.onc
+++ b/chromeos/test/data/network/translation_of_shill_wifi_clientcert.onc
@@ -8,7 +8,8 @@
"SaveCredentials": true,
"UseSystemCAs": true
},
- "SSID":"SomeWifi-XY",
+ "HexSSID":"4F70656E577274", // "OpenWrt"
+ "SSID":"OpenWrt",
"Security":"WPA-EAP"
}
}
diff --git a/chromeos/test/data/network/translation_of_shill_wifi_non_utf8_ssid.onc b/chromeos/test/data/network/translation_of_shill_wifi_non_utf8_ssid.onc
new file mode 100644
index 0000000..aa1d208
--- /dev/null
+++ b/chromeos/test/data/network/translation_of_shill_wifi_non_utf8_ssid.onc
@@ -0,0 +1,12 @@
+{
+ "GUID":"{64c4f86b-cf6a-4e4a-8eff-456def}",
+ "Name":"OpenWrt",
+ "Type":"WiFi",
+ "WiFi":{
+ // Hex of the SSID field
+ "HexSSID": "6C6174696E2D3120C0CBCCD6FB",
+ "Passphrase":"some passphrase",
+ "Security":"WPA-PSK",
+ "SSID": "latin-1 \u00c0\u00cb\u00cc\u00d6\u00fb"
+ }
+}
diff --git a/chromeos/test/data/network/translation_of_shill_wifi_with_state.onc b/chromeos/test/data/network/translation_of_shill_wifi_with_state.onc
index 25c833e..43355c2 100644
--- a/chromeos/test/data/network/translation_of_shill_wifi_with_state.onc
+++ b/chromeos/test/data/network/translation_of_shill_wifi_with_state.onc
@@ -7,6 +7,7 @@
"WiFi": {
"AutoConnect": true,
"BSSID": "00:12:34:ca:56:8b",
+ "HexSSID": "4F70656E577274", // "OpenWrt"
"HiddenSSID": false,
"Passphrase": "some passphrase",
"SSID": "OpenWrt",
diff --git a/chromeos/test/data/network/valid_wifi_clientref.onc b/chromeos/test/data/network/valid_wifi_clientref.onc
index 259ff76..3a31e79 100644
--- a/chromeos/test/data/network/valid_wifi_clientref.onc
+++ b/chromeos/test/data/network/valid_wifi_clientref.onc
@@ -3,7 +3,7 @@
"Type": "WiFi",
"Name": "SomeWifi-XY",
"WiFi": {
- "SSID": "SomeWifi-XY",
+ "HexSSID": "4F70656E577274", // "OpenWrt"
"Security": "WPA-EAP",
"Recommended": [ "AutoConnect" ],
"EAP": {
diff --git a/chromeos/test/data/network/valid_wifi_psk.onc b/chromeos/test/data/network/valid_wifi_psk.onc
index 0fde0dd..0de9781 100644
--- a/chromeos/test/data/network/valid_wifi_psk.onc
+++ b/chromeos/test/data/network/valid_wifi_psk.onc
@@ -27,9 +27,9 @@
"AutoConnect": true,
"Frequency": 2412,
"FrequencyList": [2412, 5180],
+ "HexSSID": "4F70656E577274", // "OpenWrt"
"HiddenSSID": false,
"Passphrase": "some passphrase",
- "SSID": "OpenWrt",
"Security": "WPA-PSK"
}
}
diff --git a/chromeos/test/data/network/wifi_clientcert_with_cert_pems.onc b/chromeos/test/data/network/wifi_clientcert_with_cert_pems.onc
index 32481f0..7e31b61 100644
--- a/chromeos/test/data/network/wifi_clientcert_with_cert_pems.onc
+++ b/chromeos/test/data/network/wifi_clientcert_with_cert_pems.onc
@@ -3,7 +3,7 @@
"Type": "WiFi",
"Name": "SomeWifi-XY",
"WiFi": {
- "SSID": "SomeWifi-XY",
+ "HexSSID": "4F70656E577274", // Hex of "OpenWrt"
"Security": "WPA-EAP",
"Recommended": [ "AutoConnect" ],
"EAP": {
diff --git a/chromeos/test/data/network/wifi_dhcp.onc b/chromeos/test/data/network/wifi_dhcp.onc
index 12ae00e..ad7e9f7 100644
--- a/chromeos/test/data/network/wifi_dhcp.onc
+++ b/chromeos/test/data/network/wifi_dhcp.onc
@@ -5,8 +5,8 @@
"Type": "WiFi",
"WiFi": {
"AutoConnect": true,
+ "HexSSID": "576966695769746844484350", // "WifiWithDHCP"
"Passphrase": "some passphrase",
- "SSID": "WifiWithDHCP",
"Security": "WPA-PSK"
}
}
diff --git a/components/onc/docs/onc_spec.html b/components/onc/docs/onc_spec.html
index f33fdee..8bf7e6d 100644
--- a/components/onc/docs/onc_spec.html
+++ b/components/onc/docs/onc_spec.html
@@ -698,12 +698,7 @@
a hex representation of <span class="field">SSID</span>)
<span class="type">string</span>
</span>
- Hex representation of the network's SSID. If the
- <span class="field">SSID</span> field is set, but
- <span class="field">HexSSID</span> is not, converts the contents of the
- <span class="field">SSID</span> field to UTF-8 encoding,
- creates the hex representation and assigns the result to
- <span class="field">HexSSID</span>.
+ Hex representation of the network's SSID.
</dd>
<dt class="field">HiddenSSID</dt>
@@ -748,12 +743,20 @@
<dt class="field">SSID</dt>
<dd>
<span class="field_meta">
- (optional if <span class="field">HexSSID</span> is set)
+ (optional if <span class="field">HexSSID</span> is set, otherwise
+ ignored)
<span class="type">string</span>
</span>
- SSID of the network. This field can only used for unicode strings in the
- UTF-8 encoding. For non-UTF-8 encodings the
- <span class="field">HexSSID</span> field must be used.
+ Property to access the decoded SSID of a network.<br/>
+ If this field is set, but <span class="field">HexSSID</span> is not,
+ its value will be UTF-8 encoded and the hex representation will be
+ assigned to <span class="field">HexSSID</span>. To configure a non-UTF-8
+ SSID, field <span class="field">HexSSID</span> must be used.<br/>
+ When reading the configuration of a network, both this field and
+ <span class="field">HexSSID</span> might be set. Then this field is the
+ decoding of <span class="field">HexSSID</span>. If possible the HexSSID is
+ decoded using UTF-8, otherwise an encoding is guessed on a best effort
+ basis.
</dd>
<dt class="field">SignalStrength</dt>
diff --git a/components/wifi/network_properties.cc b/components/wifi/network_properties.cc
index 8656165..49aeb69 100644
--- a/components/wifi/network_properties.cc
+++ b/components/wifi/network_properties.cc
@@ -6,6 +6,7 @@
#include "base/json/json_reader.h"
#include "base/message_loop/message_loop.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "components/onc/onc_constants.h"
@@ -54,6 +55,8 @@ scoped_ptr<base::DictionaryValue> NetworkProperties::ToValue(
if (!bssid.empty())
wifi->SetString(onc::wifi::kBSSID, bssid);
wifi->SetString(onc::wifi::kSSID, ssid);
+ wifi->SetString(onc::wifi::kHexSSID,
+ base::HexEncode(ssid.c_str(), ssid.size()));
}
value->Set(onc::network_type::kWiFi, wifi.release());
diff --git a/components/wifi/network_properties.h b/components/wifi/network_properties.h
index 5295138..8e4d179 100644
--- a/components/wifi/network_properties.h
+++ b/components/wifi/network_properties.h
@@ -7,6 +7,7 @@
#include <list>
#include <set>
+#include <string>
#include "base/values.h"
#include "components/wifi/wifi_export.h"