Hi,

I am trying to use the Tspi_TPM_PcrReset(hTPM, hPcrs) function.
It is working for pcrs 16 and 23 and I can't reset pcrs 17 to 22 for
locality reason which is fine.
But when I try to reset pcrs from 0 to 15 I get an error Bad input size.
Any idea why it is happening ? and how to reset those pcrs ?

I am working on an arm embeded system with an i2c wired tpm chip:
Linux v2r1 3.14.36ltsi-yocto-standard #12 Tue Sep 15 11:57:15 CEST
2015 armv7l GNU/Linux

  TPM 1.2 Version Info:
  Chip Version:        1.2.66.4
  Spec Level:          2
  Errata Revision:     3
  TPM Vendor ID:       ATML
  TPM Version:         01010000
  Manufacturer Info:   41544d4c

Here is the code I used:

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

#include <trousers/tss.h>
#include <trousers/trousers.h>

static void exit_on_error(char *msg, int status)
{
    fprintf(stderr, "%s\n", msg);
    exit(status);
}

static void check_args(int argc, char *argv[], UINT32 *pcrIndex)
{
  if (argc != 2 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)
    exit_on_error("Usage: reset_pcr pcrIndex\n", 1);

  *pcrIndex = strtol(argv[1], NULL, 0);
  if (errno == ERANGE || errno == EINVAL || *pcrIndex > 23)
    exit_on_error("pcrIndex must be an int between 0 and 23\n", 1);
}

int main(int argc, char *argv[])
{
    TSS_HCONTEXT hContext = 0;
    TSS_HTPM hTPM = 0;
    TSS_RESULT result;
    TSS_HPCRS hPcrs;
    UINT32 pcrIndex = 0;

    check_args(argc, argv, &pcrIndex);

    if ((result = Tspi_Context_Create(&hContext)) != TSS_SUCCESS)
        exit_on_error(Trspi_Error_String(result), 2);
    if ((result = Tspi_Context_Connect(hContext, NULL)) != TSS_SUCCESS)
        exit_on_error(Trspi_Error_String(result), 3);
    if ((result = Tspi_Context_GetTpmObject(hContext, &hTPM)) != TSS_SUCCESS)
        exit_on_error(Trspi_Error_String(result), 4);

    if ((result = Tspi_Context_CreateObject(hContext, TSS_OBJECT_TYPE_PCRS,
                                                    0, &hPcrs)) != TSS_SUCCESS)
        exit_on_error(Trspi_Error_String(result), 5);

    if ((result = Tspi_PcrComposite_SelectPcrIndex(hPcrs,
                                                     pcrIndex)) != TSS_SUCCESS)
        exit_on_error(Trspi_Error_String(result), 6);

    if ((result = Tspi_TPM_PcrReset(hTPM, hPcrs)) != TSS_SUCCESS)
        exit_on_error(Trspi_Error_String(result), 7);


    Tspi_Context_FreeMemory(hContext, NULL);
    Tspi_Context_Close(hContext);
    return 0;
}

Thanks.

-- 
Ismael

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
TrouSerS-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-users

Reply via email to