I found an issue with trousers 0.3.13, but after a quick look on the source code the issue seems to be also present in the last release.
My application creates its context using Tspi_Context_Create function.
Then the app makes some signing, sealing operation using the TPM.
Then the app closes all objects, free memory allocations and close its context using Tspi_Context_Close.
Then later, the app needs to access again to the TPM.
So the app create a new context using Tspi_Context_Create function
Then the app makes some signing, sealing operation using the TPM.
Then the app close all objects, free memory allocations and close its context using Tspi_Context_Close.
But this Tspi_Context_Close function never return a value. The app is blocked in this function.
After some research I found that the Tspi_Context_Close function is blocked by a mutex (mutex user_ps_path) in the function get_user_ps_path (file src/tspi/ps/tspps.c).
I found that there is a possibility to quit the get_user_ps_path without unlocking the mutex user_ps_path. That's why the first Tspi_Context_Close works, and the second is blocked.
So I created a patch to unlock the user_ps_path mutex before to quit the get_user_ps_path function.
And it fixes my issue.
Please find this patch attached.
If you have any comments,
I know this patch can be improved, corrected even if it works well for my case.
Thanks.
Thomas