From patchwork Tue Jun 16 05:26:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1309993 X-Patchwork-Delegate: xypron.glpk@gmx.de 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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=r+r3mypZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49mGv80vT7z9sSc for ; Tue, 16 Jun 2020 15:28:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 219E181EA9; Tue, 16 Jun 2020 07:28:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="r+r3mypZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CD1CB81EAF; Tue, 16 Jun 2020 07:28:13 +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,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) (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 8041F81E92 for ; Tue, 16 Jun 2020 07:28:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1044.google.com with SMTP id i12so917297pju.3 for ; Mon, 15 Jun 2020 22:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PhxnimSgiKDE4d+ss2+jFRxlXs+ihR700KFrqkbt7JA=; b=r+r3mypZqqqs1x+smuaVhax7DmErIpTx0DSNiuza9iz4mtFVtZIka+dTHpSTH1PNa5 feMtWDY4/d1CMtLHHGupE7SbTT5Ns3aaCemJ0ko48s5pGi0sifGX2l9zKXDwLwkgTDUJ bNpwVo+v2ApuUb1Flo9XrvLQoDkKlN+lkL/HQ/kKfBJwkBVViBiTDuIA7XFXODSziARc v9i+UmL2HC3CG8bMakCYQVjruWPfHtWjO6IRL7EpExBHR0hSL21NnbSUV0IDqkqHBKsX 99NFh2kz1i3EYoqeQYmGdEV/h8FYeNaT63N4duCP+OX7+MA6TLVAESct/EyK+v0gi90c 9AUw== 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=PhxnimSgiKDE4d+ss2+jFRxlXs+ihR700KFrqkbt7JA=; b=Wd31vEQis3mdnJBvDFim92/pSVYlBNfIm18M/8Nd/eMw4vbGOVcxWeJmiiRK3xNG+2 z+MtfFFSvclPYvHpuV8OFN7KYl2vHdGQ8i5Go5Lu3rVheo7PvBDgDT0ccu1ErI+YKubK k3W+/RTssPeKSfkKg0ijTKEK1B1L3RUOLgg86zCgOTNzm5AavldLmSQ2TwTXwtHkXayg IA3zNC+4NzYV9UsCtXxeEgpF0MWnYV/pS6RBiMiRR+tHE6cn1oaZf9pcBR23C8qjy7VY L7S5gr0sawKaiLIAy6bQk4h6yU6m1X6wLPSA9aK53j4A5wuiU4ovzjNrFjTzXdACrsei k0WQ== X-Gm-Message-State: AOAM533GqbfnVBss1h/fXnYc8CzAp/uk+537TPiC87WvE6LZA/tPBHTm CVx7fNr77BP6X2AUw0sMehXk8w== X-Google-Smtp-Source: ABdhPJzBiLPi7jTkhpygOoQQj0M2K3bv8GUH8mJGgzWmRfPcRJhmxlH09rWJFtmwbIx3s17RLeqq+Q== X-Received: by 2002:a17:90b:e89:: with SMTP id fv9mr1112006pjb.131.1592285282304; Mon, 15 Jun 2020 22:28:02 -0700 (PDT) Received: from localhost.localdomain (p6e421564.tkyea130.ap.so-net.ne.jp. [110.66.21.100]) by smtp.gmail.com with ESMTPSA id ds11sm1080789pjb.0.2020.06.15.22.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 22:28:01 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Cc: sughosh.ganu@linaro.org, mail@patrick-wildt.de, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 1/8] lib: rsa: export rsa_verify_with_pkey() Date: Tue, 16 Jun 2020 14:26:48 +0900 Message-Id: <20200616052655.4845-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616052655.4845-1-takahiro.akashi@linaro.org> References: <20200616052655.4845-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean This function will be used to implement public_key_verify_signature() in a later patch. rsa_verify() is not suitable here because calculation of message digest is not necessary. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- include/u-boot/rsa.h | 3 +++ lib/rsa/rsa-verify.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/u-boot/rsa.h b/include/u-boot/rsa.h index 2d3024d8b710..eab6bfafa476 100644 --- a/include/u-boot/rsa.h +++ b/include/u-boot/rsa.h @@ -98,6 +98,9 @@ int rsa_verify(struct image_sign_info *info, const struct image_region region[], int region_count, uint8_t *sig, uint sig_len); +int rsa_verify_with_pkey(struct image_sign_info *info, + const void *hash, uint8_t *sig, uint sig_len); + int padding_pkcs_15_verify(struct image_sign_info *info, uint8_t *msg, int msg_len, const uint8_t *hash, int hash_len); diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 1d55b997e34c..d0e863f9b0f8 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -374,8 +374,8 @@ static int rsa_verify_key(struct image_sign_info *info, * * Return 0 if verified, -ve on error */ -static int rsa_verify_with_pkey(struct image_sign_info *info, - const void *hash, uint8_t *sig, uint sig_len) +int rsa_verify_with_pkey(struct image_sign_info *info, + const void *hash, uint8_t *sig, uint sig_len) { struct key_prop *prop; int ret; @@ -395,8 +395,8 @@ static int rsa_verify_with_pkey(struct image_sign_info *info, return ret; } #else -static int rsa_verify_with_pkey(struct image_sign_info *info, - const void *hash, uint8_t *sig, uint sig_len) +int rsa_verify_with_pkey(struct image_sign_info *info, + const void *hash, uint8_t *sig, uint sig_len) { return -EACCES; }