From patchwork Sun Jul 21 02:51:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1134495 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GIm8rvfN"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45rqk33Rsnz9s3l for ; Sun, 21 Jul 2019 13:20:11 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 253ACC21F3A; Sun, 21 Jul 2019 03:20:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 131B9C21D74; Sun, 21 Jul 2019 02:54:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1A80DC21DED; Sun, 21 Jul 2019 02:54:15 +0000 (UTC) Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by lists.denx.de (Postfix) with ESMTPS id ED9F8C21CB1 for ; Sun, 21 Jul 2019 02:52:11 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id f4so66555066ioh.6 for ; Sat, 20 Jul 2019 19:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J7+ReWCij5Jl+uGU8NhJOZNYaj8a0tfQk1aNt5svmcQ=; b=GIm8rvfN+OO4igWVWtQPHkBoUdKigTEIrbF9QJFMrt+L7mFhBLGbMKjNjtyHgObUfi xV5HyGCv+njFdiF300TFZkKIFYJODGEDqAmOum+5kEiU4wIhDE54U2Hp14qD/jh8G03g +5sFha+D9dLwZiM/l8T6COk1dUUcKePBL6gSM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J7+ReWCij5Jl+uGU8NhJOZNYaj8a0tfQk1aNt5svmcQ=; b=IULdhCAXA3zALYWn+rPyuAbi93hyQ9p1hW54tV+NN0Tz55GTcrUjIgPjRtzA7TSCpF KHq2BWXDlg75NOI1ih0/6brV7G7DStBz0/wvtG627Ra/NVLsNcBZi9gBC+fswZhjhhri Dnjgeznj3AuEKFD06zC/GQchbhnD9XIrLh9kEMlN3to8hXj4sV9xZU0GPSGb6j2EBuxH y1+0jeB/T6DM27FDj4KMbHXHdBeO/vKh2fNyocfiTmMUPm17MWm93cpI8CVrVWsbWdJd k3DHk5rDgeSkPUDLYFKxpYCUbV+jJe9DajJWTLgA+n14RH2u4sK+D5NlXvcdRQLDOWW0 PHGQ== X-Gm-Message-State: APjAAAX6jfxYKWt5F7nWmD0G+XdZ0B5Qq4oAIrWaN7aem9+f+GR+s+WR BNyU3GcDFX3MoURM2ZReiPO0VBXdBF0= X-Google-Smtp-Source: APXvYqwlId6xxzXJlzEJAnX8axMptDJeN0mP3Y1jaXju/4Rm1/PIXb4uQ5IB5D+CpaCJzYjsQkCzxw== X-Received: by 2002:a6b:901:: with SMTP id t1mr48133177ioi.42.1563677530864; Sat, 20 Jul 2019 19:52:10 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id b14sm38862696iod.33.2019.07.20.19.52.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 20 Jul 2019 19:52:10 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 20 Jul 2019 20:51:16 -0600 Message-Id: <20190721025128.30351-7-sjg@chromium.org> X-Mailer: git-send-email 2.22.0.657.g960e92d24f-goog In-Reply-To: <20190721025128.30351-1-sjg@chromium.org> References: <20190721025128.30351-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Tom Rini , Martin Etnestad Subject: [U-Boot] [PATCH v2 06/18] autoboot: Drop #ifdef for CONFIG_AUTOBOOT_ENCRYPTION X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Use if() instead for this option, renaming the two different passwd_abort() functions to indicate their purpose. Signed-off-by: Simon Glass --- Changes in v2: None common/autoboot.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/autoboot.c b/common/autoboot.c index e3086e3828..5a0dac8d79 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,6 @@ static int stored_bootdelay; #endif #if defined(CONFIG_AUTOBOOT_KEYED) -#if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256) /* * Use a "constant-length" time compare function for this @@ -54,7 +54,7 @@ static int slow_equals(u8 *a, u8 *b, int len) return diff == 0; } -static int passwd_abort(uint64_t etime) +static int passwd_abort_sha256(uint64_t etime) { const char *sha_env_str = env_get("bootstopkeysha256"); u8 sha_env[SHA256_SUM_LEN]; @@ -105,8 +105,8 @@ static int passwd_abort(uint64_t etime) return abort; } -#else -static int passwd_abort(uint64_t etime) + +static int passwd_abort_key(uint64_t etime) { int abort = 0; struct { @@ -182,7 +182,6 @@ static int passwd_abort(uint64_t etime) return abort; } -#endif /*************************************************************************** * Watch for 'delay' seconds for autoboot stop or autoboot delay string. @@ -201,7 +200,10 @@ static int __abortboot(int bootdelay) printf(CONFIG_AUTOBOOT_PROMPT, bootdelay); # endif - abort = passwd_abort(etime); + if (IS_ENABLED(CONFIG_AUTOBOOT_ENCRYPTION)) + abort = passwd_abort_sha256(etime); + else + abort = passwd_abort_key(etime); if (!abort) debug_bootkeys("key timeout\n");