ESP32: Map wifi_auth_mode_t to NetworkCommissioning Security (#27929)

diff --git a/src/platform/ESP32/NetworkCommissioningDriver.cpp b/src/platform/ESP32/NetworkCommissioningDriver.cpp
index a99f20a..2c597da 100644
--- a/src/platform/ESP32/NetworkCommissioningDriver.cpp
+++ b/src/platform/ESP32/NetworkCommissioningDriver.cpp
@@ -38,6 +38,40 @@
 static uint8_t WiFiSSIDStr[DeviceLayer::Internal::kMaxWiFiSSIDLength];
 } // namespace
 
+BitFlags<WiFiSecurityBitmap> ConvertSecurityType(wifi_auth_mode_t authMode)
+{
+    BitFlags<WiFiSecurityBitmap> securityType;
+    switch (authMode)
+    {
+    case WIFI_AUTH_OPEN:
+        securityType.Set(WiFiSecurity::kUnencrypted);
+        break;
+    case WIFI_AUTH_WEP:
+        securityType.Set(WiFiSecurity::kWep);
+        break;
+    case WIFI_AUTH_WPA_PSK:
+        securityType.Set(WiFiSecurity::kWpaPersonal);
+        break;
+    case WIFI_AUTH_WPA2_PSK:
+        securityType.Set(WiFiSecurity::kWpa2Personal);
+        break;
+    case WIFI_AUTH_WPA_WPA2_PSK:
+        securityType.Set(WiFiSecurity::kWpa2Personal);
+        securityType.Set(WiFiSecurity::kWpaPersonal);
+        break;
+    case WIFI_AUTH_WPA3_PSK:
+        securityType.Set(WiFiSecurity::kWpa3Personal);
+        break;
+    case WIFI_AUTH_WPA2_WPA3_PSK:
+        securityType.Set(WiFiSecurity::kWpa3Personal);
+        securityType.Set(WiFiSecurity::kWpa2Personal);
+        break;
+    default:
+        break;
+    }
+    return securityType;
+}
+
 CHIP_ERROR GetConfiguredNetwork(Network & network)
 {
     wifi_ap_record_t ap_info;
diff --git a/src/platform/ESP32/NetworkCommissioningDriver.h b/src/platform/ESP32/NetworkCommissioningDriver.h
index ed5fac3..7a26165 100644
--- a/src/platform/ESP32/NetworkCommissioningDriver.h
+++ b/src/platform/ESP32/NetworkCommissioningDriver.h
@@ -19,6 +19,9 @@
 #include <esp_wifi.h>
 #include <platform/NetworkCommissioning.h>
 
+using chip::BitFlags;
+using chip::app::Clusters::NetworkCommissioning::WiFiSecurityBitmap;
+
 namespace chip {
 namespace DeviceLayer {
 namespace NetworkCommissioning {
@@ -28,6 +31,8 @@
 constexpr uint8_t kWiFiConnectNetworkTimeoutSeconds = 30;
 } // namespace
 
+BitFlags<WiFiSecurityBitmap> ConvertSecurityType(wifi_auth_mode_t authMode);
+
 class ESPScanResponseIterator : public Iterator<WiFiScanResponse>
 {
 public:
@@ -40,7 +45,7 @@
             return false;
         }
 
-        item.security.SetRaw(mpScanResults[mIternum].authmode);
+        item.security = ConvertSecurityType(mpScanResults[mIternum].authmode);
         static_assert(chip::DeviceLayer::Internal::kMaxWiFiSSIDLength <= UINT8_MAX, "SSID length might not fit in item.ssidLen");
         item.ssidLen = static_cast<uint8_t>(
             strnlen(reinterpret_cast<const char *>(mpScanResults[mIternum].ssid), chip::DeviceLayer::Internal::kMaxWiFiSSIDLength));