[rdkb][common][app][Fix test-tool wrong key type setting]

[Description]
Fix test-tool wrong key type setting

[Release-log]
N/A

Change-Id: I072d8b1be9bc0e5535a735b7c034afeca237a71d
diff --git a/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.c b/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.c
index 17a8b20..b180b81 100644
--- a/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.c
+++ b/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.c
@@ -237,15 +237,6 @@
     }else{
         intf_param->security.mfp = wifi_mfp_cfg_disabled;
     }
-
-    if (!strcmp(encryption_mode, "sae")){
-        intf_param->security.u.key.type = wifi_security_key_type_sae;
-    }else if (!strcmp(encryption_mode, "sae-mixed")){
-        intf_param->security.u.key.type = wifi_security_key_type_psk_sae;
-    }else{
-        intf_param->security.u.key.type = wifi_security_key_type_psk;
-    }
-
 }
 
 void set_key(wifi_intf_param *intf_param, char *key)
@@ -402,6 +393,7 @@
     int ret = 0;
     int vap_index_in_map = 0;
     int phy_index = 0;
+    int key_len = 0;
     wifi_vap_info_t vap_info = {0};
     BOOL radio_enable = FALSE;
 
@@ -442,6 +434,18 @@
         vap_info.vap_name[15] = "\0";
     }
 
+    // Security
+    if (ap_param.security.mode == wifi_security_mode_wpa3_personal || ap_param.security.mode == wifi_security_mode_wpa3_transition){
+        // OpenWrt script only set psk, here we choose to set both psk and sae.
+        ap_param.security.u.key.type = wifi_security_key_type_psk_sae;
+    } else {
+        key_len = strlen(ap_param.security.u.key.key);
+        if (key_len == 64)
+            ap_param.security.u.key.type = wifi_security_key_type_psk;
+        else if (key_len >= 8 && key_len < 64)
+            ap_param.security.u.key.type = wifi_security_key_type_pass;
+    }
+
     vap_info.u.bss_info.security.mode = ap_param.security.mode;
     vap_info.u.bss_info.security.encr = ap_param.security.encr;
     vap_info.u.bss_info.security.mfp = ap_param.security.mfp;