From patchwork Mon Jun 21 20:23:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Jaeckel X-Patchwork-Id: 1495305 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G81HM1rGlz9sTD for ; Tue, 22 Jun 2021 06:25:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 954D582BD7; Mon, 21 Jun 2021 22:24:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=eyet-services.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 2C8B082BE5; Mon, 21 Jun 2021 22:24:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from aye.elm.relay.mailchannels.net (aye.elm.relay.mailchannels.net [23.83.212.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 88F0B829F0 for ; Mon, 21 Jun 2021 22:24:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=eyet-services.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jaeckel-floss@eyet-services.de X-Sender-Id: instrampxe0y3a|x-authuser|jaeckel@eyet-services.de Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B395C342AC0; Mon, 21 Jun 2021 20:24:40 +0000 (UTC) Received: from cpanel-004-fra.hostingww.com (100-96-17-75.trex.outbound.svc.cluster.local [100.96.17.75]) (Authenticated sender: instrampxe0y3a) by relay.mailchannels.net (Postfix) with ESMTPA id E7C5A342734; Mon, 21 Jun 2021 20:24:37 +0000 (UTC) X-Sender-Id: instrampxe0y3a|x-authuser|jaeckel@eyet-services.de Received: from cpanel-004-fra.hostingww.com (ec2-18-198-100-52.eu-central-1.compute.amazonaws.com [18.198.100.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.17.75 (trex/6.3.3); Mon, 21 Jun 2021 20:24:40 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: instrampxe0y3a|x-authuser|jaeckel@eyet-services.de X-MailChannels-Auth-Id: instrampxe0y3a X-Eight-Army: 4f1000935d5b91a0_1624307080007_2888237898 X-MC-Loop-Signature: 1624307080007:2041604169 X-MC-Ingress-Time: 1624307080007 Received: from hsi-kbw-46-223-101-50.hsi.kabel-badenwuerttemberg.de ([46.223.101.50]:39002 helo=draupnir.jaeckel.lan) by cpanel-004-fra.hostingww.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1lvQTA-00066a-89; Mon, 21 Jun 2021 20:24:36 +0000 From: Steffen Jaeckel To: u-boot@lists.denx.de Cc: Steffen Jaeckel , Simon Glass , Alexandru Gagniuc , Bin Meng , Heiko Schocher , Heinrich Schuchardt , Joel Peshkin , Klaus Heinrich Kiwi , Masahisa Kojima , Patrick Delaunay , Siew Chin Lim , "Yuezhang.Mo@sony.com" Subject: [PATCH v3 5/8] common: allow disabling of timeout for password entry Date: Mon, 21 Jun 2021 22:23:48 +0200 Message-Id: <20210621202352.1250303-6-jaeckel-floss@eyet-services.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210621202352.1250303-1-jaeckel-floss@eyet-services.de> References: <20210621202352.1250303-1-jaeckel-floss@eyet-services.de> MIME-Version: 1.0 X-OutGoing-Spam-Status: No, score=-1.0 X-AuthUser: jaeckel@eyet-services.de X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 key before entering any other character. Signed-off-by: Steffen Jaeckel Reviewed-by: Simon Glass --- (no changes since v1) common/Kconfig.boot | 8 ++++++++ common/autoboot.c | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/common/Kconfig.boot b/common/Kconfig.boot index 410d117cdd..e70dcf17cb 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -859,6 +859,14 @@ config AUTOBOOT_KEYED_CTRLC Setting this variable provides an escape sequence from the limited "password" strings. +config AUTOBOOT_NEVER_TIMEOUT + bool "Make the password entry never time-out" + depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION && CRYPT_PW + help + This option removes the timeout from the password entry + when the user first presses the key before entering + any other character. + config AUTOBOOT_STOP_STR_ENABLE bool "Enable fixed string to stop autobooting" depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION diff --git a/common/autoboot.c b/common/autoboot.c index e03c387a1f..50ab9281e7 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -62,6 +62,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 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 */ @@ -71,6 +75,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(CONFIG_AUTOBOOT_STOP_STR_ENABLE) && !crypt_env_str) @@ -90,6 +95,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); @@ -103,7 +113,7 @@ static int passwd_abort_crypt(uint64_t etime) presskey_len++; } } - } while (get_ticks() <= etime); + } while (never_timeout || get_ticks() <= etime); return abort; }