From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A126DC4743C for ; Mon, 21 Jun 2021 20:25:38 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1896B608FC for ; Mon, 21 Jun 2021 20:25:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1896B608FC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=eyet-services.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 181B182BF0; Mon, 21 Jun 2021 22:25:17 +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 CFD9A82BFB; Mon, 21 Jun 2021 22:25:06 +0200 (CEST) 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 7A0A482BE9 for ; Mon, 21 Jun 2021 22:24:56 +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 01196362A8B; Mon, 21 Jun 2021 20:24:54 +0000 (UTC) Received: from cpanel-004-fra.hostingww.com (100-96-16-80.trex.outbound.svc.cluster.local [100.96.16.80]) (Authenticated sender: instrampxe0y3a) by relay.mailchannels.net (Postfix) with ESMTPA id C9A07362377; Mon, 21 Jun 2021 20:24:51 +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.16.80 (trex/6.3.3); Mon, 21 Jun 2021 20:24:53 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: instrampxe0y3a|x-authuser|jaeckel@eyet-services.de X-MailChannels-Auth-Id: instrampxe0y3a X-Turn-Ski: 24088d8514fbf89d_1624307093772_1198349776 X-MC-Loop-Signature: 1624307093772:2463811662 X-MC-Ingress-Time: 1624307093771 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 1lvQTO-00066a-3h; Mon, 21 Jun 2021 20:24:50 +0000 From: Steffen Jaeckel To: u-boot@lists.denx.de Cc: Steffen Jaeckel , Alexandru Gagniuc , Bin Meng , Heiko Schocher , Heinrich Schuchardt , Joel Peshkin , Klaus Heinrich Kiwi , Masahisa Kojima , Siew Chin Lim , Simon Glass , "Yuezhang.Mo@sony.com" Subject: [PATCH v3 7/8] common: add support to fallback to plain SHA256 Date: Mon, 21 Jun 2021 22:23:50 +0200 Message-Id: <20210621202352.1250303-8-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 Content-Transfer-Encoding: 8bit X-OutGoing-Spam-Status: No, score=-0.5 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 crypt-based hashing is enabled this will be the default mechanism that is used. If a user wants to have support for both, the environment variable `bootstopusesha256` can be set to `true` to allow plain SHA256 based hashing of the password. Signed-off-by: Steffen Jaeckel --- (no changes since v1) common/Kconfig.boot | 8 ++++++++ common/autoboot.c | 22 +++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/common/Kconfig.boot b/common/Kconfig.boot index d19bc32836..b04a6c98e5 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -834,6 +834,14 @@ config AUTOBOOT_ENCRYPTION This provides a way to ship a secure production device which can also be accessed at the U-Boot command line. +config AUTOBOOT_SHA256_FALLBACK_ENABLE + bool "Allow fallback from crypt-hashed password to sha256" + depends on AUTOBOOT_ENCRYPTION && CRYPT_PW + help + This option adds support to fall back from crypt-hashed + passwords to checking a SHA256 hashed password in case the + 'bootstopusesha256' environment variable is set to 'true'. + config AUTOBOOT_DELAY_STR string "Delay autobooting via specific input key / string" depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION diff --git a/common/autoboot.c b/common/autoboot.c index 1eeabf0b1a..c6f550b8a7 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -305,6 +305,26 @@ static void flush_stdin(void) (void)getchar(); } +/** + * fallback_to_sha256() - check whether we should fall back to sha256 + * password checking + * + * This checks for the environment variable `bootstopusesha256` in case + * sha256-fallback has been enabled via the config setting + * `AUTOBOOT_SHA256_FALLBACK_ENABLE`. + * + * @return 0 if we must not fall-back, 1 if plain sha256 should be tried + */ +static int fallback_to_sha256(void) +{ + if (IS_ENABLED(CONFIG_AUTOBOOT_SHA256_FALLBACK_ENABLE)) + return env_get_yesno("bootstopusesha256") == 1; + else if (IS_ENABLED(CONFIG_CRYPT_PW)) + return 0; + else + return 1; +} + /*************************************************************************** * Watch for 'delay' seconds for autoboot stop or autoboot delay string. * returns: 0 - no key string, allow autoboot 1 - got key string, abort @@ -325,7 +345,7 @@ static int abortboot_key_sequence(int bootdelay) # endif if (IS_ENABLED(CONFIG_AUTOBOOT_ENCRYPTION)) { - if (IS_ENABLED(CONFIG_CRYPT_PW)) + if (IS_ENABLED(CONFIG_CRYPT_PW) && !fallback_to_sha256()) abort = passwd_abort_crypt(etime); else abort = passwd_abort_sha256(etime); -- 2.31.1