diff options
author | Purushottam Kushwaha <quic_pkushwah@quicinc.com> | 2022-04-20 12:33:46 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-04-20 12:33:46 +0000 |
commit | 4624e353934bcdd5b86a7d4d8fc1bf629b29f36a (patch) | |
tree | cd3b0f6f5230660c2a85ff06a510693fc770f6d6 | |
parent | 621ef2db6261d5ab9fb830d2d8c98d02a66de0e0 (diff) | |
parent | 083fd59340c105e3c3d4c71b6a366b6353cf5537 (diff) | |
download | wpa_supplicant_8-4624e353934bcdd5b86a7d4d8fc1bf629b29f36a.tar.gz |
AIDL: DPP-AKM configuration support in configurator/enrollee roles. am: 083fd59340
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/wpa_supplicant_8/+/17332684
Change-Id: I754e0e68834882e73138e4e6843f9e55022601fb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | wpa_supplicant/aidl/aidl_manager.cpp | 7 | ||||
-rw-r--r-- | wpa_supplicant/aidl/sta_iface.cpp | 72 | ||||
-rw-r--r-- | wpa_supplicant/aidl/sta_network.cpp | 32 |
3 files changed, 103 insertions, 8 deletions
diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp index e18292a9..91245702 100644 --- a/wpa_supplicant/aidl/aidl_manager.cpp +++ b/wpa_supplicant/aidl/aidl_manager.cpp @@ -1584,7 +1584,12 @@ void AidlManager::notifyDppConfigReceived(struct wpa_supplicant *wpa_s, config->ssid + config->ssid_len); if (securityAkm == DppAkm::DPP) { - // TODO Add code to fill aidl_keys + std::string connector_str = misc_utils::charBufToString(config->dpp_connector); + aidl_keys.connector = std::vector<uint8_t>(connector_str.begin(), + connector_str.end()); + aidl_keys.cSign = byteArrToVec(config->dpp_csign, config->dpp_csign_len); + aidl_keys.netAccessKey = byteArrToVec(config->dpp_netaccesskey, + config->dpp_netaccesskey_len); } /* At this point, the network is already registered, notify about new diff --git a/wpa_supplicant/aidl/sta_iface.cpp b/wpa_supplicant/aidl/sta_iface.cpp index f382285e..b4fbb242 100644 --- a/wpa_supplicant/aidl/sta_iface.cpp +++ b/wpa_supplicant/aidl/sta_iface.cpp @@ -1419,6 +1419,9 @@ StaIface::startDppConfiguratorInitiatorInternal( #ifdef CONFIG_DPP struct wpa_supplicant *wpa_s = retrieveIfacePtr(); std::string cmd = ""; + std::string cmd2 = ""; + int32_t id; + char key[1024]; if (net_role != DppNetRole::AP && net_role != DppNetRole::STA) { @@ -1493,8 +1496,10 @@ StaIface::startDppConfiguratorInitiatorInternal( role += "psk-sae"; break; - // TODO add code to handle DPP AKM case DppAkm::DPP: + role += "dpp"; + break; + default: wpa_printf(MSG_ERROR, "DPP: Invalid or unsupported security AKM specified: %d", security_akm); @@ -1510,10 +1515,33 @@ StaIface::startDppConfiguratorInitiatorInternal( cmd += " conn_status=1"; } + if (security_akm == DppAkm::DPP) { + if (!privEcKey.empty()) { + cmd2 += " key=" + std::string(privEcKey.begin(), privEcKey.end()); + } + id = dpp_configurator_add(wpa_s->dpp, cmd2.c_str()); + if (id < 0 || (privEcKey.empty() && + (dpp_configurator_get_key_id(wpa_s->dpp, id, key, sizeof(key)) < 0))) + { + wpa_printf(MSG_ERROR, "DPP configurator add failed. " + "Input key might be incorrect"); + return {std::vector<uint8_t>(), + createStatus(SupplicantStatusCode::FAILURE_UNKNOWN)}; + } + + cmd += " configurator=" + std::to_string(id); + } + wpa_printf(MSG_DEBUG, "DPP initiator command: %s", cmd.c_str()); if (wpas_dpp_auth_init(wpa_s, cmd.c_str()) == 0) { + // Return key if input privEcKey was null/empty. + if (security_akm == DppAkm::DPP && privEcKey.empty()) { + std::string k(key); + std::vector<uint8_t> vKey(k.begin(), k.end()); + return {vKey, ndk::ScopedAStatus::ok()}; + } return {std::vector<uint8_t>(), ndk::ScopedAStatus::ok()}; } #endif @@ -1666,8 +1694,46 @@ ndk::ScopedAStatus StaIface::generateSelfDppConfigurationInternal(const std::str const std::vector<uint8_t> &privEcKey) { #ifdef CONFIG_DPP - // TODO Implement this function - return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED); + struct wpa_supplicant *wpa_s = retrieveIfacePtr(); + std::string cmd = ""; + char *ssid_hex_str; + int len; + int32_t id; + + if (ssid.empty() || privEcKey.empty()) { + wpa_printf(MSG_ERROR, "DPP generate self configuration failed. ssid/key empty"); + return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); + } + + cmd += " key=" + std::string(privEcKey.begin(), privEcKey.end()); + + id = dpp_configurator_add(wpa_s->dpp, cmd.c_str()); + if (id < 0) { + wpa_printf(MSG_ERROR, "DPP configurator add failed. Input key might be incorrect"); + return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); + } + + cmd = " conf=sta-dpp"; + cmd += " configurator=" + std::to_string(id); + + ssid_hex_str = (char *) os_zalloc(ssid.size() * 2 + 1); + if (!ssid_hex_str) { + return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); + } + + wpa_snprintf_hex(ssid_hex_str, ssid.size() * 2 + 1, (u8*)ssid.data(), ssid.size()); + cmd += " ssid=" + std::string(ssid_hex_str); + + /* Report received configuration to AIDL and create an internal profile */ + wpa_s->conf->dpp_config_processing = 1; + + if (wpas_dpp_configurator_sign(wpa_s, cmd.c_str()) == 0) { + os_free(ssid_hex_str); + return ndk::ScopedAStatus::ok(); + } + + os_free(ssid_hex_str); + return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); #else return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED); #endif diff --git a/wpa_supplicant/aidl/sta_network.cpp b/wpa_supplicant/aidl/sta_network.cpp index da5decd1..88e7b74c 100644 --- a/wpa_supplicant/aidl/sta_network.cpp +++ b/wpa_supplicant/aidl/sta_network.cpp @@ -45,7 +45,8 @@ constexpr uint32_t kAllowedKeyMgmtMask = static_cast<uint32_t>(KeyMgmtMask::WAPI_PSK) | static_cast<uint32_t>(KeyMgmtMask::WAPI_CERT) | static_cast<uint32_t>(KeyMgmtMask::FILS_SHA256) | - static_cast<uint32_t>(KeyMgmtMask::FILS_SHA384)); + static_cast<uint32_t>(KeyMgmtMask::FILS_SHA384) | + static_cast<uint32_t>(KeyMgmtMask::DPP)); constexpr uint32_t kAllowedProtoMask = (static_cast<uint32_t>(ProtoMask::WPA) | static_cast<uint32_t>(ProtoMask::RSN) | @@ -946,10 +947,33 @@ ndk::ScopedAStatus StaNetwork::setBssidInternal( ndk::ScopedAStatus StaNetwork::setDppKeysInternal(const DppConnectionKeys& keys) { #ifdef CONFIG_DPP - // TODO Implement the function - return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED); + if (keys.connector.empty() || keys.cSign.empty() || keys.netAccessKey.empty()) { + return createStatus(SupplicantStatusCode::FAILURE_ARGS_INVALID); + } + + struct wpa_ssid *wpa_ssid = retrieveNetworkPtr(); + std::string connector_str(keys.connector.begin(), keys.connector.end()); + + if (setStringFieldAndResetState( + connector_str.c_str(), &(wpa_ssid->dpp_connector), "dpp_connector")) { + return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); + } + + if (setByteArrayFieldAndResetState( + keys.cSign.data(), keys.cSign.size(), &(wpa_ssid->dpp_csign), + &(wpa_ssid->dpp_csign_len), "dpp csign")) { + return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); + } + + if (setByteArrayFieldAndResetState( + keys.netAccessKey.data(), keys.netAccessKey.size(), &(wpa_ssid->dpp_netaccesskey), + &(wpa_ssid->dpp_netaccesskey_len), "dpp netAccessKey")) { + return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); + } + + return ndk::ScopedAStatus::ok(); #else - return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED); + return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED); #endif } |