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 2F871C433F5 for ; Fri, 12 Nov 2021 19:30:51 +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 A5AF760F41 for ; Fri, 12 Nov 2021 19:30:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A5AF760F41 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 4EB5A83093; Fri, 12 Nov 2021 20:29:50 +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="PzW2hE+n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C1BC88302F; Fri, 12 Nov 2021 20:29:17 +0100 (CET) Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 4025A82FB9 for ; Fri, 12 Nov 2021 20:29:01 +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-oi1-x22f.google.com with SMTP id q124so19776670oig.3 for ; Fri, 12 Nov 2021 11:29:01 -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=apKefxu6VtOCFchHVhRx4SHGPdUIWdydVDUnbhLU1E4=; b=PzW2hE+n1N3tcdB8c95OPVrPXsYDe7PD3AalDExaK+9dJVaJJCm7xTnqW8g/Gs7LNy WjBw3AUD7xsyr1DdYWKw987ahwT3eyfc4B7NCOWLtZNhrAe70NEv2AJASu/QM3jUPKaA bBRuYGgsCU+xZfxUMbgLRD7LDfm84cRYb1H9g= 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=apKefxu6VtOCFchHVhRx4SHGPdUIWdydVDUnbhLU1E4=; b=o7WQwLDhSAVnXrp/UE0Cb1KAHahWtNAcufqA/mpWFRZpyzGashtA0yJ13G3p4wIVgj COKJ/fv7y1f6lZvecsm9ya/4hOnYXetUMuNcdBE4qWsoc7cG/fIJKWTrF5MuEIsoZXXJ DNQwOUa/4Dro+0D/NF/O9y1QYmSZcPt7jNCG6bilU6GrWdM7nzIzA21K8cqRnN9omCWl 7a9vdTBM6u/4Yg71mrPhLAsnSStoh4y4QxZkEHyyGDKYK8bXKe6980w0Wj/uMHtMuKmi 21OalZM3CQIs9Ix89RVjglrfolMv+UBFQI6c6mlXc8takncM7aha6EbnJEKknE48pawk wZkA== X-Gm-Message-State: AOAM532sg4lNYABI2USIIaWxH7DWtj/F0Qfb7V3AngrseXiWw5xT4VWQ Z3S7y55Sbd5dS25LRAdWhbiHTe7/eYt+SQ== X-Google-Smtp-Source: ABdhPJw6RyWnqzbX0Xh7vaJXAkQOlHaO2ot6Jl+jg78HlNW+1fpeBC9a4k6ID1pvTmcmCquDOZRMZQ== X-Received: by 2002:aca:604:: with SMTP id 4mr28036724oig.8.1636745339719; Fri, 12 Nov 2021 11:28:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 11:28:59 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Rob Herring , Tom Rini , Bill Mills , Simon Glass , Alexandru Gagniuc , Ming Liu , Philippe Reynes , Vagrant Cascadian Subject: [PATCH 11/16] tools: Pass public-key node through to caller Date: Fri, 12 Nov 2021 12:28:12 -0700 Message-Id: <20211112192817.199075-12-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 Update the two functions that call add_verify_data() so that the caller can see the node that was written to. Signed-off-by: Simon Glass --- tools/image-host.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tools/image-host.c b/tools/image-host.c index e53fe4bbbed..e2b120ce532 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -209,7 +209,8 @@ static int fit_image_setup_sig(struct image_sign_info *info, * @comment: Comment to add to signature nodes * @require_keys: Mark all keys as 'required' * @engine_id: Engine to use for signing - * @return 0 if ok, -1 on error + * @return keydest node if @keydest is non-NULL, else 0 if none; -ve error code + * on failure */ static int fit_image_process_sig(const char *keydir, const char *keyfile, void *keydest, void *fit, const char *image_name, @@ -269,6 +270,8 @@ static int fit_image_process_sig(const char *keydir, const char *keyfile, node_name, image_name); return ret; } + /* Return the node that was written to */ + return ret; } return 0; @@ -645,7 +648,7 @@ int fit_image_add_verification_data(const char *keydir, const char *keyfile, fit, image_name, noffset, data, size, comment, require_keys, engine_id, cmdname); } - if (ret) + if (ret < 0) return ret; } @@ -974,6 +977,24 @@ static int fit_config_get_regions(const void *fit, int conf_noffset, return 0; } +/** + * fit_config_process_sig - Process a single subnode of the configurations/ node + * + * Generate a signed hash of the supplied data and store it in the node. + * + * @keydir: Directory containing keys to use for signing + * @keydest: Destination FDT blob to write public keys into (NULL if none) + * @fit: pointer to the FIT format image header + * @conf_name name of config being processed (used to display errors) + * @conf_noffset: Offset of configuration node, e.g. '/configurations/conf-1' + * @noffset: subnode offset, e.g. '/configurations/conf-1/sig-1' + * @comment: Comment to add to signature nodes + * @require_keys: Mark all keys as 'required' + * @engine_id: Engine to use for signing + * @cmdname: Command name used when reporting errors + * @return keydest node if @keydest is non-NULL, else 0 if none; -ve error code + * on failure + */ static int fit_config_process_sig(const char *keydir, const char *keyfile, void *keydest, void *fit, const char *conf_name, int conf_noffset, int noffset, const char *comment, @@ -1034,6 +1055,7 @@ static int fit_config_process_sig(const char *keydir, const char *keyfile, printf("Failed to add verification data for '%s' signature node in '%s' configuration node\n", node_name, conf_name); } + return ret; } return 0; @@ -1063,7 +1085,7 @@ static int fit_config_add_verification_data(const char *keydir, fit, conf_name, conf_noffset, noffset, comment, require_keys, engine_id, cmdname); } - if (ret) + if (ret < 0) return ret; } -- 2.34.0.rc1.387.gb447b232ab-goog