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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 741F9C04FF3 for ; Mon, 24 May 2021 20:21:34 +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 EF4B261378 for ; Mon, 24 May 2021 20:21:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF4B261378 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 6CC0F82F05; Mon, 24 May 2021 22:20:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="WpI6oqcA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6617082EE4; Mon, 24 May 2021 22:19:55 +0200 (CEST) Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) (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 619DB82EC9 for ; Mon, 24 May 2021 22:19:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-ot1-x329.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso15778911otu.10 for ; Mon, 24 May 2021 13:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NrgMxSmmUHI7Bau14QUwLRiPP08ohqkwFlFCHSf0oCE=; b=WpI6oqcAQ5k/NdBCPj+ECK1F+c7AJ6RlyahYoTv9ZhX6cfmrDT6CDkUfFo4v8LX2l5 ul2iooIbYf5Uoc3QlmkHaVp/PT1Mdz/52VorRdEW1XCD6Z9tg5v5JE7+lMEz0pmNmFKb lxzdJUrvJNZaB5H96Zu+XV3VQBWDOdAhXWTPGUs6a+uCAzI/jyhN218ItX947AczLPnH VbIgyeF+CbZC+e3GmYr74r1uyAouUteKx/cr/lI5UcqGH/eBTNO0uryEGFnrmtxX5Wij UMpRiGZKnYMq9FLBlOn5ykoavf91wK2wZX62nSakaPRLBSP0ciKHg8Ghl9LNa8dRNg1W DQgg== 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=NrgMxSmmUHI7Bau14QUwLRiPP08ohqkwFlFCHSf0oCE=; b=ua8ngV53tY2xTSeuVXMtQOJiRY6cdHcbWZlUE5s8qaHDaS8ccD7NvfLnQslbCc8Id+ zzmoNobL8rv2I9BmlPD+J+QCxtkgQjRQeBzv4vM0JCX2YnyIEVmR1ALVFwcGqtj/e/U/ vgySE6FlwfcAxm06IHihyvM0a4QDPn6qFios/eMMjEXxkrNcaV4/Qk3LHiyPmg/zs4Ut lIITowA733CWSARYHPGyxStdri1TksVtRWB5waaW1gnuMHNOo+BNKxd/YVzUcupVRSia QGPZoNoMcWEpwbOEnx62nIxx4Xd/j7cAZob5gzf3g723TlxviaDCkjrSW6MNXbIxoMLm aTKQ== X-Gm-Message-State: AOAM532+oEQ33SCUmX4s41CiskTZRYRkolw7cOT7aZL/V6pejaxJDcBa 2quLmB3CItFQj7iPZ/d77tLEBE4cRynC4A== X-Google-Smtp-Source: ABdhPJyYCJ7YL3tbgo1HISSC+v/KeREqJkMtBZudaNXLcn0fLFHEnw9Jc29qiCej97N1bFCcQAmPVg== X-Received: by 2002:a9d:57cd:: with SMTP id q13mr20025561oti.23.1621887589988; Mon, 24 May 2021 13:19:49 -0700 (PDT) Received: from nuclearis3.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id w13sm2816338otp.10.2021.05.24.13.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 13:19:49 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de, sjg@chromium.org Cc: Alexandru Gagniuc , trini@konsulko.com, michal.simek@xilinx.com, rasmus.villemoes@prevas.dk Subject: [PATCH v2 11/18] image: Add support for placing crypto_algo in linker lists Date: Mon, 24 May 2021 15:19:32 -0500 Message-Id: <20210524201939.1491676-12-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524201939.1491676-1-mr.nuke.me@gmail.com> References: <20210524201939.1491676-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.102.4 at phobos.denx.de X-Virus-Status: Clean The purpose of this change is to enable crypto algorithms to be placed in linker lists, rather than be declared as a static array. The goal is to remove the crypto_algos array in a subsequent patch. Create a new linker list named "cryptos", and search it when image_get_crypto_algo() is invoked. NOTE that adding support for manual relocation of crypto_algos within linker lists is beyond the scope of this patch. Signed-off-by: Alexandru Gagniuc Reviewed-by: Simon Glass --- common/image-sig.c | 9 +++++++++ include/image.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/common/image-sig.c b/common/image-sig.c index 5e2d171975..81a3b739fe 100644 --- a/common/image-sig.c +++ b/common/image-sig.c @@ -107,6 +107,7 @@ struct checksum_algo *image_get_checksum_algo(const char *full_name) struct crypto_algo *image_get_crypto_algo(const char *full_name) { + struct crypto_algo *crypto, *end; int i; const char *name; @@ -133,6 +134,14 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name) return &crypto_algos[i]; } + crypto = ll_entry_start(struct crypto_algo, cryptos); + end = ll_entry_end(struct crypto_algo, cryptos); + for (; crypto < end; crypto++) { + if (!strcmp(crypto->name, name)) + return crypto; + } + + /* Not found */ return NULL; } diff --git a/include/image.h b/include/image.h index dbb24993f1..f7f8f8a029 100644 --- a/include/image.h +++ b/include/image.h @@ -47,6 +47,7 @@ struct fdt_region; #include #include #include +#include /* Take notice of the 'ignore' property for hashes */ #define IMAGE_ENABLE_IGNORE 1 @@ -1328,6 +1329,10 @@ struct crypto_algo { uint8_t *sig, uint sig_len); }; +/* Declare a new U-Boot crypto algorithm handler */ +#define U_BOOT_CRYPTO_ALGO(__name) \ +ll_entry_declare(struct crypto_algo, __name, cryptos) + struct padding_algo { const char *name; int (*verify)(struct image_sign_info *info, -- 2.31.1