[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZmLnyp9j_QoPgj7W@gondor.apana.org.au>
Date: Fri, 7 Jun 2024 18:58:18 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Jarkko Sakkinen <jarkko@...nel.org>
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, Stefan Berger <stefanb@...ux.ibm.com>,
Lennart Poettering <lennart@...ttering.net>,
"David S. Miller" <davem@...emloft.net>,
open list <linux-kernel@...r.kernel.org>,
David Howells <dhowells@...hat.com>,
Ard Biesheuvel <ardb@...nel.org>,
Mario Limonciello <mario.limonciello@....com>
Subject: Re: [PATCH v7 4/5] keys: asymmetric: Add tpm2_key_rsa
On Wed, May 29, 2024 at 12:08:09AM +0300, Jarkko Sakkinen wrote:
>
> +/*
> + * Sign operation is an encryption using the TPM's private key. With RSA the
> + * only difference between encryption and decryption is where the padding goes.
> + * Since own padding can be used, TPM2_RSA_Decrypt can be repurposed to do
> + * encryption.
> + */
> +static int tpm2_key_rsa_sign(struct tpm_chip *chip, struct tpm2_key *key,
> + struct kernel_pkey_params *params,
> + const void *in, void *out)
> +{
> + const off_t o = key->priv_len + 2 + sizeof(*key->desc);
> + const struct tpm2_rsa_parms *p =
> + (const struct tpm2_rsa_parms *)&key->data[o];
> + const u16 mod_size = be16_to_cpu(p->modulus_size);
> + const struct rsa_asn1_template *asn1;
> + u32 in_len = params->in_len;
> + void *asn1_wrapped = NULL;
> + u8 *padded;
> + int ret;
> +
> + if (strcmp(params->encoding, "pkcs1") != 0) {
> + ret = -ENOPKG;
> + goto err;
> + }
> +
> + if (params->hash_algo) {
> + asn1 = rsa_lookup_asn1(params->hash_algo);
Could you please explain why this can't be done through pkcs1pad
instead of going to raw RSA?
Thanks,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists