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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1CAA5C61DA3 for ; Tue, 21 Feb 2023 20:33:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 581EC85B9A; Tue, 21 Feb 2023 21:24:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="U234F+R4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B1D8685B5E; Tue, 21 Feb 2023 21:23:58 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (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 3A42285AD1 for ; Tue, 21 Feb 2023 21:22:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3A540611EE; Tue, 21 Feb 2023 20:22:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3D3EC4339B; Tue, 21 Feb 2023 20:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677010955; bh=U23J/oIO2uHrEz9WM5Tj4Bx1mX8g8Qg0s3jCog67tp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U234F+R4fuWThg3oFNogli2lKT5q5W2cG1hGzeJ96X4kXonriVoC9eotJJrgQhC8T jTbueyyuNLPumgr5RqZ1o6Is8mDI+bLSL88hAsSQCFdxLMcWn77OIaJgW9ZCiWquKN arzJ0skV6UPP3VwUPdTcHu8HHzQj0v+ionW4DGZCAhx82n7Q0bNU41HSDiHuXX+2b4 g3kcf/AixoNQheXmUZndNtHWsYedWPzs0f+Wtr1COsv6Xjc8n1JiOgcsYCTk8yRAh0 RBMFqqGrLXiqSAW6RBQ2PuDapa4bhG/6zrqrs36fbCVCupK5oGAV1/fDj1tEJ8yAhZ jWpvBT2Olv+cQ== Received: by pali.im (Postfix) id A1104708; Tue, 21 Feb 2023 21:22:34 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Cc: Stefan Roese , Tony Dinh , Josua Mayer Subject: [PATCH RFC u-boot-mvebu 41/59] tools: kwbimage: Simplify add_secure_header_v1() Date: Tue, 21 Feb 2023 21:19:07 +0100 Message-Id: <20230221201925.9644-42-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230221201925.9644-1-pali@kernel.org> References: <20230221201925.9644-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean To make add_secure_header_v1() function more readable, call it directly with arguments: header pointer with header size and data image pointer with data image size. No functional change. Signed-off-by: Pali Rohár --- tools/kwbimage.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 5f62ed159c4b..857af6a438a4 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1322,16 +1322,14 @@ static int kwb_sign_csk_with_kak(struct image_tool_params *params, return 0; } -static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr, - int payloadsz, size_t headersz, uint8_t *image, +static int add_secure_header_v1(struct image_tool_params *params, uint8_t *image_ptr, + size_t image_size, uint8_t *header_ptr, size_t headersz, struct secure_hdr_v1 *secure_hdr) { struct image_cfg_element *e_jtagdelay; struct image_cfg_element *e_boxid; struct image_cfg_element *e_flashid; RSA *csk = NULL; - unsigned char *image_ptr; - size_t image_size; struct sig_v1 tmp_sig; bool specialized_img = image_get_spezialized_img(); @@ -1357,14 +1355,11 @@ static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr, if (kwb_sign_csk_with_kak(params, secure_hdr, csk)) return 1; - image_ptr = ptr + headersz; - image_size = payloadsz - headersz; - if (kwb_sign_and_verify(csk, image_ptr, image_size, &secure_hdr->imgsig, "image") < 0) return 1; - if (kwb_sign_and_verify(csk, image, headersz, &tmp_sig, "header") < 0) + if (kwb_sign_and_verify(csk, header_ptr, headersz, &tmp_sig, "header") < 0) return 1; secure_hdr->hdrsig = tmp_sig; @@ -1533,8 +1528,8 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, &datai, delay); } - if (secure_hdr && add_secure_header_v1(params, ptr, payloadsz + headersz, - headersz, image, secure_hdr)) + if (secure_hdr && add_secure_header_v1(params, ptr + headersz, payloadsz, + image, headersz, secure_hdr)) return NULL; *imagesz = headersz; -- 2.20.1