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 X-Spam-Level: X-Spam-Status: No, score=-15.7 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,URIBL_BLOCKED,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 4BB8AC12002 for ; Wed, 14 Jul 2021 22:08:20 +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 B534D613C2 for ; Wed, 14 Jul 2021 22:08:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B534D613C2 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 AB59C82C93; Thu, 15 Jul 2021 00:07:41 +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="ASrbFdF0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 47A3182903; Thu, 15 Jul 2021 00:06:14 +0200 (CEST) Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) (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 D46C582979 for ; Thu, 15 Jul 2021 00:06:03 +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-x32f.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso4085602otu.10 for ; Wed, 14 Jul 2021 15:06:03 -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=Bz2g0w9Ba0ItpFEUEW+cnAQcH/mAWdQ0CIzkIU/aiF8=; b=ASrbFdF0D367c1kV4LnC4H+MP3Rd+6DAedKYjYLJA6XPQtjHIWgqRZejbNHE79wYU0 FGnaR2md9QvsSm1whTJy69IqWXC3+NYbCymSTztoR0JScHi0VgSSsy/FLNVU6fBRoZsf UEkNd05jVv/wHlitPt7ZozAJDiT2QvuHMhV+lVPu8fiGaFuCbBBHD3V2mdTBIlyCoRsg fwFySYCTR+cIIIr2nItCwCDATYCV4KXa9ywbbpKTapxF+1nglrOWm3JejCnzKXvYheqr 4rl9hvu1I+foZtL0vSKxITnYCGOM5u0Wx2XvMmJT0+MZUaXJmX7LCIr9KBVxuun17t/N b2KA== 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=Bz2g0w9Ba0ItpFEUEW+cnAQcH/mAWdQ0CIzkIU/aiF8=; b=ngKSFt9mmYglefb4sUAhnfDCyeuCKjaZ1VwnA6FB2su4pqmjNg9HJJdbIYw2f9J6fZ NYWMMm+2NelVSJPyLcy921qG/g+e6g8LFDN7GY+Nl7Qx57GK6SzWZriawNp/XnlvJcsa ILBzXm23boNYlCfmY+x5psj9xv9ENkLISO/kVbK6du0dSZKK3qDXZBrrPh+KdnHnvq/r WW/G3frFWC5O05zSPMRAYg6NSTbepMiTkgoDFmdS0JV6n+OrKqJKj6SxUrgvgoQN7QuQ Gs+3sG3a+adUdcveDYzJNVk9YFlUMHd2bee7MYnG2kjOpOstIHyBpVERPrb8BAxq6zqi 29ZA== X-Gm-Message-State: AOAM533UgKWG3/OHER4LOPUv6deeIO6DwNhtgKFpy5Gy0keeXt6QeDNJ hGP05xJMGPvGaOR7W3eNSGVLEjZbsZs= X-Google-Smtp-Source: ABdhPJyZz5Whkg/NaWfc6Ns8PxHObnhci/b8EtyK6xp0MMGgxRepXg+hjwaBpK8vZ25/uX+KoRnAbg== X-Received: by 2002:a9d:3406:: with SMTP id v6mr256629otb.347.1626300362120; Wed, 14 Jul 2021 15:06:02 -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 w64sm687278otb.45.2021.07.14.15.06.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 15:06:01 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de, trini@konsulko.com Cc: Alexandru Gagniuc , Simon Glass Subject: [PATCH v3 11/19] image: Add support for placing crypto_algo in linker lists Date: Wed, 14 Jul 2021 17:05:39 -0500 Message-Id: <20210714220547.170371-12-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210714211138.GA25256@bill-the-cat> References: <20210714211138.GA25256@bill-the-cat> 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.103.2 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 8b420f2c02..d4c453428c 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