HP-UX Trusted Computing Services A.02.00 Administrator's Guide
if(parseOptions(argc, argv) != 0) {
goto out;
}
// Ensure that data to be 'binded' is no larger than our keysize
if(strlen(secret) > 256) {
fprintf(stderr, "Error: Secret to be bound to TPM is too large.\n
Please limit the secret to 256 characters\n");
}
// Start a TSS session
tResult = Tspi_Context_Create(&hContext);
if (tResult != TSS_SUCCESS) {
fprintf(stderr, "Tspi_Context_Create failed. Error: %s\n",
Trspi_Error_String(tResult));
goto out;
}
// Connect to TCSD
if(host) {
tResult = Tspi_Context_Connect(hContext,
(UNICODE *)Trspi_Native_To_UNICODE((BYTE *)host, NULL));
}
else {
tResult = Tspi_Context_Connect(hContext, NULL);
}
if (tResult != TSS_SUCCESS) {
fprintf(stderr, "Tspi_Context_Connect failed. Error: %s\n",
Trspi_Error_String(tResult));
goto out_close;
}
// Get a software representation of the TPM
if (Tspi_Context_GetTpmObject(hContext, &hTpm) != TSS_SUCCESS) {
fprintf(stderr, "Tspi_Context_GetTpmObject failed. Error: %s\n",
Trspi_Error_String(tResult));
goto out_close;
}
// Load Storage Root Key by UUID
tResult = Tspi_Context_LoadKeyByUUID(hContext, TSS_PS_TYPE_SYSTEM,
SRK_UUID, &hSRK);
if (tResult != TSS_SUCCESS) {
fprintf(stderr, "Tspi_Context_LoadKeyByUUID failed. Error: %s\n",
Trspi_Error_String(tResult));
goto out_close;
}
// Set the correct SRK policy
tResult = Tspi_GetPolicyObject(hSRK, TSS_POLICY_USAGE, &hSRKp);
if (tResult != TSS_SUCCESS) {
fprintf(stderr, "Tspi_GetPolicyObject failed. Error: %s\n",
Trspi_Error_String(tResult));
goto out_close;
}
tResult = Tspi_Policy_SetSecret(hSRKp, TSS_SECRET_MODE_PLAIN, 0,
(BYTE *)0);
if (tResult != TSS_SUCCESS) {
fprintf(stderr, "Tspi_Policy_SetSecret failed. Error: %s\n",
Trspi_Error_String(tResult));
goto out_close;
}
// Actually create the key in the TPM
94 Sample TSS Application