Map extension AKMs in AIDL to main AKM am: 1de410d064 am: c495778b19

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/wpa_supplicant_8/+/23639894

Change-Id: Id518477b3439d34d8951db05317b97568d0a356e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk
index 03dc209..c3a7bc6 100644
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
@@ -1835,7 +1835,7 @@
 PASNOBJS += src/crypto/crypto_openssl.c
 ifdef TLS_FUNCS
 PASNOBJS += src/crypto/tls_openssl.c
-#PASNOBJS += -lssl -lcrypto
+PASNOBJS += src/crypto/tls_openssl_ocsp.c
 NEED_TLS_PRF_SHA256=y
 endif
 endif
@@ -2038,13 +2038,20 @@
 include $(BUILD_STATIC_LIBRARY)
 endif # WPA_SUPPLICANT_USE_AIDL == y
 
-#include $(CLEAR_VARS)
-#LOCAL_MODULE = libpasn
-#LOCAL_CFLAGS = $(L_CFLAGS)
-#LOCAL_SRC_FILES = $(PASNOBJS)
-#LOCAL_C_INCLUDES = $(INCLUDES)
-#LOCAL_SHARED_LIBRARIES := libc libcutils liblog
-#ifeq ($(CONFIG_TLS), openssl)
-#LOCAL_SHARED_LIBRARIES := libcrypto libssl
-#endif
-#include $(BUILD_SHARED_LIBRARY)
+ifeq ($(CONFIG_PASN), y)
+include $(CLEAR_VARS)
+LOCAL_MODULE = libpasn
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-BSD SPDX-license-identifier-BSD-3-Clause SPDX-license-identifier-ISC legacy_unencumbered
+LOCAL_LICENSE_CONDITIONS := notice unencumbered
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../LICENSE
+LOCAL_VENDOR_MODULE := true
+LOCAL_CFLAGS = $(L_CFLAGS)
+LOCAL_SRC_FILES = $(PASNOBJS)
+LOCAL_C_INCLUDES = $(INCLUDES)
+LOCAL_SHARED_LIBRARIES := libc libcutils liblog
+ifeq ($(CONFIG_TLS), openssl)
+LOCAL_SHARED_LIBRARIES += libcrypto libssl libkeystore-wifi-hidl
+LOCAL_SHARED_LIBRARIES += libkeystore-engine-wifi-hidl
+endif
+include $(BUILD_SHARED_LIBRARY)
+endif # CONFIG_PASN == y
diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp
index 4d5ac29..db566ab 100644
--- a/wpa_supplicant/aidl/aidl_manager.cpp
+++ b/wpa_supplicant/aidl/aidl_manager.cpp
@@ -833,6 +833,7 @@
 	return 1;
 }
 
+#ifdef CONFIG_INTERWORKING
 /**
  * Notify that the AT_PERMANENT_ID_REQ is denied from eap_peer when the strict
  * conservative peer mode is enabled.
@@ -903,6 +904,7 @@
 			}
 		}
 
+#ifdef CONFIG_HS20
 		aidl_hs20_anqp_data.operatorFriendlyName =
 			misc_utils::convertWpaBufToVector(
 			anqp->hs20_operator_friendly_name);
@@ -914,6 +916,16 @@
 		aidl_hs20_anqp_data.osuProvidersList =
 			misc_utils::convertWpaBufToVector(
 			anqp->hs20_osu_providers_list);
+#else
+		aidl_hs20_anqp_data.operatorFriendlyName =
+			misc_utils::convertWpaBufToVector(NULL);
+		aidl_hs20_anqp_data.wanMetrics =
+			misc_utils::convertWpaBufToVector(NULL);
+		aidl_hs20_anqp_data.connectionCapability =
+			misc_utils::convertWpaBufToVector(NULL);
+		aidl_hs20_anqp_data.osuProvidersList =
+			misc_utils::convertWpaBufToVector(NULL);
+#endif /* CONFIG_HS20 */
 	}
 
 	callWithEachStaIfaceCallback(
@@ -922,6 +934,7 @@
 				   std::placeholders::_1, macAddrToVec(bssid), aidl_anqp_data,
 				   aidl_hs20_anqp_data));
 }
+#endif /* CONFIG_INTERWORKING */
 
 /**
  * Notify all listeners about the end of an HS20 icon query.
diff --git a/wpa_supplicant/aidl/sta_iface.cpp b/wpa_supplicant/aidl/sta_iface.cpp
index 4620538..afcd4b5 100644
--- a/wpa_supplicant/aidl/sta_iface.cpp
+++ b/wpa_supplicant/aidl/sta_iface.cpp
@@ -1087,6 +1087,7 @@
 	if (info_elements.size() > kMaxAnqpElems) {
 		return createStatus(SupplicantStatusCode::FAILURE_ARGS_INVALID);
 	}
+#ifdef CONFIG_INTERWORKING
 	uint16_t info_elems_buf[kMaxAnqpElems];
 	uint32_t num_info_elems = 0;
 	for (const auto &info_element : info_elements) {
@@ -1110,11 +1111,15 @@
 		return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
 	}
 	return ndk::ScopedAStatus::ok();
+#else
+	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
+#endif /* CONFIG_INTERWORKING */
 }
 
 ndk::ScopedAStatus StaIface::initiateVenueUrlAnqpQueryInternal(
 	const std::vector<uint8_t> &mac_address)
 {
+#ifdef CONFIG_INTERWORKING
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	uint16_t info_elems_buf[1] = {ANQP_VENUE_URL};
 	if (mac_address.size() != ETH_ALEN) {
@@ -1126,11 +1131,15 @@
 		return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
 	}
 	return ndk::ScopedAStatus::ok();
+#else
+	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
+#endif /* CONFIG_INTERWORKING */
 }
 
 ndk::ScopedAStatus StaIface::initiateHs20IconQueryInternal(
 	const std::vector<uint8_t> &mac_address, const std::string &file_name)
 {
+#ifdef CONFIG_HS20
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	if (mac_address.size() != ETH_ALEN) {
 		return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
@@ -1143,6 +1152,9 @@
 		return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
 	}
 	return ndk::ScopedAStatus::ok();
+#else
+	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
+#endif /* CONFIG_HS20 */
 }
 
 std::pair<std::vector<uint8_t>, ndk::ScopedAStatus>
