how unique are primary keys ?
ted.h.kim at oracle.com
Folks,
How unique are primary keys ?
As an example:
$ tpm2_createprimary -Q -C o -c prim1.ctx $ tpm2_createprimary -Q -C o -c prim2.ctx $ tpm2_createprimary -Q -C o -u /dev/random -c prim3.ctx $ tpm2_readpublic -c prim1.ctx > prim1.rp $ tpm2_readpublic -c prim2.ctx > prim2.rp $ tpm2_readpublic -c prim3.ctx > prim3.rp $ diff prim1.rp prim2.rp $ diff prim1.rp prim3.rp $
Is it supposed to be like this?
Shouldn't they be different in some way?
For prim3, I thought putting some -u data would make a difference, but it seems not.
FWIW, I am using 4.1 branch of tpm2-tools with swtpm.
Thanks,
-ted
Signature · 3 lines
Ted H. Kim, PhD ted.h.kim(a)oracle.com +1 310-258-7515
ted.h.kim at oracle.com
Folks,
Doesn't this behavior kind of make PolicyDuplicationSelect meaningless? I am thinking of the example in the tpm2_policyduplicationselect man page.
If the tpm2_readpublic output is the same for all three keys, then the names are the same as well as the RSA public keys.
So the policy digest created by tpm2_policyduplicationselect specifying prim1 as parent will be the same as created for prim2 and prim3. And importing a duplicated key meant for prim1 as a parent will also work under prim2 and prim3.
Am I missing something here?
Thanks,
-ted
Quoted 26 lines · ted.h.kim(a)oracle.com
Folks,
How unique are primary keys ?
As an example:
$ tpm2_createprimary -Q -C o -c prim1.ctx $ tpm2_createprimary -Q -C o -c prim2.ctx $ tpm2_createprimary -Q -C o -u /dev/random -c prim3.ctx $ tpm2_readpublic -c prim1.ctx > prim1.rp $ tpm2_readpublic -c prim2.ctx > prim2.rp $ tpm2_readpublic -c prim3.ctx > prim3.rp $ diff prim1.rp prim2.rp $ diff prim1.rp prim3.rp $Is it supposed to be like this?
Shouldn't they be different in some way?
For prim3, I thought putting some -u data would make a difference, but it seems not.FWIW, I am using 4.1 branch of tpm2-tools with swtpm.
Thanks,
-ted
Signature · 3 lines
Ted H. Kim, PhD ted.h.kim(a)oracle.com +1 310-258-7515
Rowan Moul
Primary Keys are created using a deterministic key derivation function, the seed value of the selected hierarchy, and the key “template” (effectively the options you pass to tpm2_createprimary). This is the intended functionality.
Your first two calls are identical, and so they will indeed produce the same key. The third one passes in unique data from /dev/random which in theory should make it unique, but in practice I’m not sure how that is implemented (eg how much data will it actually read in?). I’m actually surprised it didn’t fail based on my experience here:
https://lists.01.org/hyperkitty/list/tpm2(a)lists.01.org/message/5YDZRV63LCGX6BZQXRW6S6F77PSS5JU5/
I’m honesty not even convinced that what I did in that thread was actually correct. Perhaps someone more knowledgeable will answer here and clear that up.
Another way to make a key unique is to set an authorization value or policy, but you would have to have a different value for every key, which is where the unique data is supposed to come in if you want multiple keys with the same authorization value.
Rowan
Quoted 36 lines · ted.h.kim(a)oracle.com
Folks,
How unique are primary keys ?
As an example:
$ tpm2_createprimary -Q -C o -c prim1.ctx $ tpm2_createprimary -Q -C o -c prim2.ctx $ tpm2_createprimary -Q -C o -u /dev/random -c prim3.ctx $ tpm2_readpublic -c prim1.ctx > prim1.rp $ tpm2_readpublic -c prim2.ctx > prim2.rp $ tpm2_readpublic -c prim3.ctx > prim3.rp $ diff prim1.rp prim2.rp $ diff prim1.rp prim3.rp $Is it supposed to be like this?
Shouldn't they be different in some way?
For prim3, I thought putting some -u data would make a difference, but it seems not.FWIW, I am using 4.1 branch of tpm2-tools with swtpm.
Thanks,
-tedSignature · 8 lines
Ted H. Kim, PhD ted.h.kim(a)oracle.com +1 310-258-7515 _______________________________________________ tpm2 mailing list -- tpm2(a)lists.01.org To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
ted.h.kim at oracle.com
Rowan,
I think I understand your point.
But are these KDFs "stateless"? I would think they would be like random number generators, where you can set the initial seed, but from then on each invocation updates the state. That way there is a deterministic sequence for a given starting seed, but still there is a sequence. But of course, I am no expert about any of this.
Sorry I am not able clear things up on your thread.
Thanks,
-ted
Quoted 60 lines · Rowan Moul
Primary Keys are created using a deterministic key derivation function, the seed value of the selected hierarchy, and the key “template” (effectively the options you pass to
tpm2_createprimary). This is the intended functionality.Your first two calls are identical, and so they will indeed produce the same key. The third one passes in unique data from
/dev/randomwhich in theory should make it unique, but in practice I’m not sure how that is implemented (eg how much data will it actually read in?). I’m actually surprised it didn’t fail based on my experience here:
https://lists.01.org/hyperkitty/list/tpm2(a)lists.01.org/message/5YDZRV63LCGX6BZQXRW6S6F77PSS5JU5/
<https://urldefense.com/v3/__https://lists.01.org/hyperkitty/list/tpm2(a)lists.01.org/message/5YDZRV63LCGX6BZQXRW6S6F77PSS5JU5/__;!!GqivPVa7Brio!MfGiWe1M5tPIE6MeSRiB3WpC1xS4FOvRzXt4cLDDXmSjrARG9I7nv-UffpZC-cs$>
I’m honesty not even convinced that what I did in that thread was actually correct. Perhaps someone more knowledgeable will answer here and clear that up.
Another way to make a key unique is to set an authorization value or policy, but you would have to have a different value for every key, which is where the unique data is supposed to come in if you want multiple keys with the same authorization value.Rowan
Quoted 37 lines · ted.h.kim(a)oracle.com
Folks,
How unique are primary keys ?
As an example:
$ tpm2_createprimary -Q -C o -c prim1.ctx $ tpm2_createprimary -Q -C o -c prim2.ctx $ tpm2_createprimary -Q -C o -u /dev/random -c prim3.ctx $ tpm2_readpublic -c prim1.ctx > prim1.rp $ tpm2_readpublic -c prim2.ctx > prim2.rp $ tpm2_readpublic -c prim3.ctx > prim3.rp $ diff prim1.rp prim2.rp $ diff prim1.rp prim3.rp $Is it supposed to be like this?
Shouldn't they be different in some way?
For prim3, I thought putting some -u data would make a difference, but it seems not.FWIW, I am using 4.1 branch of tpm2-tools with swtpm.
Thanks,
-tedSignature · 8 lines
Ted H. Kim, PhD ted.h.kim(a)oracle.com +1 310-258-7515 _______________________________________________ tpm2 mailing list -- tpm2(a)lists.01.org To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Signature · 3 lines
Ted H. Kim, PhD ted.h.kim(a)oracle.com +1 310-258-7515
Rowan Moul
The derivation function is effectively stateless as it uses the hierarchy seed which doesn’t change unless you call tpm2_clear. This open access book explains it better than me: https://link.springer.com/book/10.1007%2F978-1-4302-6584-9
A short quote from Chapter 10: Keys
The key-derivation function is fixed and repeatable. For the same seed, the same template always produces the same key. By varying the unique data in the template, the caller can create an unlimited number of primary keys.
The book mentions different internal TPM commands but their names don’t always correlate directly to the user-space tools found in tpm-tools
Rowan
Quoted 61 lines
Quoted 1 line · ted.h.kim(a)oracle.com
Rowan,I think I understand your point.
But are these KDFs "stateless"? I would think they would be like random number generators, where you can set the initial seed, but from then on each invocation updates the state. That way there is a deterministic sequence for a given starting seed, but still there is a sequence. But of course, I am no expert about any of this.
Sorry I am not able clear things up on your thread.
Thanks,
-tedQuoted 38 lines · Rowan Moul
Primary Keys are created using a deterministic key derivation function, the seed value of the selected hierarchy, and the key “template” (effectively the options you pass to
tpm2_createprimary). This is the intended functionality.Your first two calls are identical, and so they will indeed produce the same key. The third one passes in unique data from
/dev/randomwhich in theory should make it unique, but in practice I’m not sure how that is implemented (eg how much data will it actually read in?). I’m actually surprised it didn’t fail based on my experience here:
https://lists.01.org/hyperkitty/list/tpm2(a)lists.01.org/message/5YDZRV63LCGX6BZQXRW6S6F77PSS5JU5/
I’m honesty not even convinced that what I did in that thread was actually correct. Perhaps someone more knowledgeable will answer here and clear that up.
Another way to make a key unique is to set an authorization value or policy, but you would have to have a different value for every key, which is where the unique data is supposed to come in if you want multiple keys with the same authorization value.Rowan
Quoted 27 lines
Quoted 1 line · ted.h.kim(a)oracle.com
Folks,
How unique are primary keys ?
As an example:$ tpm2_createprimary -Q -C o -c prim1.ctx $ tpm2_createprimary -Q -C o -c prim2.ctx $ tpm2_createprimary -Q -C o -u /dev/random -c prim3.ctx $ tpm2_readpublic -c prim1.ctx > prim1.rp $ tpm2_readpublic -c prim2.ctx > prim2.rp $ tpm2_readpublic -c prim3.ctx > prim3.rp $ diff prim1.rp prim2.rp $ diff prim1.rp prim3.rp $ Is it supposed to be like this? Shouldn't they be different in some way? For prim3, I thought putting some -u data would make a difference, but it seems not. FWIW, I am using 4.1 branch of tpm2-tools with swtpm. Thanks, -ted -- Ted H. Kim, PhD ted.h.kim(a)oracle.com +1 310-258-7515 _______________________________________________ tpm2 mailing list -- tpm2(a)lists.01.org To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)sSignature · 9 lines
Ted H. Kim, PhD ted.h.kim(a)oracle.com +1 310-258-7515 _______________________________________________ tpm2 mailing list -- tpm2(a)lists.01.org To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Roberts
Quoted 11 lines
-----Original Message-----
From: Rowan Moul <lists(a)rowan.moul.ca>
Sent: Friday, June 5, 2020 6:29 PM
To: ted.h.kim(a)oracle.com
Cc: tpm2(a)lists.01.org
Subject: [tpm2] Re: how unique are primary keys ?The derivation function is effectively stateless as it uses the hierarchy seed which doesn’t change unless you call
tpm2_clear.
That depends on the hierarchy. Each seed can change under the following conditions:
NULL - Reboot
OWNER - tpm2_clear
ENDORSEMENT - ChangeEPS command if supported
PLATFORN - ChangePPS command if supported
So depending on what you use for the tpm2_createprimary -C (capital C option) Controls your hierarchy. The tools default to owner.
Quoted 193 lines
This open access book explains it better than me:
https://link.springer.com/book/10.1007%2F978-1-4302-6584-9
A short quote from Chapter 10: KeysThe key-derivation function is fixed and repeatable. For the same seed, the same template always produces the same key. By varying the unique data in the template, the caller can create an unlimited number of primary keys.
The book mentions different internal TPM commands but their names don’t always correlate directly to the user-space tools found in tpm-tools
Rowan
On Jun 5, 2020, at 17:02, ted.h.kim(a)oracle.com wrote:
Rowan,
I think I understand your point.
But are these KDFs "stateless"? I would think they would be like random
number generators, where you can set the initial seed, but from then on each invocation updates the state. That way there is a deterministic sequence for a given starting seed, but still there is a sequence. But of course, I am no expert about any of this.Sorry I am not able clear things up on your thread.
Thanks,
-tedOn 6/5/20 3:34 PM, Rowan Moul wrote:
Primary Keys are created using a deterministic key derivation
function, the seed value of the selected hierarchy, and the key “template” (effectively the options you pass totpm2_createprimary). This is the intended functionality.Your first two calls are identical, and so they will indeed produce
the same key. The third one passes in unique data from/dev/randomwhich in theory should make it unique, but in practice I’m not sure how that is implemented (eg how much data will it actually read in?). I’m actually surprised it didn’t fail based on my experience here:https://lists.01.org/hyperkitty/list/tpm2(a)lists.01.org/message/5YDZRV63LCGX6BZQXRW6S6F77PSS5JU5/
<https://urldefense.com/v3/__https://lists.01.org/hyperkitty/list/tpm2(a)lists.01.
org/message/5YDZRV63LCGX6BZQXRW6S6F77PSS5JU5/__;!!GqivPVa7Brio!MfGi We1M5tPIE6MeSRiB3WpC1xS4FOvRzXt4cLDDXmSjrARG9I7nv-UffpZC-cs$>
I’m honesty not even convinced that what I did in that thread was
actually correct. Perhaps someone more knowledgeable will answer here and clear that up.
Another way to make a key unique is to set an authorization
value or policy, but you would have to have a different value for every key, which is where the unique data is supposed to come in if you want multiple keys with the same authorization value.Rowan On Jun 4, 2020, at 17:48, ted.h.kim(a)oracle.com<mailto:ted.h.kim(a)oracle.com> wrote:
Folks,
How unique are primary keys ?
As an example:
$
tpm2_createprimary-Q -C o -c prim1.ctx$
tpm2_createprimary-Q -C o -c prim2.ctx$
tpm2_createprimary-Q -C o -u/dev/random-c
prim3.ctx$ tpm2_readpublic -c prim1.ctx > prim1.rp$ tpm2_readpublic -c prim2.ctx > prim2.rp$ tpm2_readpublic -c prim3.ctx > prim3.rp$ diff prim1.rp prim2.rp$ diff prim1.rp prim3.rp$
Is it supposed to be like this?
Shouldn't they be different in some way?
For prim3, I thought putting some -u data would make a
difference, but it seems not.FWIW, I am using 4.1 branch of tpm2-tools with swtpm. Thanks, -ted -- Ted H. Kim, PhD ted.h.kim(a)oracle.com <mailto:ted.h.kim(a)oracle.com> +1 310-258-7515 _______________________________________________ tpm2 mailing list -- tpm2(a)lists.01.org<mailto:tpm2(a)lists.01.org>
To unsubscribe send an email to tpm2-leave(a)lists.01.org
<mailto:tpm2-leave(a)lists.01.org>%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s -- Ted H. Kim, PhD ted.h.kim(a)oracle.com <mailto:ted.h.kim(a)oracle.com> +1 310-258-7515 _______________________________________________ tpm2 mailing list -- tpm2(a)lists.01.org To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Roberts
Quoted 12 lines
-----Original Message-----
From: ted.h.kim(a)oracle.com <ted.h.kim(a)oracle.com>
Sent: Thursday, June 4, 2020 6:47 PM
To: tpm2(a)lists.01.org
Subject: [tpm2] how unique are primary keys ?Folks,
How unique are primary keys ?
Quoted 7 lines
As an example:
$ tpm2_createprimary -Q -C o -c prim1.ctx $ tpm2_createprimary -Q -C o -c prim2.ctx $ tpm2_createprimary -Q -C o -u /dev/random -c prim3.ctx $ tpm2_readpublic -c prim1.ctx > prim1.rp $ tpm2_readpublic -c prim2.ctx > prim2.rp $ tpm2_readpublic -c prim3.ctx > prim3.rp $ diff prim1.rp prim2.rp $ diff prim1.rp prim3.rp $
You got that to work? The -u data needs to be formatted as a binary TPMU_PUBLIC_ID Union (which is utterly terrible).
See:
- https://github.com/tpm2-software/tpm2-tools/commit/6c9377faf056b6700e19ceaa11fb6425342daa49
- https://github.com/tpm2-software/tpm2-tools/blob/master/lib/tpm2_alg_util.c#L957
I filed a bug against the project for this unique data format.
I tried getting it to work, briefly and failed. I'm not even sure if this feature works, especially without tests around it.
Quoted 20 lines
Is it supposed to be like this?
Shouldn't they be different in some way?
For prim3, I thought putting some -u data would make a difference, but it seems not.FWIW, I am using 4.1 branch of tpm2-tools with swtpm.
Thanks,
-ted--
Ted H. Kim, PhD
ted.h.kim(a)oracle.com
+1 310-258-7515_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Imran Desai
From integration tests -- https://github.com/tpm2-software/tpm2-tools/blob/876e5d57efb48cce4225bdb738704c5cd48aa312/test/integration/tests/createprimary.sh#L53
printf '\x00\x01' > ud.1
dd if=/dev/zero bs=256 count=1 of=ud.2
cat ud.1 ud.2 > unique.dat
tpm2_createprimary -C o -G rsa2048:aes128cfb -g sha256 -c prim.ctx -a "restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|\
noda" -u unique.dat
tpm2_createprimary -C o -G rsa2048:aes128cfb -g sha256 -c prim2.ctx -a "restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|\
noda"
diff prim.ctx prim2.ctx
ted.h.kim at oracle.com
William,
Thanks for filing the issue.
https://github.com/tpm2-software/tpm2-tools/issues/2091
unique data format is binary, make it easier to format
-ted
Quoted 53 lines · William C
Quoted 11 lines
-----Original Message-----
From: ted.h.kim(a)oracle.com <ted.h.kim(a)oracle.com>
Sent: Thursday, June 4, 2020 6:47 PM
To: tpm2(a)lists.01.org
Subject: [tpm2] how unique are primary keys ?Folks,
How unique are primary keys ?
Quoted 7 lines
As an example:
$ tpm2_createprimary -Q -C o -c prim1.ctx $ tpm2_createprimary -Q -C o -c prim2.ctx $ tpm2_createprimary -Q -C o -u /dev/random -c prim3.ctx $ tpm2_readpublic -c prim1.ctx > prim1.rp $ tpm2_readpublic -c prim2.ctx > prim2.rp $ tpm2_readpublic -c prim3.ctx > prim3.rp $ diff prim1.rp prim2.rp $ diff prim1.rp prim3.rp $You got that to work? The -u data needs to be formatted as a binary
TPMU_PUBLIC_IDUnion (which is utterly terrible).See:
- https://urldefense.com/v3/__https://github.com/tpm2-software/tpm2-tools/commit/6c9377faf056b6700e19ceaa11fb6425342daa49__;!!GqivPVa7Brio!IluyUE7DiEgqTu52mNKQK6d9yC8GLdNlqkoNuiIfqCA2Rto35JQOUk20ShsnGZs$
- https://urldefense.com/v3/__https://github.com/tpm2-software/tpm2-tools/blob/master/lib/tpm2_alg_util.c*L957__;Iw!!GqivPVa7Brio!IluyUE7DiEgqTu52mNKQK6d9yC8GLdNlqkoNuiIfqCA2Rto35JQOUk20FR6bGKI$I filed a bug against the project for this unique data format.
I tried getting it to work, briefly and failed. I'm not even sure if this feature works, especially without tests around it.
Quoted 15 lines
Is it supposed to be like this?
Shouldn't they be different in some way?
For prim3, I thought putting some -u data would make a difference, but it seems not.FWIW, I am using 4.1 branch of tpm2-tools with swtpm.
Thanks,
-ted--
Ted H. Kim, PhD
ted.h.kim(a)oracle.com
+1 310-258-7515Quoted 4 lines
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Signature · 3 lines
Ted H. Kim, PhD ted.h.kim(a)oracle.com +1 310-258-7515