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_transport.c 367 2010-02-13 15:52:18Z mast $ |
16 */ | 15 */ |
17 | 16 |
18 /* | 17 /* |
19 * Thanks go to Edison Su (<sudison@gmail.com>) for providing | 18 * Thanks go to Edison Su (<sudison@gmail.com>) for providing |
20 * the initial Transport Session patch. | 19 * the initial Transport Session patch. |
21 */ | 20 */ |
22 | 21 |
23 #include "tpm_emulator.h" | 22 #include "tpm_emulator.h" |
24 #include "tpm_commands.h" | 23 #include "tpm_commands.h" |
25 #include "tpm_handles.h" | 24 #include "tpm_handles.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 buf_len--; | 238 buf_len--; |
240 } | 239 } |
241 } | 240 } |
242 } | 241 } |
243 | 242 |
244 static void compute_key_digest(TPM_REQUEST *req, TPM_DIGEST *digest) | 243 static void compute_key_digest(TPM_REQUEST *req, TPM_DIGEST *digest) |
245 { | 244 { |
246 tpm_sha1_ctx_t ctx; | 245 tpm_sha1_ctx_t ctx; |
247 TPM_HANDLE h1, h2; | 246 TPM_HANDLE h1, h2; |
248 TPM_KEY_DATA *k1, *k2; | 247 TPM_KEY_DATA *k1, *k2; |
249 BYTE *ptr, buf[4]; | 248 BYTE *ptr; |
250 UINT32 len, offset = tpm_get_in_param_offset(req->ordinal); | 249 UINT32 len, offset = tpm_get_in_param_offset(req->ordinal); |
251 /* handle some exceptions */ | 250 /* handle some exceptions */ |
252 if (req->ordinal == TPM_ORD_FlushSpecific) offset = 0; | 251 if (req->ordinal == TPM_ORD_FlushSpecific) offset = 0; |
253 else if (req->ordinal == TPM_ORD_OwnerReadInternalPub) offset = 4; | 252 else if (req->ordinal == TPM_ORD_OwnerReadInternalPub) offset = 4; |
254 /* compute public key digests */ | 253 /* compute public key digests */ |
255 if (offset == 0) { | 254 if (offset == 0) { |
256 debug("no handles"); | 255 debug("no handles"); |
257 memset(digest, 0, sizeof(TPM_DIGEST)); | 256 memset(digest, 0, sizeof(TPM_DIGEST)); |
258 } else if (offset == 4) { | 257 } else if (offset == 4) { |
259 debug("one handle"); | 258 debug("one handle"); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 res = tpm_sign(key, auth1, FALSE, buf, SHA1_DIGEST_LENGTH, sig, sigSize); | 466 res = tpm_sign(key, auth1, FALSE, buf, SHA1_DIGEST_LENGTH, sig, sigSize); |
468 } else if (key->sigScheme == TPM_SS_RSASSAPKCS1v15_INFO) { | 467 } else if (key->sigScheme == TPM_SS_RSASSAPKCS1v15_INFO) { |
469 debug("TPM_SS_RSASSAPKCS1v15_INFO"); | 468 debug("TPM_SS_RSASSAPKCS1v15_INFO"); |
470 res = tpm_sign(key, auth1, TRUE, buf, sizeof(buf), sig, sigSize); | 469 res = tpm_sign(key, auth1, TRUE, buf, sizeof(buf), sig, sigSize); |
471 } else { | 470 } else { |
472 debug("unsupported signature scheme: %02x", key->sigScheme); | 471 debug("unsupported signature scheme: %02x", key->sigScheme); |
473 res = TPM_INVALID_KEYUSAGE; | 472 res = TPM_INVALID_KEYUSAGE; |
474 } | 473 } |
475 return res; | 474 return res; |
476 } | 475 } |
OLD | NEW |