[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D1FMVEJWGLEW.14QGHPAYPHQG1@kernel.org>
Date: Wed, 22 May 2024 00:17:13 +0300
From: "Jarkko Sakkinen" <jarkko@...nel.org>
To: "James Bottomley" <James.Bottomley@...senPartnership.com>, "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>, "David S. Miller" <davem@...emloft.net>, "open
list:CRYPTO API" <linux-crypto@...r.kernel.org>, "open list"
<linux-kernel@...r.kernel.org>, "Peter Huewe" <peterhuewe@....de>, "Jason
Gunthorpe" <jgg@...pe.ca>, "Mimi Zohar" <zohar@...ux.ibm.com>, "David
Howells" <dhowells@...hat.com>, "Paul Moore" <paul@...l-moore.com>, "James
Morris" <jmorris@...ei.org>, "Serge E. Hallyn" <serge@...lyn.com>, "open
list:SECURITY SUBSYSTEM" <linux-security-module@...r.kernel.org>
Subject: Re: [PATCH v2 4/6] KEYS: trusted: Move tpm2_key_decode() to the TPM
driver
On Tue May 21, 2024 at 9:18 PM EEST, James Bottomley wrote:
> On Tue, 2024-05-21 at 06:16 +0300, Jarkko Sakkinen wrote:
> [...]
> > diff --git a/include/crypto/tpm2_key.h b/include/crypto/tpm2_key.h
> > new file mode 100644
> > index 000000000000..acf41b2e0c92
> > --- /dev/null
> > +++ b/include/crypto/tpm2_key.h
> > @@ -0,0 +1,33 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +#ifndef __LINUX_TPM2_KEY_H__
> > +#define __LINUX_TPM2_KEY_H__
> > +
> > +#include <linux/slab.h>
> > +
> > +/*
> > + * TPM2 ASN.1 key
> > + */
> > +struct tpm2_key {
> > + u32 parent;
> > + const u8 *blob;
> > + u32 blob_len;
> > + const u8 *pub;
> > + u32 pub_len;
> > + const u8 *priv;
> > + u32 priv_len;
> > +};
> > +
> > +int tpm2_key_decode(const u8 *src, u32 src_len, struct tpm2_key
> > *key,
> > + u32 max_key_len);
>
> I don't think this is a good idea. Trusted keys already have a pre-
> defined max payload size (MAX_BLOB_SIZE in include/keys/trusted-type.h)
> and I've already had to increase this several times because once you
> get policy attached to a key, it can get pretty big (over a page).
> Exactly the same thing will happen to asymmetric keys as well, so it
> does make sense that they share the same maximum (probably in a more
> generic header, though).
ECDSA and RSA have different space requirements. With that solution you
actually max out space requirements given same cap for everything.
Even tpm2_key_ecdsa should use a different value than tpm2_key_rsa to
save memory.
> Since the code already right sizes the allocation and all we check with
> this is whether it's over a pre-defined maximum, it's way easier if
> that maximum is defined in a header rather than passed in in several
> places making increasing the maximum really hard because you have to
> chase all the threading.
You don't save a single byte of memory with any constant that dictates
the size requirements for multiple modules in two disjoint subsystems.
You are maximizing the use of memory.
> James
BR, Jarkko
Powered by blists - more mailing lists