コード例 #1
0
ファイル: tpmtest_timing.c プロジェクト: coreboot/vboot
int main(int argc, char** argv) {
	uint32_t x;
	uint8_t in[20], out[20];
	int time_limit_exceeded = 0;
	int errors = 0;

	TlclLibInit();
	TTPM_CHECK(0, 50);
	TTPM_CHECK(TlclStartupIfNeeded(), 50);
	TTPM_CHECK(TlclContinueSelfTest(), 100);
	TTPM_CHECK(TlclSelfTestFull(), 1000);
	TTPM_CHECK(TlclAssertPhysicalPresence(), 100);
	TTPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), 100);
	TTPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)), 100);
	TTPM_CHECK(TlclExtend(0, in, out), 200);
	TTPM_CHECK(TlclSetGlobalLock(), 50);
	TTPM_CHECK(TlclLockPhysicalPresence(), 100);
	if (time_limit_exceeded || errors > 0) {
		printf("TEST FAILED\n");
		exit(1);
	} else {
		printf("TEST SUCCEEDED\n");
		return 0;
	}
}
コード例 #2
0
int main(int argc, char** argv) {
  uint32_t perm;
  uint32_t result;
  uint32_t x;

  TlclLibInit();

  TPM_CHECK(TlclStartupIfNeeded());
  TPM_CHECK(TlclSelfTestFull());
  TPM_CHECK(TlclAssertPhysicalPresence());
  TPM_CHECK(TlclForceClear());
  TPM_CHECK(TlclSetEnable());
  TPM_CHECK(TlclSetDeactivated(0));

  result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x));
  if (result == TPM_E_BADINDEX) {
    perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
    TPM_CHECK(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)));
  }

  result = TlclRead(INDEX1, (uint8_t*) &x, sizeof(x));
  if (result == TPM_E_BADINDEX) {
    perm = TPM_NV_PER_PPWRITE;
    TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
  }

  printf("TEST SUCCEEDED\n");
  exit(0);
}
コード例 #3
0
int main(int argc, char** argv) {
    uint8_t disable, deactivated;
    int i;

    TlclLibInit();
    TPM_CHECK(TlclStartupIfNeeded());
    TPM_CHECK(TlclSelfTestFull());
    TPM_CHECK(TlclAssertPhysicalPresence());
    TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
    printf("disable is %d, deactivated is %d\n", disable, deactivated);

    for (i = 0; i < 2; i++) {
        TPM_CHECK(TlclForceClear());
        TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
        printf("disable is %d, deactivated is %d\n", disable, deactivated);
        VbAssert(disable == 1 && deactivated == 1);
        TPM_CHECK(TlclSetEnable());
        TPM_CHECK(TlclSetDeactivated(0));
        TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
        printf("disable is %d, deactivated is %d\n", disable, deactivated);
        VbAssert(disable == 0 && deactivated == 0);
    }

    printf("TEST SUCCEEDED\n");
    return 0;
}
コード例 #4
0
int main(int argc, char** argv) {
  uint8_t disable, deactivated;

  TlclLibInit();
  TPM_CHECK(TlclStartupIfNeeded());
  TPM_CHECK(TlclSelfTestFull());
  TPM_CHECK(TlclAssertPhysicalPresence());
  TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
  printf("disable is %d, deactivated is %d\n", disable, deactivated);
  TPM_CHECK(TlclSetEnable());
  TPM_CHECK(TlclSetDeactivated(0));
  TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
  printf("disable is %d, deactivated is %d\n", disable, deactivated);
  if (disable == 1 || deactivated == 1) {
    VbExError("failed to enable or activate");
  }
  printf("TEST SUCCEEDED\n");
  return 0;
}