Skip to contentSkip to conversation

Conflicting TPM2 engines and storage formats

tpm2 Fuchs 2 participants 6 messages Oct 5, 2018 1 message not in the archive

lore
Share & tools
lore

Fuchs

#1 lore raw
In reply to a message not in the archive

Hi James, Hi David,

I put together a Wiki-Page with the most relevant information at https://github.com/tpm2-software/tpm2-tss-engine/wiki/Key-templates-and-on-disk-format
Also including things like nameAlg for the primary key and such, since maybe that's where we are differing right now.

There are a bunch of ??? about the tss2-engine where I'd need input from you.

And a bunch of tbds of the tpm2-tss-engine where I'll have to do some coding.

Thanks a lot,
Andreas
________________________________________
From: James Bottomley [James.Bottomley(a)hansenpartnership.com]
Sent: Thursday, October 04, 2018 18:15
To: Fuchs, Andreas; David Woodhouse; tpm2(a)lists.01.org; Nikos Mavrogiannopoulos
Subject: Re: [tpm2] Conflicting TPM2 engines and storage formats

Quoted 7 lines · Andreas

Should we try to setup a wiki or markdown to start converging into a single form ?
I think we can also easily set NODA for the primary, because they have to auth value anyways.

@James: how do you handle the key-ids ? Allways assume them to be files ?

My engine assumes it's a file unless it's convertible to a hex number and the first octet is 0x81 (which is the persistent key MSO); so I don't do the 0x prefix and with this form you specify, say the template primary as 81000001. Anything that doesn't look like a persistent key hex number is treated as a file name.

James

Quoted 8 lines

I have a PR for persistent TPM keys, where all key ids starting with 0x are interpreted as TPM keys. For the future I'll also want to reference FAPI keys (path-like format).
Thus, any clues on how to handle things consistently here ?

tpm2-tss-engine will propably not support policies from your format then, but wait until FAPI (with integrated policy engine) is available.

#2 lore raw
Quoted 8 lines · Andreas

Hi James, Hi David,

I put together a Wiki-Page with the most relevant information at
https://github.com/tpm2-software/tpm2-tss-engine/wiki/Key-templates-and-on-disk-format
Also including things like nameAlg for the primary key and such, since maybe that's where we are differing right now.

There are a bunch of ??? about the tss2-engine where I'd need input from you.

My GnuTLS code mostly follows tpm2-tss-engine here, except for the different objectAttributes when generating the parent key. That differs in the NODA, FIXEDTPM and FIXEDPARENT flags, as discussed — and I follow James's version here so that I can actually test VPN connections with a valid key (which I have on disk, and has to be wrapped).

Every other part of the default parent key generation, is the same between the engines. It's only the objectAttributes I had to change.

I'm not sure you have the 'Parent key is 0x81000001 if it exists' part right.

The parent key is encoded in the PEM ASN.1.

If it matches 0x81xxxxxx, it's used as a key handle directly.

If not, it identifies the hierarchy under which the EC primary key is generated. James's version defaults to TPM_RH_OWNER, but I think other hierarchies can be specified.

#5 lore raw
In reply to Fuchs
Quoted 7 lines · Andreas

Hi James, Hi David,

I put together a Wiki-Page with the most relevant information at
https://github.com/tpm2-software/tpm2-tss-engine/wiki/Key-templates-and-on-disk-format
Also including things like nameAlg for the primary key and such, since maybe that's where we are differing right now.

Quoted 5 lines

There are a bunch of ??? about the tss2-engine where I'd need input from you.

And a bunch of tbds of the tpm2-tss-engine where I'll have to do some coding.

Thanks a lot,

Can we change the PEM tag too, to -----BEGIN TSS2 PRIVATE KEY----- ?

Ending with "PRIVATE KEY" is needed for OpenSSL 1.1.1 to be able to automatically load it without having to hack *every* application to recognise the strings and try the appropriate engine.

See https://github.com/openssl/openssl/issues/7354

#3 lore raw
In reply to David Woodhouse

Hi David,

are you sure this is about the (default) parent, i.e. primary key ?

I assume you're talking about the actual key, which I left out for the specification. Can this be ?

Cheers,
Andreas
________________________________________
From: David Woodhouse [dwmw2(a)infradead.org]
Sent: Friday, October 05, 2018 12:27
To: Fuchs, Andreas; James Bottomley; tpm2(a)lists.01.org; Nikos Mavrogiannopoulos
Subject: Re: [tpm2] Conflicting TPM2 engines and storage formats

Quoted 8 lines · Andreas

Hi James, Hi David,

I put together a Wiki-Page with the most relevant information at
https://github.com/tpm2-software/tpm2-tss-engine/wiki/Key-templates-and-on-disk-format
Also including things like nameAlg for the primary key and such, since maybe that's where we are differing right now.

There are a bunch of ??? about the tss2-engine where I'd need input from you.

My GnuTLS code mostly follows tpm2-tss-engine here, except for the different objectAttributes when generating the parent key. That differs in the NODA, FIXEDTPM and FIXEDPARENT flags, as discussed — and I follow James's version here so that I can actually test VPN connections with a valid key (which I have on disk, and has to be wrapped).

Every other part of the default parent key generation, is the same between the engines. It's only the objectAttributes I had to change.

I'm not sure you have the 'Parent key is 0x81000001 if it exists' part right.

The parent key is encoded in the PEM ASN.1.

If it matches 0x81xxxxxx, it's used as a key handle directly.

If not, it identifies the hierarchy under which the EC primary key is generated. James's version defaults to TPM_RH_OWNER, but I think other hierarchies can be specified.

#6 lore raw
In reply to David Woodhouse

Actually, I like the TSS2 PEM Tag.
We could then also get rid of the OPTIONAL for publicKey, since we won't support TPMv1.2 anymore.
________________________________________
From: David Woodhouse [dwmw2(a)infradead.org]
Sent: Friday, October 05, 2018 13:59
To: Fuchs, Andreas; James Bottomley; tpm2(a)lists.01.org; Nikos Mavrogiannopoulos
Cc: Richard Levitte
Subject: Re: [tpm2] Conflicting TPM2 engines and storage formats

Quoted 7 lines · Andreas

Hi James, Hi David,

I put together a Wiki-Page with the most relevant information at
https://github.com/tpm2-software/tpm2-tss-engine/wiki/Key-templates-and-on-disk-format
Also including things like nameAlg for the primary key and such, since maybe that's where we are differing right now.

Quoted 5 lines

There are a bunch of ??? about the tss2-engine where I'd need input from you.

And a bunch of tbds of the tpm2-tss-engine where I'll have to do some coding.

Thanks a lot,

Can we change the PEM tag too, to -----BEGIN TSS2 PRIVATE KEY----- ?

Ending with "PRIVATE KEY" is needed for OpenSSL 1.1.1 to be able to automatically load it without having to hack *every* application to recognise the strings and try the appropriate engine.

See https://github.com/openssl/openssl/issues/7354

#4 lore raw
In reply to Fuchs
Quoted 7 lines · Andreas

Hi David,

are you sure this is about the (default) parent, i.e. primary key ?

I assume you're talking about the actual key, which I left out for the specification.
Can this be ?

James's code uses the 'parent' handle from the ASN.1 directly if it matches 0x81xxxxxx. If it doesn't, then he has a function equivalent to your init_tpm_primary() function, except that the value used for in.primaryHandle is the one from the ASN.1. Which seems like it's designed to allow the user of other hierarchies. It defaults to RH_OWNER, while yours is hard-coded to that.

But I see James is awake now, so I'll defer to him...