2 * This file is part of the OpenPTS project.
4 * The Initial Developer of the Original Code is International
5 * Business Machines Corporation. Portions created by IBM
6 * Corporation are Copyright (C) 2011 International Business
7 * Machines Corporation. All Rights Reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the Common Public License as published by
11 * IBM Corporation; either version 1 of the License, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * Common Public License for more details.
19 * You should have received a copy of the Common Public License
20 * along with this program; if not, a copy can be viewed at
21 * http://www.opensource.org/licenses/cpl1.0.php.
25 * \file include/openpts_tpm.h
27 * @author Seiji Munetoh <munetoh@users.sourceforge.jp>
33 #ifndef INCLUDE_OPENPTS_TPM_H_
34 #define INCLUDE_OPENPTS_TPM_H_
37 #define MAX_PCRNUM 24 // TPM v1.2
39 // 20100614 support SHA1, SHA256, SHA512
40 #define MAX_DIGEST_SIZE 64
41 #define SHA1_DIGEST_SIZE 20
42 #define SHA256_DIGEST_SIZE 32
43 #define SHA512_DIGEST_SIZE 64
45 #define SHA1_BASE64_DIGEST_SIZE 28
46 #define SHA256_BASE64_DIGEST_SIZE 44
47 #define SHA512_BASE64_DIGEST_SIZE 88 // TODO(munetoh)
54 BYTE pcr[MAX_PCRNUM][SHA1_DIGEST_SIZE]; /**< */
55 // TODO(munetoh) add AIK
56 } OPENPTS_TPM_CONTEXT;
61 * TODO(munetoh) change to OPENPTS_QUOTE
66 int pcr_select[MAX_PCRNUM];
67 BYTE pcr[MAX_PCRNUM][MAX_DIGEST_SIZE];
71 BYTE *pcr_select_byte;
73 /* ValidationData ? */
83 #define EV_COLLECTOR_START 0x80 // 128
84 #define EV_FILE_SCAN 0x84 // 132 by TDDL?
85 #define EV_FILE_SCAN_TSS 0x86 // 134 by Tspi_TPM_PcrExtend()
91 TSS_VERSION pts_version; // PTS_VERSION
92 PTS_UUID collector_uuid;
93 PTS_UUID manifest_uuid;
94 BYTE pcr_value[SHA1_DIGEST_SIZE];
95 } OPENPTS_EVENT_COLLECTOR_START;
105 BYTE digest[SHA1_DIGEST_SIZE];
106 UINT32 filename_length;
108 } OPENPTS_EVENT_FILE_SCAN;
111 int resetTpm(OPENPTS_TPM_CONTEXT *tctx, int drtm);
112 int extendTpm(OPENPTS_TPM_CONTEXT *tctx, TSS_PCR_EVENT *event);
113 int extendTpm2(OPENPTS_TPM_CONTEXT *tctx, int index, BYTE* digest);
114 int checkTpmPcr(OPENPTS_TPM_CONTEXT *tctx, TSS_PCR_EVENT *event);
115 int checkTpmPcr2(OPENPTS_TPM_CONTEXT *tctx, int index, BYTE* digest);
116 int printTpm(OPENPTS_TPM_CONTEXT *tctx);
117 int getTpmPcrValue(OPENPTS_TPM_CONTEXT *tpm, int index, BYTE *digest);
118 int resetTpmPcr(OPENPTS_TPM_CONTEXT *tctx, int index);
121 int printTssKeyList(int ps_type);
122 int createTssSignKey(
123 PTS_UUID *uuid, int ps_type, char *filename, int force, int srk_password_mode);
124 int deleteTssKey(PTS_UUID *uuid, int ps_type);
125 int getTpmVersion(TSS_VERSION *version);
128 int ps_type, int srk_password_mode, int resetdalock,
130 int *pubkey_length, BYTE **pubkey);
134 int srk_password_mode,
138 TSS_VALIDATION *validationData);
142 int srk_password_mode,
146 TSS_VALIDATION *validationData);
147 int validateQuoteData(OPENPTS_PCRS *pcrs, TSS_VALIDATION *validationData);
148 int validatePcrCompositeV11(OPENPTS_PCRS *pcrs, TSS_VALIDATION *validationData);
149 int validatePcrCompositeV12(OPENPTS_PCRS *pcrs, TSS_VALIDATION *validationData);
150 int getRandom(BYTE *out, int size);
151 int extendEvent(TSS_PCR_EVENT* event);
152 int readPcr(int pcr_index, BYTE *pcr);
153 int getTpmStatus(TSS_FLAG flag, TSS_BOOL *value, int tpm_password_mode);
154 int setTpmStatus(TSS_FLAG flag, TSS_BOOL value, int tpm_password_mode);
156 #endif // INCLUDE_OPENPTS_TPM_H_