Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30D80C433EF for ; Fri, 12 Nov 2021 19:30:10 +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 9CCC160F41 for ; Fri, 12 Nov 2021 19:30:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9CCC160F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC34383081; Fri, 12 Nov 2021 20:29:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="eRC837nd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 014A383046; Fri, 12 Nov 2021 20:29:08 +0100 (CET) Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5020083046 for ; Fri, 12 Nov 2021 20:28:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x331.google.com with SMTP id w6-20020a9d77c6000000b0055e804fa524so15386562otl.3 for ; Fri, 12 Nov 2021 11:28:57 -0800 (PST) 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=YJCK0y1XTsl36mFoKs00M5/TdhQoGyA5hcbmusj/o28=; b=eRC837ndDkkmX3QD1m/mFpm7HLXGv11NZf3cjO4RoRRbie8lt2h/LvUSV12C2fDSqJ TcKweygS0WJIay5ZXoUKqWgn8XhJgi7WmBKEt77cd/TljJTmkcSudDuWDx5rXX81tisx 5gOzy0YgEVsmo5WXhnVxBFmQMHK3cnyBsNN8Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YJCK0y1XTsl36mFoKs00M5/TdhQoGyA5hcbmusj/o28=; b=oaA8Q8vaSZxCp56Mk1hrOJL7MRMmkNwgckQPe5SaBPWNZw/+9RtaZSn1WIWr4g+jT2 VHGT/428gJdlLDbjCekyq/JEGLEgpZs56YgoodzGJDUShwdcEY5zX7gByMKA4eYCaWaB JHGCS2zsXuF2bE8nxzDVIv2LuRgjSZ3PEmL8vzlYn8WySZtnjDsmrPSe9mAhONPVA3YA O99VGgO5HQs1gtkcvHTmcWOpwVzy56S0aAX+6xIJc9G3mp2CGS+Phs7WGB01KpCHqELD o2r6iAE4HDtCwrA+jBu7DIKzPB9AcSUHVKocQZ+etuEuF9gbCkAIn0Lvi+Ek/uQ+9HRd PZSw== X-Gm-Message-State: AOAM532NLrqBGaSKALjMysbBLQDZtHEqe1IxopeUXy0OUZmZUWgsYgt9 T4XLix97i1UoqD9uCL+FrnzpvzGLXfiwhQ== X-Google-Smtp-Source: ABdhPJxfqc2bd7ddAEaxpI/a1dtf4KzmLZDCwzBdzfjoNd7Y8DcAMr/2hRIEcF1Wr4xT6INQvZKUPg== X-Received: by 2002:a9d:6297:: with SMTP id x23mr14271063otk.142.1636745335772; Fri, 12 Nov 2021 11:28:55 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id n20sm1283527ooe.7.2021.11.12.11.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 11:28:55 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Rob Herring , Tom Rini , Bill Mills , Simon Glass , Alexandru Gagniuc , Artem Lapkin , Hannu Lounento , Joel Stanley , John Keeping Subject: [PATCH 08/16] tools: Tidy up argument order in fit_config_check_sig() Date: Fri, 12 Nov 2021 12:28:09 -0700 Message-Id: <20211112192817.199075-9-sjg@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211112192817.199075-1-sjg@chromium.org> References: <20211112192817.199075-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 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 Put the parent node first in the parameters as this is more natural. Also add a comment to explain what is going on. Signed-off-by: Simon Glass --- boot/image-fit-sig.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/boot/image-fit-sig.c b/boot/image-fit-sig.c index f0ccd9b5227..253748ef649 100644 --- a/boot/image-fit-sig.c +++ b/boot/image-fit-sig.c @@ -226,21 +226,34 @@ int fit_image_verify_required_sigs(const void *fit, int image_noffset, /** * fit_config_check_sig() - Check the signature of a config * + * Here we are looking at a particular signature that needs verification (here + * signature-1): + * + * configurations { + * default = "conf-1"; + * conf-1 { + * kernel = "kernel-1"; + * fdt = "fdt-1"; + * signature-1 { + * algo = "sha1,rsa2048"; + * value = <...conf 1 signature...>; + * }; + * }; + * * @fit: FIT to check - * @noffset: Offset of configuration node (e.g. /configurations/conf-1) - * @required_keynode: Offset in the control FDT of the required key node, + * @noffset: Offset of the signature node being checked (e.g. + * /configurations/conf-1/signature-1) + * @conf_noffset: Offset of configuration node (e.g. /configurations/conf-1) + * @required_keynode: Offset in @key_blob of the required key node, * if any. If this is given, then the configuration wil not * pass verification unless that key is used. If this is * -1 then any signature will do. - * @conf_noffset: Offset of the configuration subnode being checked (e.g. - * /configurations/conf-1/kernel) * @err_msgp: In the event of an error, this will be pointed to a * help error string to display to the user. * @return 0 if all verified ok, <0 on error */ -static int fit_config_check_sig(const void *fit, int noffset, - int required_keynode, int conf_noffset, - char **err_msgp) +static int fit_config_check_sig(const void *fit, int noffset, int conf_noffset, + int required_keynode, char **err_msgp) { static char * const exc_prop[] = { "data", @@ -409,8 +422,8 @@ static int fit_config_verify_key(const void *fit, int conf_noffset, if (!strncmp(name, FIT_SIG_NODENAME, strlen(FIT_SIG_NODENAME))) { - ret = fit_config_check_sig(fit, noffset, key_offset, - conf_noffset, &err_msg); + ret = fit_config_check_sig(fit, noffset, conf_noffset, + key_offset, &err_msg); if (ret) { puts("- "); } else { -- 2.34.0.rc1.387.gb447b232ab-goog