as Philip mentioned:
$ tpm2_rc_decode 0x1c2
This means that the combination of attributes inside your inPublic field do not fit together.
That can be the case the physical TPMs implement "only" the PC-Client TPM Profile, which is a subset of all functions defined in the TPM library specification, whilst the simulator implements them all. Most notably these are Hashes and EC-Curves, where
pTPMs usually only support up to SHA384 and P256+P384, whilst the simulator has many more algorithms.
In some rare cases it is also a bug due to the pTPM being rev 1.16 whilst the simulator is rev 1.38, but that's pretty rare.
Maybe compare your inPublic to the integration tests. They were all run against physical TPMs.
Or post your inPublic declaration and we can point something out.
From: tpm2 [email@example.com] on behalf of Sourajit Mukhopadhyay [firstname.lastname@example.org]
Sent: Wednesday, December 05, 2018 14:57
Subject: [tpm2] Esys_CreatePrimary works with Simulator but failing with /dev/tpm0
I am trying to create a primary key using Esys_CreatePrimary. The code works without any issues when trying on the simulator, but fails when trying on a hardware TPM using /dev/tpm0
The error I am getting is:
WARNING:esys:src/tss2-esys/api/Esys_CreatePrimary.c:423:Esys_CreatePrimary_Finish() Received TPM Error
ERROR:esys:src/tss2-esys/api/Esys_CreatePrimary.c:164:Esys_CreatePrimary() Esys Finish ErrorCode (0x000001c2)
Can someone point out why I am getting this error? So far I am unable to pinpoint the problem.