[tpm2] Re: Lifecycle of handles and contexts

Roberts, William C <william.c.roberts at intel.com> Mon, 25 Jul 2022 18:56:59 +0000
Newsgroups dev.linux.lists.tpm2
Message-ID <[email protected]>
On Tue, 2022-07-19 at 22:17 +0000, Kenneth Goldman wrote:
> > On Mon, 2022-07-18 at 17:36 +0000, Kenneth Goldman wrote:
> > > It depends.
> > > 
> > > Windows seems to have a large keystore, so you probably don't
> > > have to
> > > ever flush.
> > > 
> > > Linux in kernel RM manages keys across processes but not within
> > > processes, so you still have to flush.
> > 
> > This is also how TBS works on Windows.
> 
> Not on my Windows 10.  I just created 32 keys with one process.  Now
> there are 
> 32 loaded keys.

Did the process exit? I always thought TBS was spec compliant:
"The RM also monitors connections, and removes table entries and
ContextFlushes leftover sessions
when the caller closes a connection." from Section 2.3.3 of:
https://trustedcomputinggroup.org/wp-content/uploads/TSS_2p0_TAB_ResourceManager_v1p0_r18_04082019_pub.pdf

The table entries include transient handles and their associated
virtual mapping.

> OK, the Windows RM swaps them out, but the application never 
> sees that.
> 
> I don't know what the RM limit is, but it's certainly far more than
> the TPM 
> itself.
> 
> getcapability.exe -cap 1 -pr 80000000
> 32 handles
>         80ffffe0
>         80ffffe1
>         80ffffe2
>         80ffffe3
>         80ffffe4
>         80ffffe5
>         80ffffe6
>         80ffffe7
>         80ffffe8
>         80ffffe9
>         80ffffea
>         80ffffeb
>         80ffffec
>         80ffffed
>         80ffffee
>         80ffffef
>         80fffff0
>         80fffff1
>         80fffff2
>         80fffff3
>         80fffff4
>         80fffff5
>         80fffff6
>         80fffff7
>         80fffff8
>         80fffff9
>         80fffffa
>         80fffffb
>         80fffffc
>         80fffffd
>         80fffffe
>         80ffffff

These look like virtual handles. The spec also states,
"In responses that return handles, these handles MUST be virtualized
before returning the
response to the caller:
 These virtual handles MUST be unique per connection".
I don't think anyone actually makes them unique per connection.