| OLD | NEW |
| 1 /* Software-Based Trusted Platform Module (TPM) Emulator for Linux | 1 /* Software-based Trusted Platform Module (TPM) Emulator |
| 2 * Copyright (C) 2004 Mario Strasser <mast@gmx.net>, | 2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net> |
| 3 * Swiss Federal Institute of Technology (ETH) Zurich | 3 * 2005-2008 Heiko Stamer <stamer@gaos.org> |
| 4 * 2006, 2007 Heiko Stamer <stamer@gaos.org> | |
| 5 * | 4 * |
| 6 * This module is free software; you can redistribute it and/or modify | 5 * This module is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License as published | 6 * it under the terms of the GNU General Public License as published |
| 8 * by the Free Software Foundation; either version 2 of the License, | 7 * by the Free Software Foundation; either version 2 of the License, |
| 9 * or (at your option) any later version. | 8 * or (at your option) any later version. |
| 10 * | 9 * |
| 11 * This module is distributed in the hope that it will be useful, | 10 * This module is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 * GNU General Public License for more details. | 13 * GNU General Public License for more details. |
| 15 * | 14 * |
| 16 * $Id$ | 15 * $Id: tpm_structures.h 367 2010-02-13 15:52:18Z mast $ |
| 17 */ | 16 */ |
| 18 | 17 |
| 19 #ifndef _TPM_STRUCTURES_H_ | 18 #ifndef _TPM_STRUCTURES_H_ |
| 20 #define _TPM_STRUCTURES_H_ | 19 #define _TPM_STRUCTURES_H_ |
| 21 | 20 |
| 22 #include "tpm_emulator.h" | 21 #include "tpm_emulator.h" |
| 23 #include "crypto/rsa.h" | 22 #include "crypto/rsa.h" |
| 24 | 23 |
| 25 /* | 24 /* |
| 26 * The following types and structures are specified in | 25 * The following types and structures are specified in |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 #define TPM_ET_DATA 0x03 | 142 #define TPM_ET_DATA 0x03 |
| 144 #define TPM_ET_SRK 0x04 | 143 #define TPM_ET_SRK 0x04 |
| 145 #define TPM_ET_KEY 0x05 | 144 #define TPM_ET_KEY 0x05 |
| 146 #define TPM_ET_REVOKE 0x06 | 145 #define TPM_ET_REVOKE 0x06 |
| 147 #define TPM_ET_DEL_OWNER_BLOB 0x07 | 146 #define TPM_ET_DEL_OWNER_BLOB 0x07 |
| 148 #define TPM_ET_DEL_ROW 0x08 | 147 #define TPM_ET_DEL_ROW 0x08 |
| 149 #define TPM_ET_DEL_KEY_BLOB 0x09 | 148 #define TPM_ET_DEL_KEY_BLOB 0x09 |
| 150 #define TPM_ET_COUNTER 0x0A | 149 #define TPM_ET_COUNTER 0x0A |
| 151 #define TPM_ET_NV 0x0B | 150 #define TPM_ET_NV 0x0B |
| 152 #define TPM_ET_OPERATOR 0x0C | 151 #define TPM_ET_OPERATOR 0x0C |
| 152 #define TPM_ET_VERIFICATION_AUTH 0x0D |
| 153 #define TPM_ET_RESERVED_HANDLE 0x40 | 153 #define TPM_ET_RESERVED_HANDLE 0x40 |
| 154 /* MSB Values */ | 154 /* MSB Values */ |
| 155 #define TPM_ET_XOR 0x00 | 155 #define TPM_ET_XOR 0x00 |
| 156 #define TPM_ET_AES128_CTR 0x06 | 156 #define TPM_ET_AES128_CTR 0x06 |
| 157 | 157 |
| 158 /* | 158 /* |
| 159 * Reserved Key Handles ([TPM_Part2], Section 4.4.1) | 159 * Reserved Key Handles ([TPM_Part2], Section 4.4.1) |
| 160 * These values specify specific keys or specific actions for the TPM. | 160 * These values specify specific keys or specific actions for the TPM. |
| 161 */ | 161 */ |
| 162 #define TPM_KH_SRK 0x40000000 | 162 #define TPM_KH_SRK 0x40000000 |
| (...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 if (s->keys[i].payload != TPM_PT_NONE) | 2229 if (s->keys[i].payload != TPM_PT_NONE) |
| 2230 size += sizeof_TPM_KEY_DATA((s->keys[i])); | 2230 size += sizeof_TPM_KEY_DATA((s->keys[i])); |
| 2231 else | 2231 else |
| 2232 size += 1; | 2232 size += 1; |
| 2233 } | 2233 } |
| 2234 size += TPM_NUM_TIS_TIMEOUTS * 4; | 2234 size += TPM_NUM_TIS_TIMEOUTS * 4; |
| 2235 size += TPM_NUM_CMD_DURATIONS * 4; | 2235 size += TPM_NUM_CMD_DURATIONS * 4; |
| 2236 return size; | 2236 return size; |
| 2237 } | 2237 } |
| 2238 | 2238 |
| 2239 static inline void free_TPM_PERMANENT_DATA(TPM_PERMANENT_DATA *s) |
| 2240 { |
| 2241 int i; |
| 2242 /* release the EK, SRK as well as all other rsa keys */ |
| 2243 if (s->endorsementKey.size > 0) tpm_rsa_release_private_key(&s->endorsementKey
); |
| 2244 if (s->srk.payload) free_TPM_KEY_DATA(s->srk); |
| 2245 if (s->manuMaintPub.valid) free_TPM_PUBKEY_DATA(s->manuMaintPub); |
| 2246 for (i = 0; i < TPM_MAX_KEYS; i++) |
| 2247 if (s->keys[i].payload) free_TPM_KEY_DATA(s->keys[i]); |
| 2248 } |
| 2249 |
| 2239 /* | 2250 /* |
| 2240 * TPM_STCLEAR_DATA ([TPM_Part2], Section 7.5) | 2251 * TPM_STCLEAR_DATA ([TPM_Part2], Section 7.5) |
| 2241 * Most of the data in this structure resets on TPM_Startup(ST_Clear). | 2252 * Most of the data in this structure resets on TPM_Startup(ST_Clear). |
| 2242 * | 2253 * |
| 2243 * This is an informative structure and not normative. | 2254 * This is an informative structure and not normative. |
| 2244 */ | 2255 */ |
| 2245 #define TPM_TAG_STCLEAR_DATA 0x0023 | 2256 #define TPM_TAG_STCLEAR_DATA 0x0023 |
| 2246 typedef struct tdTPM_STCLEAR_DATA { | 2257 typedef struct tdTPM_STCLEAR_DATA { |
| 2247 TPM_STRUCTURE_TAG tag; | 2258 TPM_STRUCTURE_TAG tag; |
| 2248 TPM_NONCE contextNonceKey; | 2259 TPM_NONCE contextNonceKey; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2340 } permanent; | 2351 } permanent; |
| 2341 struct { | 2352 struct { |
| 2342 TPM_STCLEAR_FLAGS flags; | 2353 TPM_STCLEAR_FLAGS flags; |
| 2343 TPM_STCLEAR_DATA data; | 2354 TPM_STCLEAR_DATA data; |
| 2344 } stclear; | 2355 } stclear; |
| 2345 struct { | 2356 struct { |
| 2346 TPM_STANY_FLAGS flags; | 2357 TPM_STANY_FLAGS flags; |
| 2347 TPM_STANY_DATA data; | 2358 TPM_STANY_DATA data; |
| 2348 } stany; | 2359 } stany; |
| 2349 } TPM_DATA; | 2360 } TPM_DATA; |
| 2361 #define sizeof_TPM_DATA(s) ( \ |
| 2362 sizeof_TPM_PERMANENT_FLAGS(s.permanent.flags) + 2 \ |
| 2363 + sizeof_TPM_PERMANENT_DATA(&s.permanent.data) \ |
| 2364 + sizeof_TPM_STCLEAR_FLAGS(s.stclear.flags) \ |
| 2365 + sizeof_TPM_STCLEAR_DATA(s.stclear.data) \ |
| 2366 + sizeof_TPM_STANY_DATA(s.stany.data)) |
| 2367 #define free_TPM_DATA(s) { free_TPM_PERMANENT_DATA(&s.permanent.data); } |
| 2350 | 2368 |
| 2351 /* | 2369 /* |
| 2352 * Context Structures | 2370 * Context Structures |
| 2353 */ | 2371 */ |
| 2354 | 2372 |
| 2355 /* | 2373 /* |
| 2356 * TPM_CONTEXT_BLOB ([TPM_Part2], Section 18.1) | 2374 * TPM_CONTEXT_BLOB ([TPM_Part2], Section 18.1) |
| 2357 * This is the header for the wrapped context. The blob contains all | 2375 * This is the header for the wrapped context. The blob contains all |
| 2358 * information necessary to reload the context back into the TPM. | 2376 * information necessary to reload the context back into the TPM. |
| 2359 */ | 2377 */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 TPM_TAG tag; | 2440 TPM_TAG tag; |
| 2423 UINT32 size; | 2441 UINT32 size; |
| 2424 TPM_RESULT result; | 2442 TPM_RESULT result; |
| 2425 BYTE *param; | 2443 BYTE *param; |
| 2426 UINT32 paramSize; | 2444 UINT32 paramSize; |
| 2427 TPM_AUTH *auth1; | 2445 TPM_AUTH *auth1; |
| 2428 TPM_AUTH *auth2; | 2446 TPM_AUTH *auth2; |
| 2429 } TPM_RESPONSE; | 2447 } TPM_RESPONSE; |
| 2430 | 2448 |
| 2431 #endif /* _TPM_STRUCTURES_H_ */ | 2449 #endif /* _TPM_STRUCTURES_H_ */ |
| OLD | NEW |