Re: [PATCH v6 02/12] tpm-buf: add handling for TPM2B types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2019-09-20 at 17:18 +0300, Jarkko Sakkinen wrote:
> On Mon, Sep 09, 2019 at 01:18:35PM +0100, James Bottomley wrote:
> > Most complex TPM commands require appending TPM2B buffers to the
> > command body.  Since TPM2B types are essentially variable size
> > arrays,it makes it impossible to represent these complex command
> > arguments as structures and we simply have to build them up using
> > append primitives like these.
> > 
> > Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.c
> > om>
> 
> I think a better idea would be to have headerless TPM buffers

I thought about that.  The main problem is that most of the
construct/append functions use the header, and these are the functions
most useful to the TPM2B operation.

The other thing that argues against this is that the TPM2B case would
save nothing if we eliminated the header, because we allocate a page
for all the data regardless.

>  and also it makes sense to have a separate length field in the
> struct to keep the code sane given that sometimes the buffer does not
> store the length.

I'm really not sure about that one.  The header length has to be filled
in for the non-TPM2B case but right at the moment we have no finish
function for the buf where it could be, so we'd end up having to
maintain two lengths in every update operation on non-TPM2B buffers. 
That seems inefficient and the only slight efficiency we get in the
TPM2B case is not having to do the big endian conversion from the
header which doesn't seem to be worth the added complexity.

James

> E.g.
> 
> enum tpm_buf_flags {
> 	TPM_BUF_OVERFLOW	= BIT(0),
> 	TPM_BUF_HEADERLESS	= BIT(1),
> };
> 
> struct tpm_buf {
> 	unsigned int length;
> 	struct page *data_page;
> 	unsigned int flags;
> 	u8 *data;
> };
> 
> /Jarkko
> 




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux