Hi there,
I've been trying to setup a short program to seal and unseal a file using
the TSPI library, and seem to have run into a wall, when I try to load the
key in by uuid I keep getting an error of 12556, which from what I've
looked up, is TSS_E_INVALID_OBJECT_INITFLAG But I havn't been able to fix
it by changing round the object flags etc. I'll post my code below up to
the point where the error's occuring, any help would be much appreciated.

int main(int argc, const char argv[]) {
  TSS_HCONTEXT hContext;
  TSS_RESULT result;
  TSS_HTPM hTPM = 0;
  TSS_UUID thisID = {9};
  TSS_HKEY hKey, hSRK;
  TSS_UUID SRK_UUID = TSS_UUID_SRK;
  UINT32 pcrs[8] = {0, 1, 2, 3, 4, 5, 6, 7};
  Tspi_Context_Create(&hContext);
  /* Connect to the local TCS provider */
  Tspi_Context_Connect(hContext, NULL);
  Tspi_Context_GetTpmObject(hContext, &hTPM);
  keySetup(&hContext);
  printf(
      "%u is load error\n",
      Tspi_Context_LoadKeyByUUID(hContext, TSS_PS_TYPE_SYSTEM, thisID,
&hKey));
  sealFile(&hContext, &hTPM, "test.txt", hKey, pcrs, 8);
  unsealFile(&hContext, "test.txt", hKey);
  Tspi_Context_FreeMemory(hContext, NULL);
  result = Tspi_Context_Close(hContext);
  if (result == TSS_SUCCESS) {
    printf("succesfully close context\n");
  } else {
    return 0;
  }
  return 0;
}


int keySetup(TSS_HCONTEXT *hContext) {

  TSS_UUID SRK_UUID = TSS_UUID_SRK;
  TSS_UUID thisID = {9};
  TSS_FLAG initFlags;
  TSS_HKEY hSRK, hKey, temp;
  TSS_HPOLICY hPolicy;
  initFlags = TSS_KEY_TYPE_STORAGE | TSS_KEY_SIZE_2048 |
              TSS_KEY_NO_AUTHORIZATION | TSS_KEY_NOT_MIGRATABLE;

  /* Load the new key’s parent key, the Storage Root Key */
  Tspi_Context_LoadKeyByUUID(*hContext, TSS_PS_TYPE_SYSTEM, SRK_UUID,
&hSRK);
  /* Create the software key object */
  Tspi_Context_CreateObject(*hContext, TSS_OBJECT_TYPE_RSAKEY, initFlags,
                            &hKey);
  Tspi_Key_CreateKey(hKey, hSRK, 0);
  Tspi_Context_UnregisterKey(*hContext, TSS_PS_TYPE_SYSTEM, thisID, &temp);
  printf("%u is register error\n",
         Tspi_Context_RegisterKey(*hContext, hKey, TSS_PS_TYPE_SYSTEM,
thisID,
                                  TSS_PS_TYPE_SYSTEM, SRK_UUID));
  return 0;
}
_______________________________________________
TrouSerS-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-users

Reply via email to