diff mbox series

Wifi: Support NVT-ASCII in passphrase

Message ID CAOJGChDzNh7EbWM9kw-0zCzD9rT0Sf9XT5ERkYaPfdRGZ7RK8g@mail.gmail.com
State Changes Requested
Headers show
Series Wifi: Support NVT-ASCII in passphrase | expand

Commit Message

Isaac Chiou March 23, 2021, 9:05 a.m. UTC
Hi,

In this patch, we create a new function has_non_nvt_ascii_char which
allows the following control characters to be a part of a PSK
passphrase.

7 (Bell)
8 (Backspace)
9 (Horizontal tab)
10 (Line feed)
11 (Vertical tab)
12 (Form feed)
13 (Carriage return)

Best regards,
Isaac

Comments

Jouni Malinen March 23, 2021, 5:30 p.m. UTC | #1
On Tue, Mar 23, 2021 at 05:05:15PM +0800, Isaac Chiou wrote:
> In this patch, we create a new function has_non_nvt_ascii_char which
> allows the following control characters to be a part of a PSK
> passphrase.
> 
> 7 (Bell)
> 8 (Backspace)
> 9 (Horizontal tab)
> 10 (Line feed)
> 11 (Vertical tab)
> 12 (Form feed)
> 13 (Carriage return)

This patch does not really change anything in passphrase validation,
i.e., it is only adding a new unused validation function. That said, why
would this direction be needed? What kind of use case needs such control
characters in a passphrase? None of those listed values are valid
characters in a passphrase as far as the standard is concerned.

IEEE Std 802.11-2020, Annex J.4.1: "Each character in the pass-phrase
has an encoding in the range 32 to 126 (decimal)."
diff mbox series

Patch

From 09697aa1433abe1e46e4a1b5566d3a17cd4b27a9 Mon Sep 17 00:00:00 2001
From: Isaac Chiou <isaacchiou@google.com>
Date: Tue, 23 Mar 2021 16:37:48 +0800
Subject: [PATCH] Wifi: Support NVT-ASCII in passphrase

Create a new function has_non_nvt_ascii_char which allows the following
control characters to be a part of a PSK passphrase

7 (Bell)
8 (Backspace)
9 (Horizontal tab)
10 (Line feed)
11 (Vertical tab)
12 (Form feed)
13 (Carriage return)

Signed-off-by: Isaac Chiou <isaacchiou@google.com>
---
 src/utils/common.c | 14 ++++++++++++++
 src/utils/common.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/src/utils/common.c b/src/utils/common.c
index 2c1275193..20f1c6c3f 100644
--- a/src/utils/common.c
+++ b/src/utils/common.c
@@ -720,6 +720,20 @@  int has_ctrl_char(const u8 *data, size_t len)
 }
 
 
+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 45f72bb30..660951ec6 100644
--- a/src/utils/common.h
+++ b/src/utils/common.h
@@ -509,6 +509,7 @@  const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
 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,
-- 
2.31.0.rc2.261.g7f71774620-goog