Skip to content

[Question] tpm2_encodeobject works only with persisted primarys? #3591

Description

@keros

Hi

I'm on Debian 13 with tpm2-tools 5.7-1

Can someone please explain me why this works:

tpm2_createprimary -C o -G ecc -c primary.ctx
tpm2_evictcontrol -c primary.ctx 0x81110001
tpm2_create -C 0x81110001 -G ecc -u key.pub -r key.priv -p "super-secret"

tpm2_encodeobject -C 0x81110001 -u key.pub -r key.priv -o tpm.pem

openssl req -provider tpm2 -provider default -new -key tpm.pem -subj "/CN=server" -out server.csr -passin "pass:super-secret"

And this does not work:

tpm2_createprimary -C o -G ecc -c primary.ctx
tpm2_create -C primary.ctx -G ecc -u key.pub -r key.priv -p "super-secret"

tpm2_encodeobject -C primary.ctx -u key.pub -r key.priv -o tpm.pem

openssl req -provider tpm2 -provider default -new -key tpm.pem -subj "/CN=server" -out server.csr -passin "pass:super-secret"

I'm really sure there is a valid reason for this. If someone could explain this to me or point me to a documentation where this is explained I would be very happy.

Also a second question popped up.
The -p option on tpm2_encodeobject says:

...
-p, --key-auth:
Indicates if an authorization value is needed for the object specified by -r and -u.
...

https://www.mankier.com/1/tpm2_encodeobject

Is the description inverted? In my example above I use a password (super-secret) and don't need to set -p (If I set -p the example does not work).
But the same example without password needs the -p option to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions