From patchwork Tue Jun 9 05:13:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1305575 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=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; 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=fZm+y2jF; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49gyxH6chwz9sRK for ; Tue, 9 Jun 2020 15:15:15 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 263BC8067C; Tue, 9 Jun 2020 07:15:13 +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="fZm+y2jF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EF5D98067C; Tue, 9 Jun 2020 07:15:10 +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 E7B478067C for ; Tue, 9 Jun 2020 07:15:07 +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 d6so875421pjs.3 for ; Mon, 08 Jun 2020 22:15:07 -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=fZm+y2jFi4zSe/pqz5/27prCSCHkHbzbieNWazVsG3vhotnhMvC94XGT0ClBxr8g1S YN6mMlxlRC3XHckjhvGHkiEgO4Lcu+6H5G7qIPKR9kf8uZJ2t5HA/hhSjp8Pyz2oMMfA ZggdD2T8pPIBLaLchdxQ8IAHWgjhVlLPUAyxRBJAET5jRCkcbzoJOGDaPEriJDYNCb1t WlfYNDB6gpgmECRzK1gWkjPybQkl8WGHzj9Swo0bnxdMI1ANXf7+ZTm5sIfi8IUai7Pp 1JEsp22yCWqOq/tp6JA3hqi4thV9ZIa2wF4fc2XkQ33pLHu7jM25PiiOfE/EFpM32HaO KhXA== 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=pYHFA8zb1R3s38rtIYQJmVWaEzhESlQ4Fur3BLGRqLQjWyleHMYD5j/e+OJPUT14xh s8vG4di8hY1ZJ7Wtv+IKQzFntN7dzO5J45rnI08IV6Z+8EL2Eo5Ji8zQ2xOnQQxTmZS+ BXRSdNOobaM4twuoI/zgPvxHbQBHdnMOrFlKcOHbyJcTC2Q7PWzIZmEScC0YP6VvEpmN 7VvYwqHBYP4ynDc5yWvFWA/Bg0ENzr4WbGirle1iKM/5d9cztt8BHScAHm+nRRtI79eM Cz6W0w54k1dzJqPXMxNusnmAXKjEs47VJoeB68X8hLRj5oYcpuwiGW1C+pSdSplLSiGF Rb6A== X-Gm-Message-State: AOAM533oBft4ZNGQ+Q1VCRvoXJU2b0MF1J4iL+GNxVMkOVgOX4e5WwrY p3GY/DBYcZmh8Id4dDBo1/eREQ== X-Google-Smtp-Source: ABdhPJyfRLNJtq+uKM/qanM3Up5afTd0wlHO+hLXfO/mkHNwNEVt4jH2qS/IeCZmEoX20S0tadP/bA== X-Received: by 2002:a17:90a:69c3:: with SMTP id s61mr2869246pjj.212.1591679706294; Mon, 08 Jun 2020 22:15:06 -0700 (PDT) Received: from localhost.localdomain (p6e421564.tkyea130.ap.so-net.ne.jp. [110.66.21.100]) by smtp.gmail.com with ESMTPSA id r34sm7289362pgl.38.2020.06.08.22.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2020 22:15:05 -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 1/8] lib: rsa: export rsa_verify_with_pkey() Date: Tue, 9 Jun 2020 14:13:54 +0900 Message-Id: <20200609051401.18192-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200609051401.18192-1-takahiro.akashi@linaro.org> References: <20200609051401.18192-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 --- 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; }