[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <12cc5fd9-6537-4a0b-b7d9-1221da3bf9f7@linux.ibm.com>
Date: Tue, 28 May 2024 19:20:56 -0400
From: Stefan Berger <stefanb@...ux.ibm.com>
To: Jarkko Sakkinen <jarkko@...nel.org>,
Herbert Xu <herbert@...dor.apana.org.au>
Cc: linux-integrity@...r.kernel.org, keyrings@...r.kernel.org,
Andreas.Fuchs@...ineon.com, James Prestwood <prestwoj@...il.com>,
David Woodhouse <dwmw2@...radead.org>,
Eric Biggers <ebiggers@...nel.org>,
James Bottomley <James.Bottomley@...senpartnership.com>,
linux-crypto@...r.kernel.org,
Lennart Poettering <lennart@...ttering.net>,
"David S. Miller" <davem@...emloft.net>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v7 1/5] crypto: rsa-pkcs1pad: export rsa1_asn_lookup()
On 5/28/24 17:08, Jarkko Sakkinen wrote:
> 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
piggy-backed
> patch prepares crypto subsystem for the addition of those keys.
>
> Signed-off-by: Jarkko Sakkinen <jarkko@...nel.org>
Reviewed-by: Stefan Berger <stefanb@...ux.ibm.com>
> ---
> 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 <crypto/algapi.h>
> #include <crypto/akcipher.h>
> +#include <crypto/rsa-pkcs1pad.h>
> #include <crypto/internal/akcipher.h>
> #include <crypto/internal/rsa.h>
> #include <linux/err.h>
> @@ -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 */
Powered by blists - more mailing lists