Skip to content

Commit

Permalink
test_esapi: use tr_from_tpmpublic with NV index
Browse files Browse the repository at this point in the history
In order to read a NV index from a "TPM index", the function
`tr_from_tpmpublic` needs to be used first. Add such a use-case in the
test suite.

This was discussed in tpm2-software#298.

Signed-off-by: Nicolas Iooss <[email protected]>
  • Loading branch information
niooss-ledger committed Jan 6, 2022
1 parent e8f85e0 commit b1f7f1f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/test_esapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ def test_plain_nv_define_write_read_undefine(self):
self.assertEqual(len(n), 68)
self.assertTrue(isinstance(n, str))

# Read the NV index using tr_from_tpmpublic
nv_handle = self.ectx.tr_from_tpmpublic(TPM2_HC.NV_INDEX_FIRST)
public_2, name_2 = self.ectx.nv_read_public(nv_handle)
self.assertEqual(public_2.marshal(), public.marshal())
self.assertEqual(name_2, name)
value = self.ectx.nv_read(nv_handle, 11)
self.assertEqual(bytes(value), b"hello world")
self.ectx.tr_close(nv_handle)
with self.assertRaises(TSS2_Exception):
self.ectx.nv_read_public(nv_handle)

self.ectx.nv_undefine_space(nv_index)

with self.assertRaises(TSS2_Exception):
Expand Down

0 comments on commit b1f7f1f

Please sign in to comment.