We see the same behaviour on an Intel NUC5i7. I haven't looked at the capabilities reported by the TPM device on that platform. The attached patch (setting max_data_size = MAX_NV_BUFFER_SIZE when max_data_size is reported as 0), sorts the problem out.


Dunk


Duncan Palmer
Senior Software Engineer | Autonomous Systems
Data61 | CSIRO

E duncan.palmer@csiro.au

Queensland Centre for Advanced Technologies (QCAT),

1 Technology Court, Pullenvale QLD, 4069

www.data61.csiro.au


CSIRO’s Digital Productivity business unit and NICTA have joined forces to create digital powerhouse Data61


From: tpm2 <tpm2-bounces@lists.01.org> on behalf of Ian Oliver <ian.justin.oliver@gmail.com>
Sent: 17 April 2018 21:10
To: tpm2@lists.01.org
Subject: [tpm2] NVRAM_write, BUFFER_SIZE is 0
 
Hi,

we're having problems writing to NV_RAM with tpm2_nvwrite. We can define areas but not write

 
$ tpm2_nvlist
0x1800005:
  hash algorithm:
    friendly: sha256
    value: 0xB
  attributes:
    friendly: ownerwrite|policywrite|ownerread|written
    value: 0xA000220
  size: 32

 

 
$ echo -n "hello" | tpm2_nvwrite -x 0x1800005 -a 0x40000001 -V
INFO on line: "135" in file: "tools/tpm2_nvwrite.c": The data(size=0) to be written:
INFO on line: "149" in file: "tools/tpm2_nvwrite.c": Success to write NV area at index 0x1800005 (25165829) offset 0x0.
INFO on line: "135" in file: "tools/tpm2_nvwrite.c": The data(size=0) to be written:
INFO on line: "149" in file: "tools/tpm2_nvwrite.c": Success to write NV area at index 0x1800005 (25165829) offset 0x0.
INFO on line: "135" in file: "tools/tpm2_nvwrite.c": The data(size=0) to be written:
INFO on line: "149" in file: "tools/tpm2_nvwrite.c": Success to write NV area at index 0x1800005 (25165829) offset 0x0.
INFO on line: "135" in file: "tools/tpm2_nvwrite.c": The data(size=0) to be written:
INFO on line: "149" in file: "tools/tpm2_nvwrite.c": Success to write NV area at index 0x1800005 (25165829) offset 0x0.
INFO on line: "135" in file: "tools/tpm2_nvwrite.c": The data(size=0) to be written:
INFO on line: "149" in file: "tools/tpm2_nvwrite.c": Success to write NV area at index 0x1800005 (25165829) offset 0x0.
Which loops infinitely
 
 
Relevant parts of the tpm2-tools and tpm2-tss code:
file: tpm2_nvwrite.c
113     res = tpm2_util_nv_max_buffer_size(sapi_context, &max_data_size);
The call to tpm2_nv_read_public should get the TPM_PT_NV_BUFFER_MAX capability but and store it to max_data_size.
In that part of the code max_data_size gets set to 0 and that causes the loop above.


The TPM_PT_NV_BUFFER_MAX seems not to be defined in the capabilities for this device: Infineon TPM 2.0 9665  as reported by tpm2_cap. 

t.

Ian


--
Dr. Ian Oliver
===============================
Privacy Engineering:  via Amazon
Twitter: @i_j_oliver