if (action == ACTION_SIGN && imageID == INVALID_FLAG) { snprintf(debugMsg, sizeof(debugMsg), "[!] FATAL: no imageID specified"); debugLog(debugMsg); exit(1); }
/* create context, connect it to local TCS */
result = Tspi_Context_Create( &hContext ); // create context struct in memory, point to it with hContext
checkErr(result, "Tspi_Context_Create()");
result = Tspi_Context_Connect ( hContext, // the context pointed to by hContext..
NULL ); // is to be connected to the local TCS
checkErr(result, "Tspi_Context_Connect()");
/* LIST INFO ON KEYS IN USER & SYSTEM PERSISTENT STORAGE */
if (action == ACTION_LIST)
{
TSS_KM_KEYINFO2 *keys;
UINT32 keysLen;
Tspi_Context_GetRegisteredKeysByUUID2 ( hContext, // get info on current context
TSS_PS_TYPE_SYSTEM, // it appears to ignore this and prints both SYSTEM and USER persistent keys
NULL, // NULL in this UUID field means "give me info on all the keys"; otherwise this would provide // data about all the keys in the path leading to the identified key
&keysLen, // will store the number of array entries retrieved
&keys ); // this will point to actual key heirarchy
printf("\nKeys currently stored in persistent storage (USER and SYSTEM stores):\n");
int i; for (i=0; i<keysLen; i++) { print_KM_KEYINFO2(&keys[i]); }
}
/* CLEAR ALL THE KEYS IN SYSTEM PERSISTENT STORAGE EXCEPT THE SRK */
if (action == ACTION_RESET)
{
/* locals */
int keysRemoved = 0;
UINT32 persistentKeysLen;
TSS_HKEY *hDeletedKey; // TODO: GCC complains about this; come back to this
TSS_KM_KEYINFO2 *persistentKeys;
printf("\nRemoving the all non-root keys from SYSTEM persistent storage:\n");
/* get all persistent keys, point to the array of structs with 'persistentKeys' */
Tspi_Context_GetRegisteredKeysByUUID2 ( hContext, // get info on current context
TSS_PS_TYPE_SYSTEM, // it appears to ignore this and prints both SYSTEM and USER persistent keys
NULL, // NULL in this UUID field means "give me info on all the keys"; otherwise this would // only provide data about all the keys in the path leading to the identified key
&persistentKeysLen, // will store the number of array entries retrieved
&persistentKeys ); // this will point to actual key heirarchy
char keyUUIDString[38], parentUUIDString[38];
int i; for (i=0; i<persistentKeysLen; i++)
{ TSS_KM_KEYINFO2 *k = &persistentKeys[i];
if (k->persistentStorageType != TSS_PS_TYPE_SYSTEM) continue; // we're only concerned with keys in SYSTEM persistent storage
/* get the parent UUID in the same format as displayed in the '-l' option */