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 83F66C352A1 for ; Tue, 6 Dec 2022 18:51:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 770D284494; Tue, 6 Dec 2022 19:51:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com 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=konsulko.com header.i=@konsulko.com header.b="aWcSZxNx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1136984BD1; Tue, 6 Dec 2022 19:51:28 +0100 (CET) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (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 CA91582F69 for ; Tue, 6 Dec 2022 19:51:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-wr1-x42a.google.com with SMTP id h11so24766788wrw.13 for ; Tue, 06 Dec 2022 10:51:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1uieg1MK0lpNZIxAP5VHE6xe33JMBOK65pWRExxnCJw=; b=aWcSZxNxdwCH2eUejttqOojIIZChU4dHpQI2NaR2mRlQeSn7+8mCD9IGWObL4L2uGG 7Tm41nlHfdOuZkuJGQlnCy9/KBBabmq5lwdEZkBlLs/dUzW8oogqtbrg9yzkXJ3b3rrQ AouTG73UdWiWgoL6qHLsK/Iom9BFQJijNK0Xs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1uieg1MK0lpNZIxAP5VHE6xe33JMBOK65pWRExxnCJw=; b=PT2WEeYY3B21/caTATECEReqTGOvbENdzSdMxjyLmBKIDJwxgTb/vsDAMF5FEKPbR0 7l+k1wB6NUzgRg78To3RW5Sz1E/pcZIzbiwRVGDh8O/2kNW+kNOM3XdEBomGD08sYB2u 4HPIVMUbbRnBhaKnMbLRea5KSZOmzzArm35i69fVgSalFKfxh/PKum/4GsdbL7ZFNv8F f79cqTisB/fXseLhV4scDhRnX1ksgmqO5HErPRq6wyjXG3TbeQJqtgmgRMajBL65vl1E xFWCdAmY/9xoVpjxdz7IbOVaw8QdLXgPEE13O9gTPQabvgtSg2e8gLPSB+tKk9ixQxEW Vkeg== X-Gm-Message-State: ANoB5pl/MkEyrXAbff3naCPnO7BAGgSMY75ZnRG8wr32m5033VhebJMN ltY2Cv9EaR6HVvOTnUEHDmCodn8oCnJsSIhn X-Google-Smtp-Source: AA0mqf6cEQKk39gGrkIjBVJSpOshEaIFpczknFpRwz3FA1AhvBwfTHptmVxmvaGCAKNPQ6tCU0Sw3g== X-Received: by 2002:a5d:4a8c:0:b0:242:165e:7a79 with SMTP id o12-20020a5d4a8c000000b00242165e7a79mr24715632wrq.343.1670352685145; Tue, 06 Dec 2022 10:51:25 -0800 (PST) Received: from bill-the-cat.lan (2603-6081-7b00-6400-40ab-ff29-04a6-7f8f.res6.spectrum.com. [2603:6081:7b00:6400:40ab:ff29:4a6:7f8f]) by smtp.gmail.com with ESMTPSA id s17-20020a5d5111000000b0022584c82c80sm17529498wrt.19.2022.12.06.10.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 10:51:24 -0800 (PST) From: Tom Rini To: u-boot@lists.denx.de Cc: AKASHI Takahiro , Simon Glass Subject: [PATCHv3 010/149] rsa-verify: Rework host check for CONFIG_RSA_VERIFY_WITH_PKEY Date: Tue, 6 Dec 2022 13:51:21 -0500 Message-Id: <20221206185121.3157214-1-trini@konsulko.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221204223706.176996-1-trini@konsulko.com> References: <20221204223706.176996-1-trini@konsulko.com> MIME-Version: 1.0 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 While we do not want to use CONFIG_RSA_VERIFY_WITH_PKEY on the host, we cannot undef the symbol in this manner. As this ends up being a test within another function we can use !tools_build() as a test here. Cc: AKASHI Takahiro Cc: Simon Glass Signed-off-by: Tom Rini --- Changes in v3: - Move comment, per Akashi-san Changes in v2: - Switch to !tools_build() per Simon --- lib/rsa/rsa-verify.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 9605c376390a..2f3b34403913 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -23,18 +23,6 @@ #include #include -#ifndef __UBOOT__ -/* - * NOTE: - * Since host tools, like mkimage, make use of openssl library for - * RSA encryption, rsa_verify_with_pkey()/rsa_gen_key_prop() are - * of no use and should not be compiled in. - * So just turn off CONFIG_RSA_VERIFY_WITH_PKEY. - */ - -#undef CONFIG_RSA_VERIFY_WITH_PKEY -#endif - /* Default public exponent for backward compatibility */ #define RSA_DEFAULT_PUBEXP 65537 @@ -506,7 +494,13 @@ int rsa_verify_hash(struct image_sign_info *info, { int ret = -EACCES; - if (CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { + /* + * Since host tools, like mkimage, make use of openssl library for + * RSA encryption, rsa_verify_with_pkey()/rsa_gen_key_prop() are + * of no use and should not be compiled in. + */ + if (!tools_build() && CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) && + !info->fdt_blob) { /* don't rely on fdt properties */ ret = rsa_verify_with_pkey(info, hash, sig, sig_len); if (ret) -- 2.25.1