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 | |
4 * | 3 * |
5 * This module is free software; you can redistribute it and/or modify | 4 * This module is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published | 5 * it under the terms of the GNU General Public License as published |
7 * by the Free Software Foundation; either version 2 of the License, | 6 * by the Free Software Foundation; either version 2 of the License, |
8 * or (at your option) any later version. | 7 * or (at your option) any later version. |
9 * | 8 * |
10 * This module is distributed in the hope that it will be useful, | 9 * This module is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
14 * | 13 * |
15 * $Id$ | 14 * $Id: tpm_audit.c 385 2010-02-17 15:41:28Z mast $ |
16 */ | 15 */ |
17 | 16 |
18 #include "tpm_emulator.h" | 17 #include "tpm_emulator.h" |
19 #include "tpm_commands.h" | 18 #include "tpm_commands.h" |
20 #include "tpm_data.h" | 19 #include "tpm_data.h" |
21 #include "tpm_marshalling.h" | 20 #include "tpm_marshalling.h" |
22 #include "tpm_handles.h" | 21 #include "tpm_handles.h" |
23 #include <crypto/sha1.h> | 22 #include <crypto/sha1.h> |
24 | 23 |
25 /* | 24 /* |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 tpm_sha1_init(&sha1_ctx); | 58 tpm_sha1_init(&sha1_ctx); |
60 tpm_sha1_update(&sha1_ctx, tpmData.stany.data.auditDigest.digest, sizeof(TPM
_DIGEST)); | 59 tpm_sha1_update(&sha1_ctx, tpmData.stany.data.auditDigest.digest, sizeof(TPM
_DIGEST)); |
61 tpm_sha1_update(&sha1_ctx, buf, sizeof(buf)); | 60 tpm_sha1_update(&sha1_ctx, buf, sizeof(buf)); |
62 tpm_sha1_final(&sha1_ctx, tpmData.stany.data.auditDigest.digest); | 61 tpm_sha1_final(&sha1_ctx, tpmData.stany.data.auditDigest.digest); |
63 } | 62 } |
64 } | 63 } |
65 | 64 |
66 void tpm_audit_response(TPM_COMMAND_CODE ordinal, TPM_RESPONSE *rsp) | 65 void tpm_audit_response(TPM_COMMAND_CODE ordinal, TPM_RESPONSE *rsp) |
67 { | 66 { |
68 tpm_sha1_ctx_t sha1_ctx; | 67 tpm_sha1_ctx_t sha1_ctx; |
69 BYTE buf[sizeof_TPM_AUDIT_EVENT_OUT()], *ptr; | 68 BYTE buf[sizeof_TPM_AUDIT_EVENT_OUT(x)], *ptr; |
70 UINT32 len; | 69 UINT32 len; |
71 TPM_COMMAND_CODE ord = ordinal & TPM_ORD_INDEX_MASK; | 70 TPM_COMMAND_CODE ord = ordinal & TPM_ORD_INDEX_MASK; |
72 if (ord < TPM_ORD_MAX | 71 if (ord < TPM_ORD_MAX |
73 && (AUDIT_STATUS[ord / 8] & (1 << (ord & 0x07)))) { | 72 && (AUDIT_STATUS[ord / 8] & (1 << (ord & 0x07)))) { |
74 info("tpm_audit_response()"); | 73 info("tpm_audit_response()"); |
75 /* update audit digest */ | 74 /* update audit digest */ |
76 ptr = buf; len = sizeof(buf); | 75 ptr = buf; len = sizeof(buf); |
77 tpm_marshal_TPM_TAG(&ptr, &len, TPM_TAG_AUDIT_EVENT_OUT); | 76 tpm_marshal_TPM_TAG(&ptr, &len, TPM_TAG_AUDIT_EVENT_OUT); |
78 tpm_marshal_TPM_COMMAND_CODE(&ptr, &len, ordinal); | 77 tpm_marshal_TPM_COMMAND_CODE(&ptr, &len, ordinal); |
79 tpm_sha1_init(&sha1_ctx); | 78 tpm_sha1_init(&sha1_ctx); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 if (ordinalToAudit > TPM_ORD_MAX) return TPM_BADINDEX; | 227 if (ordinalToAudit > TPM_ORD_MAX) return TPM_BADINDEX; |
229 ordinalToAudit &= TPM_ORD_INDEX_MASK; | 228 ordinalToAudit &= TPM_ORD_INDEX_MASK; |
230 if (auditState) { | 229 if (auditState) { |
231 AUDIT_STATUS[ordinalToAudit / 8] |= (1 << (ordinalToAudit & 0x07)); | 230 AUDIT_STATUS[ordinalToAudit / 8] |= (1 << (ordinalToAudit & 0x07)); |
232 } else { | 231 } else { |
233 AUDIT_STATUS[ordinalToAudit / 8] &= ~(1 << (ordinalToAudit & 0x07)); | 232 AUDIT_STATUS[ordinalToAudit / 8] &= ~(1 << (ordinalToAudit & 0x07)); |
234 } | 233 } |
235 return TPM_SUCCESS; | 234 return TPM_SUCCESS; |
236 } | 235 } |
237 | 236 |
OLD | NEW |