pietrmar / stpm2

0 stars 0 forks source link

Tss2_Sys_CreatePrimary() failed with tpm:parameter(2):value is out of range or is not correct for the context #1

Closed anhk closed 5 years ago

anhk commented 5 years ago

Hey @pietrmar , I'm using your code to build a test project. my code is here: https://github.com/anhk/stpm2-test/blob/master/src/main.c

Now I get a error on my laptop with TPM2.0 chip, and I modified stpm2.c and set

I got same error:

12:47:49 TRACE stpm2.c:249 Entering stpm2_init() 12:47:49 TRACE stpm2.c:21 Entering init_tcti() 12:47:49 TRACE stpm2.c:77 Leaving init_tcti() 12:47:49 TRACE stpm2.c:159 Entering stpm2_flush_all() 12:47:49 TRACE stpm2.c:132 Entering stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:153 Leaving stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:132 Entering stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:153 Leaving stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:132 Entering stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:153 Leaving stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:176 Leaving stpm2_flush_all() 12:47:49 TRACE stpm2.c:186 Entering stpm2_create_primary() 12:47:49 ERROR stpm2.c:234 Tss2_Sys_CreatePrimary() failed with tpm:parameter(2):value is out of range or is not correct for the context 12:47:49 ERROR stpm2.c:289 Failed to create primary key 12:47:49 TRACE stpm2.c:303 Entering stpm2_free() 12:47:49 TRACE stpm2.c:159 Entering stpm2_flush_all() 12:47:49 TRACE stpm2.c:132 Entering stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:153 Leaving stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:132 Entering stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:153 Leaving stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:132 Entering stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:153 Leaving stpm2_flush_context_range() 12:47:49 TRACE stpm2.c:176 Leaving stpm2_flush_all() 12:47:50 TRACE stpm2.c:91 Entering free_tcti() 12:47:50 TRACE stpm2.c:105 Leaving free_tcti() 12:47:50 TRACE stpm2.c:332 Leaving stpm2_free() 12:47:50 ERROR main.c:14 stpm2_init() failed

could you help me?

anhk commented 5 years ago

I modified the code as: 227 in_public.publicArea.nameAlg = TPM2_ALG_SHA; 235 in_public.publicArea.parameters.rsaDetail.symmetric.keyBits.aes = 128;

and then the code works.

pietrmar commented 5 years ago

Hi yes, it seems like your physical TPM does not support SHA256 and AES-256. Porbably sometime in the future I should add capability detection.

However I should alsso note that the library is developed as a hobby project and is not really mature or peer reviewed in terms of security.