Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2645864lqo; Mon, 20 May 2024 11:47:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVG/yOLkCEgCpme5BxnQk1m/gZ1+d/K9F52n7ZBuzZwpQCs5IRO1RKsgclxUEqVIbPvNjGZeE/9Vn3m4FtHoOE9rZN1eSsjogv6iH3SqA== X-Google-Smtp-Source: AGHT+IG7K7fwDd3Z+9jxR3UFg9Portx/NqdPuS3FXClM0ntJfGrEOatrD/1upfhKuH6CUqiVHKUi X-Received: by 2002:a05:6a00:2e02:b0:6ed:4a97:26c1 with SMTP id d2e1a72fcca58-6f69fbe0261mr8795675b3a.10.1716230871018; Mon, 20 May 2024 11:47:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716230871; cv=pass; d=google.com; s=arc-20160816; b=IjtFYe2Zz1e6GxBHqcAmhoh5wbBwAm/2tBXjXDwWCQHSL8GQhJfWnM10HZ3H+k8v9D 6z7KchSuWx5Oai1ooWwwtGF+7/H8YAHJwdSYZE5mYIwBtpdaYiakbjTLVigmf7luADu9 69MMb6JPDl/z0PILaF/FyeuXi6E3MKlOE7tWvtA0N6CF1sWAlV1mEzrfEULmksW996Sr ysKL0s/XHFYi4nU8Bk+CW2TzAGJGAnwxZDrTSBswCCxjvAmytsZ0YoGlFndfUfZbmbb3 fyawA9FQo6bin05gORS8Fr4SWL467kfYOBr8kHAEabBjePLhau/whrHjpCjaJCAe8WMP WzRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=43Sb18VKUhg0R2Kq+8TU0oUqFnZm/9MPZAGvJnbIyCs=; fh=XGatjuj9gWVHuxckzjM0Is3oVe1CydIBbpBUXJu4q+Y=; b=0YnFW69TuBKOVPrjlkqpJqVFuBwNsoTnVufQOWPBWtHQRGTY45M1uYIjx8uLdaHSDv 2l3Bc5vXwt5xoxrNiH6QTttq59aYdmIorbEFoev0dDGqN8fg1CpThG+RSXFoPJnpgjZQ FL0WJoqF+/wi0B75JhJS+8nnPV7N+QoCfusHq7Yw2BgAra0wd1CPD3TZ/XDMfi+8AYIX OlZ/NEm86P7sSgyp17u8DYS1heMGlmyTQrcIecCSAOOKKccemwd8lJIJqd0zkmXV/2cF E6lj+XT82XlbeqSQ1OoGJwQe+gZaSw0l2g+maKirPg3yXW9yiq42ncP6Jixx3zfQbxJF /nSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=azLfIHUr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4269-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b1709dsi22411976b3a.261.2024.05.20.11.47.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 11:47:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=azLfIHUr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4269-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 58276281F22 for ; Mon, 20 May 2024 18:47:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47D68137C2E; Mon, 20 May 2024 18:47:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="azLfIHUr" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F112D28E7; Mon, 20 May 2024 18:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716230860; cv=none; b=jzAfRvj4WZIRwF+O+EFIhpaAEPRh5WLIb+6wbt/cYb8pGfiC44gsWQrvDUibTS9MVt5l92hzYdgL6wMI4dCgELbZtLhR3Xh8rkFOca2O6yjqTO4yB/p2lNNkWuRu0433+SQWdlpD8LjULdBpPdmlJaglZjlH7JXSkD1QHSiRhtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716230860; c=relaxed/simple; bh=rQTPLrmfpCPpQ7Zz53PlLkcw1m7mUahOVVqZUGpxmKU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FVFqwrdBIRsvfk3yIBczqnwRTxYuJP4TuVJYDYYvRvDv/xqCZpckKz2T/8SHhxHZ0JffSr3twMkHLqdy0TqQsa4wI7Bij8bUEeCa4zrLVi3IBpXZUgT3+TCS1t9rICXQ00bz5zACzbbvIRPOUJtpj7jELTUAexhd73zYpZBV2zI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=azLfIHUr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2180CC2BD10; Mon, 20 May 2024 18:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716230859; bh=rQTPLrmfpCPpQ7Zz53PlLkcw1m7mUahOVVqZUGpxmKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=azLfIHUrK0j3/igtwgV6l56nEAGaHF7J0MYCC8C9bEwwJYOnETgOi26Ty29PoWiwb 0PYIclHnvYNsABbTyFnJq5tK66+SIwU0nQ8KOz+d8AgN31s3bDeWBYvgYU3o8jPCJ1 Evad7zQGPbUExQ8yCOyuCbb6R3oZ8a/aAu8S41dcnem7oLqCy+KBTuZbWtMPJp7YcR i+FLHEy/I7qUIO6u7juzeQ0Hd2TqkygQFF/Mwc6sN2RRfo9YiSdfPbPgd4R2HMwYzv +5DlgyEH3NQofBRuEBWSa99lNNkqKRBZLfYlrxOOtgmtfHfJV07mT7JFgAlbh6hB6o wW7AZV0bwGn6g== From: Jarkko Sakkinen To: Herbert Xu Cc: linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, Andreas.Fuchs@infineon.com, James Prestwood , David Woodhouse , Jarkko Sakkinen , "David S. Miller" , linux-crypto@vger.kernel.org (open list:CRYPTO API), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/6] crypto: rsa-pkcs1pad: export rsa1_asn_lookup() Date: Mon, 20 May 2024 21:47:08 +0300 Message-ID: <20240520184727.22038-2-jarkko@kernel.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240520184727.22038-1-jarkko@kernel.org> References: <20240520184727.22038-1-jarkko@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ASN.1 template is required for TPM2 asymmetric keys, as it needs to be piggy-packed with the input data before applying TPM2_RSA_Decrypt. This patch prepares crypto subsystem for the addition of those keys. Signed-off-by: Jarkko Sakkinen --- crypto/rsa-pkcs1pad.c | 16 ++++++++++------ include/crypto/rsa-pkcs1pad.h | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 include/crypto/rsa-pkcs1pad.h diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index cd501195f34a..00b6c14f861c 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -79,11 +80,7 @@ static const u8 rsa_digest_info_sha3_512[] = { 0x05, 0x00, 0x04, 0x40 }; -static const struct rsa_asn1_template { - const char *name; - const u8 *data; - size_t size; -} rsa_asn1_templates[] = { +static const struct rsa_asn1_template rsa_asn1_templates[] = { #define _(X) { #X, rsa_digest_info_##X, sizeof(rsa_digest_info_##X) } _(md5), _(sha1), @@ -101,7 +98,13 @@ static const struct rsa_asn1_template { { NULL } }; -static const struct rsa_asn1_template *rsa_lookup_asn1(const char *name) +/** + * rsa_lookup_asn1() - Lookup the ASN.1 digest info given the hash + * name: hash algorithm name + * + * Returns the ASN.1 digest info on success, and NULL on failure. + */ +const struct rsa_asn1_template *rsa_lookup_asn1(const char *name) { const struct rsa_asn1_template *p; @@ -110,6 +113,7 @@ static const struct rsa_asn1_template *rsa_lookup_asn1(const char *name) return p; return NULL; } +EXPORT_SYMBOL_GPL(rsa_lookup_asn1); struct pkcs1pad_ctx { struct crypto_akcipher *child; diff --git a/include/crypto/rsa-pkcs1pad.h b/include/crypto/rsa-pkcs1pad.h new file mode 100644 index 000000000000..32c7453ff644 --- /dev/null +++ b/include/crypto/rsa-pkcs1pad.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * RSA padding templates. + */ + +#ifndef _CRYPTO_RSA_PKCS1PAD_H +#define _CRYPTO_RSA_PKCS1PAD_H + +/* + * Hash algorithm name to ASN.1 template mapping. + */ +struct rsa_asn1_template { + const char *name; + const u8 *data; + size_t size; +}; + +const struct rsa_asn1_template *rsa_lookup_asn1(const char *name); + +#endif /* _CRYPTO_RSA_PKCS1PAD_H */ -- 2.45.1