diff --git a/wpa_supplicant/aidl/sta_network.cpp b/wpa_supplicant/aidl/sta_network.cpp
index e245247..bb3045c 100644
--- a/wpa_supplicant/aidl/sta_network.cpp
+++ b/wpa_supplicant/aidl/sta_network.cpp
@@ -1420,12 +1420,16 @@
 
 ndk::ScopedAStatus StaNetwork::setUpdateIdentifierInternal(uint32_t id)
 {
+#ifdef CONFIG_HS20
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
 	wpa_ssid->update_identifier = id;
 	wpa_printf(
 		MSG_MSGDUMP, "update_identifier: %d", wpa_ssid->update_identifier);
 	resetInternalStateAfterParamsUpdate();
 	return ndk::ScopedAStatus::ok();
+#else
+	return createStatusWithMsg(SupplicantStatusCode::FAILURE_UNKNOWN, "Not implemented");
+#endif /* CONFIG_HS20 */
 }
 
 ndk::ScopedAStatus StaNetwork::setWapiCertSuiteInternal(const std::string &suite)
@@ -2301,6 +2305,7 @@
 ndk::ScopedAStatus StaNetwork::setRoamingConsortiumSelectionInternal(
 	const std::vector<uint8_t> &selectedRcoi)
 {
+#ifdef CONFIG_HS20
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
 	if (wpa_ssid == NULL) {
 		return createStatus(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
@@ -2316,6 +2321,9 @@
 
 	resetInternalStateAfterParamsUpdate();
 	return ndk::ScopedAStatus::ok();
+#else
+	return createStatusWithMsg(SupplicantStatusCode::FAILURE_UNKNOWN, "Not implemented");
+#endif /* CONFIG_HS20 */
 }
 
 /**
diff --git a/wpa_supplicant/android.config b/wpa_supplicant/android.config
index bfdd53e..4cc3808 100644
--- a/wpa_supplicant/android.config
+++ b/wpa_supplicant/android.config
@@ -541,6 +541,9 @@
 # WPA3-Personal (SAE)
 CONFIG_SAE=y
 
+# PASN
+CONFIG_PASN=y
+
 # WPA3-Enterprise (SuiteB-192)
 CONFIG_SUITEB=y
 CONFIG_SUITEB192=y
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 253f87d..0909961 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3889,6 +3889,7 @@
 			 * EVENT_PORT_AUTHORIZED handler when the driver is done
 			 * with the 4-way handshake.
 			 */
+			wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE);
 			wpa_msg(wpa_s, MSG_INFO,
 				"ASSOC INFO: wait for driver port authorized indication");
 		}
@@ -5020,7 +5021,7 @@
 
 static void wpa_supplicant_event_port_authorized(struct wpa_supplicant *wpa_s)
 {
-	if (wpa_s->wpa_state == WPA_ASSOCIATED) {
+	if (wpa_s->wpa_state >= WPA_ASSOCIATED) {
 		wpa_supplicant_cancel_auth_timeout(wpa_s);
 		wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
 		eapol_sm_notify_portValid(wpa_s->eapol, true);
diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c
index 4d0fc63..cb1165e 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -1661,6 +1661,7 @@
 	if (interworking_set_hs20_params(wpa_s, ssid) < 0)
 		goto fail;
 
+#ifdef CONFIG_HS20
 	ie = wpa_bss_get_ie(bss, WLAN_EID_ROAMING_CONSORTIUM);
 	anqp = bss->anqp ? bss->anqp->roaming_consortium : NULL;
 	for (i = 0; (ie || anqp) && i < cred->num_roaming_consortiums; i++) {
@@ -1679,6 +1680,7 @@
 			cred->roaming_consortiums_len[i];
 		break;
 	}
+#endif /* CONFIG_HS20 */
 
 	if (cred->eap_method == NULL) {
 		wpa_msg(wpa_s, MSG_DEBUG,
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 287bc9e..1344ef6 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -5702,14 +5702,14 @@
 			wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
 			interface_count = 0;
 		}
-#ifndef ANDROID
+#ifndef CONFIG_CTRL_IFACE_AIDL
 		if (!wpa_s->p2p_mgmt &&
 		    wpa_supplicant_delayed_sched_scan(wpa_s,
 						      interface_count % 3,
 						      100000))
 			wpa_supplicant_req_scan(wpa_s, interface_count % 3,
 						100000);
-#endif /* ANDROID */
+#endif /* CONFIG_CTRL_IFACE_AIDL */
 		interface_count++;
 	} else
 		wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);