All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
To: u-boot@lists.denx.de
Subject: [PATCH v1 5/6] cmd: allow disabling of timeout for password entry
Date: Mon, 26 Apr 2021 14:19:16 +0200	[thread overview]
Message-ID: <20210426121917.2117882-6-jaeckel-floss@eyet-services.de> (raw)
In-Reply-To: <20210426121917.2117882-1-jaeckel-floss@eyet-services.de>

In case a user has to enter a complicated password it is sometimes
desireable to give the user more time than the default timeout.
Enabling this feature will disable the timeout entirely in case the user
presses the <Enter> key before entering any other character.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 cmd/Kconfig       |  8 ++++++++
 common/autoboot.c | 12 +++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 9e8b69258f..860605e8c2 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -177,6 +177,14 @@ config CMD_SBI
 	help
 	  Display information about the SBI implementation.
 
+config AUTOBOOT_NEVER_TIMEOUT
+	bool "Make the password entry never time-out"
+	depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION
+	help
+	  This option removes the timeout from the password entry
+	  when the user first presses the <Enter> key before entering
+	  any other character.
+
 endmenu
 
 menu "Boot commands"
diff --git a/common/autoboot.c b/common/autoboot.c
index c28d93049b..e88d23dabf 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -67,6 +67,10 @@ static int menukey;
  * or
  *   the config value CONFIG_AUTOBOOT_STOP_STR_CRYPT
  *
+ * In case the config value CONFIG_AUTOBOOT_NEVER_TIMEOUT has been enabled
+ * this function never times out if the user presses the <Enter> key
+ * before starting to enter the password.
+ *
  * @etime: Timeout value ticks (stop when get_ticks() reachs this)
  * @return 0 if autoboot should continue, 1 if it should stop
  */
@@ -76,6 +80,7 @@ static int passwd_abort_crypt(uint64_t etime)
 	char presskey[DELAY_STOP_STR_MAX_LENGTH];
 	u_int presskey_len = 0;
 	int abort = 0;
+	int never_timeout = 0;
 	int err;
 
 	if (IS_ENABLED(HAS_STOP_STR_CRYPT) && !crypt_env_str)
@@ -95,6 +100,11 @@ static int passwd_abort_crypt(uint64_t etime)
 
 			if ((presskey[presskey_len] == '\r') ||
 			    (presskey[presskey_len] == '\n')) {
+				if (IS_ENABLED(CONFIG_AUTOBOOT_NEVER_TIMEOUT) &&
+				    !presskey_len) {
+					never_timeout = 1;
+					continue;
+				}
 				presskey[presskey_len] = '\0';
 				err = crypt_compare(crypt_env_str, presskey,
 						    &abort);
@@ -108,7 +118,7 @@ static int passwd_abort_crypt(uint64_t etime)
 				presskey_len++;
 			}
 		}
-	} while (get_ticks() <= etime);
+	} while (never_timeout || get_ticks() <= etime);
 
 	return abort;
 }
-- 
2.31.1

  parent reply	other threads:[~2021-04-26 12:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 12:19 [PATCH v1 0/6] common: Introduce crypt-style password support Steffen Jaeckel
2021-04-26 12:19 ` [PATCH v1 1/6] lib: add crypt subsystem Steffen Jaeckel
2021-04-29 16:10   ` Simon Glass
2021-05-01  9:51     ` Steffen Jaeckel
2021-05-04 15:26       ` Simon Glass
2021-04-26 12:19 ` [PATCH v1 2/6] lib: wrap crypt API to hide errno usage Steffen Jaeckel
2021-04-26 12:19 ` [PATCH v1 3/6] common: integrate crypt-based passwords Steffen Jaeckel
2021-04-29 16:10   ` Simon Glass
2021-04-26 12:19 ` [PATCH v1 4/6] common: Rename macro appropriately Steffen Jaeckel
2021-04-26 12:19 ` Steffen Jaeckel [this message]
2021-04-26 12:19 ` [PATCH v1 6/6] configs: add new values to bcm963158 defconfig Steffen Jaeckel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210426121917.2117882-6-jaeckel-floss@eyet-services.de \
    --to=jaeckel-floss@eyet-services.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.