OLD | NEW |
(Empty) | |
| 1 /* Software-based Mobile Trusted Module (MTM) Emulator |
| 2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net> |
| 3 * |
| 4 * This module is free software; you can redistribute it and/or modify |
| 5 * it under the terms of the GNU General Public License as published |
| 6 * by the Free Software Foundation; either version 2 of the License, |
| 7 * or (at your option) any later version. |
| 8 * |
| 9 * This module is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * $Id$ |
| 15 */ |
| 16 |
| 17 #include "mtm_handles.h" |
| 18 #include "mtm_data.h" |
| 19 |
| 20 MTM_KEY_DATA *mtm_get_key_slot(TPM_VERIFICATION_KEY_HANDLE handle) |
| 21 { |
| 22 if (handle == TPM_INVALID_HANDLE) return NULL; |
| 23 handle &= 0x00ffffff; |
| 24 if (handle < TPM_MAX_KEYS) return NULL; |
| 25 handle -= TPM_MAX_KEYS; |
| 26 if (handle >= MTM_MAX_KEYS) return NULL; |
| 27 return &mtmData.permanent.data.keys[handle]; |
| 28 } |
| 29 |
| 30 MTM_KEY_DATA *mtm_get_key(TPM_VERIFICATION_KEY_HANDLE handle) |
| 31 { |
| 32 if (handle == TPM_INVALID_HANDLE |
| 33 || (handle >> 24) != TPM_RT_KEY) return NULL; |
| 34 handle &= 0x00ffffff; |
| 35 if (handle < TPM_MAX_KEYS) return NULL; |
| 36 handle -= TPM_MAX_KEYS; |
| 37 if (handle >= MTM_MAX_KEYS |
| 38 || !mtmData.permanent.data.keys[handle].valid) return NULL; |
| 39 return &mtmData.permanent.data.keys[handle]; |
| 40 } |
| 41 |
| 42 MTM_KEY_DATA *mtm_get_key_by_id(TPM_VERIFICATION_KEY_ID id) |
| 43 { |
| 44 int i; |
| 45 for (i = 0; i < MTM_MAX_KEYS; i++) { |
| 46 if (mtmData.permanent.data.keys[i].valid |
| 47 && mtmData.permanent.data.keys[i].myId == id) |
| 48 return &mtmData.permanent.data.keys[i]; |
| 49 } |
| 50 return NULL; |
| 51 } |
| 52 |
OLD | NEW |