Wifi: Support NVT-ASCII in passphrase

Change in wpa_supplicant to support NVT-ASCII in passphrase

Bug: 129974610
Test: Manual test
Change-Id: Ia88804bbf6b3d8f78dbcd6a7a11c0c2201d68b11
diff --git a/src/utils/common.c b/src/utils/common.c
index 2c12751..20f1c6c 100644
--- a/src/utils/common.c
+++ b/src/utils/common.c
@@ -720,6 +720,20 @@
 }
 
 
+int has_non_nvt_ascii_char(const u8 *data, size_t len)
+{
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		if (data[i] < 7
+			|| (13 < data[i] && data[i] < 32)
+				|| data[i] == 127)
+			return 1;
+	}
+	return 0;
+}
+
+
 int has_newline(const char *str)
 {
 	while (*str) {
diff --git a/src/utils/common.h b/src/utils/common.h
index 45f72bb..660951e 100644
--- a/src/utils/common.h
+++ b/src/utils/common.h
@@ -509,6 +509,7 @@
 char * wpa_config_parse_string(const char *value, size_t *len);
 int is_hex(const u8 *data, size_t len);
 int has_ctrl_char(const u8 *data, size_t len);
+int has_non_nvt_ascii_char(const u8 *data, size_t len);
 int has_newline(const char *str);
 size_t merge_byte_arrays(u8 *res, size_t res_len,
 			 const u8 *src1, size_t src1_len,
diff --git a/wpa_supplicant/hidl/1.4/sta_network.cpp b/wpa_supplicant/hidl/1.4/sta_network.cpp
index 3e773de..04d42dd 100644
--- a/wpa_supplicant/hidl/1.4/sta_network.cpp
+++ b/wpa_supplicant/hidl/1.4/sta_network.cpp
@@ -2414,7 +2414,7 @@
 					  PSK_PASSPHRASE_MAX_LEN_IN_BYTES)) {
 		return 1;
 	}
-	if (has_ctrl_char((u8 *)psk.c_str(), psk.size())) {
+	if (has_non_nvt_ascii_char((u8 *)psk.c_str(), psk.size())) {
 		return 1;
 	}
 	return 0;