From patchwork Mon May 17 16:38:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Gagniuc X-Patchwork-Id: 1479657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=lo6YMguE; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkPwX4YZZz9sWW for ; Tue, 18 May 2021 02:39:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3492082C9B; Mon, 17 May 2021 18:38:52 +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="lo6YMguE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9821082B91; Mon, 17 May 2021 18:38:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) (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 67FCE80202 for ; Mon, 17 May 2021 18:38:44 +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-x333.google.com with SMTP id t10-20020a05683022eab0290304ed8bc759so6061460otc.12 for ; Mon, 17 May 2021 09:38:44 -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:mime-version :content-transfer-encoding; bh=JqEASwY2qT4G/lsFYUqafHZRpre28MRCVxkZP52koLc=; b=lo6YMguE1QJ2SS847NqkjQAAvxkxX5MxsvkrbPZ43PPs+00jtLruuRhBhx23J3BlUM DBQmIma/TKawv6rQ/h8ba/6eb3oatO5oTz1VNM1pYQJZRdJMyV9M5VyLNwRTl/yfc3S9 qrNffd5MPdPxYI+Z5ph3Ed/nX99Zz84KkZUnpp8wC0v89D0AZbtDBxPHeyrh5owlUGKV Sigvhsxrn7ASPNiwy6GSdHXtteTbSK/t+7WO+cmQngQXuSnzD38SdFjsXI21wHzBeq29 hf5E90K7ZfY8EU1WIKoTXqHdNb0eHUqiuV42MLnkNzgX74ciWMpLqH65xp35f+gv5g57 fx/w== 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:mime-version :content-transfer-encoding; bh=JqEASwY2qT4G/lsFYUqafHZRpre28MRCVxkZP52koLc=; b=gJ74EoTBXnth86NwDKPiSFrKfgd+NCP7bteUJHvFug3nqOxn0PMUCKCwwb2YgZa5WB n0Y/Y+5Vlpk/C6E36t1+wTm6Jid9mncS7iV6vRcBiAyzaVqWazbteUxBOIkKCVWS2LXH ZNV0VI4HgaE7N2xWlR+8JFyzbyJvNvB/+dxASOD70T7Nk1RsqFlii8BjCYOEAjMupBKe IKlLlI624xmwyL8WYrUqc+pwDC4DuqqbDPWKFU1pZ1oNHuVEuQ0zvlzzAzOH7OGqlyYa ufsXUjMDNZO7G7H2lpI+2RV14m8uGfzw2W2TyL2aL0DTqeuE0MN3Z/FiwFc97kGncd+A QQBA== X-Gm-Message-State: AOAM533yATN/mnmSkSu8TLHEzaJsJuE7RnQcxJ7o20sCiqxC5Lt+xT2X ElGKKXcmrcFlmok/wN7Y9zloTcneXdC4lw== X-Google-Smtp-Source: ABdhPJzhrOQrLkOgiCkNK24Sqh7QEIehhTr1/bABep6QxUFsd+dIgi+I7uVvVNda9I0ZUmBNbd9i6A== X-Received: by 2002:a05:6830:13c4:: with SMTP id e4mr325332otq.315.1621269522596; Mon, 17 May 2021 09:38:42 -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 64sm3103152oob.12.2021.05.17.09.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 09:38:42 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de, sjg@chromium.org Cc: Alexandru Gagniuc , trini@konsulko.com Subject: [PATCH 00/18] image: Reduce #ifdef abuse in image code Date: Mon, 17 May 2021 11:38:22 -0500 Message-Id: <20210517163840.839097-1-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 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 This is a combination of select patches from Simon's series: "image: Reduce #ifdefs and ad-hoc defines in image code" and alternative solutions I proposed in: "image: Reduce the abuse of #ifdefs in image-sig.c" After syncing with Simon, we agree that this is a reasonable base for further work in #ifdef reduction. Rather than describing changes from Simon's series or mine, we present this series de novo. Most patches are already peer-reviewed. The latest patch in this series is optional: 'image: Add support for relocating crypto_algos in linker lists" I don't have a way to test it, and I don't know if it's still needed. I have included it for completeness. Alexandru Gagniuc (10): common: Move host-only logic in image-sig.c to separate file common: image-sig.c: Remove host-specific logic and #ifdefs image: Add support for placing crypto_algo in linker lists image: rsa: Move verification algorithm to a linker list image: image-sig.c: Remove crypto_algos array lib: ecdsa: Remove #ifdefs from ecdsa.h lib: rsa: Remove #ifdefs from rsa.h image: Eliminate IMAGE_ENABLE_VERIFY macro image: Eliminate IMAGE_ENABLE_VERIFY_ECDSA macro [UNTESTED] image: Add support for relocating crypto_algos in linker lists Simon Glass (8): image: Shorten FIT_ENABLE_SHAxxx_SUPPORT image: Rename SPL_SHAxxx_SUPPORT to SPL_FIT_SHAxxx image: Rename CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT Kconfig: Rename SPL_CRC32_SUPPORT to SPL_CRC32 Kconfig: Rename SPL_MD5_SUPPORT to SPL_MD5 image: Drop IMAGE_ENABLE_SHA1 image: Drop IMAGE_ENABLE_SHAxxx image: Drop IMAGE_ENABLE_BEST_MATCH common/Kconfig.boot | 8 +- common/image-fit.c | 10 +- common/image-sig.c | 75 +++--------- common/spl/Kconfig | 14 +-- configs/axm_defconfig | 2 +- configs/bcm963158_ram_defconfig | 2 +- configs/chromebit_mickey_defconfig | 2 +- configs/chromebook_jerry_defconfig | 2 +- configs/chromebook_minnie_defconfig | 2 +- configs/chromebook_speedy_defconfig | 2 +- configs/evb-px30_defconfig | 2 +- configs/firefly-px30_defconfig | 2 +- configs/imxrt1020-evk_defconfig | 2 +- configs/imxrt1050-evk_defconfig | 2 +- configs/mt8516_pumpkin_defconfig | 2 +- configs/odroid-go2_defconfig | 2 +- configs/px30-core-ctouch2-px30_defconfig | 2 +- configs/px30-core-edimm2.2-px30_defconfig | 2 +- configs/sandbox_defconfig | 2 +- configs/socfpga_agilex_atf_defconfig | 2 +- configs/socfpga_agilex_vab_defconfig | 2 +- configs/socfpga_stratix10_atf_defconfig | 2 +- configs/taurus_defconfig | 2 +- include/image.h | 59 ++-------- include/u-boot/ecdsa.h | 25 ---- include/u-boot/rsa.h | 51 +-------- lib/rsa/rsa-sign.c | 4 +- lib/rsa/rsa-verify.c | 18 ++- tools/Makefile | 5 +- tools/image-sig-host.c | 133 ++++++++++++++++++++++ 30 files changed, 220 insertions(+), 220 deletions(-) create mode 100644 tools/image-sig-host.c