| 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 * | 3 * |
| 4 * 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 |
| 5 * 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 |
| 6 * by the Free Software Foundation; either version 2 of the License, | 6 * by the Free Software Foundation; either version 2 of the License, |
| 7 * or (at your option) any later version. | 7 * or (at your option) any later version. |
| 8 * | 8 * |
| 9 * 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, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * $Id$ | 14 * $Id: tpm_emulator_extern.h 389 2010-02-18 09:52:11Z mast $ |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #ifndef _TPM_EMULATOR_EXTERN_H_ | 17 #ifndef _TPM_EMULATOR_EXTERN_H_ |
| 18 #define _TPM_EMULATOR_EXTERN_H_ | 18 #define _TPM_EMULATOR_EXTERN_H_ |
| 19 | 19 |
| 20 #include <stdint.h> | 20 #include <inttypes.h> |
| 21 #include <stdlib.h> | 21 #include <stdlib.h> |
| 22 #include <string.h> | 22 #include <string.h> |
| 23 #include <syslog.h> | |
| 24 | |
| 25 /* TPM emulator configuration */ | |
| 26 | |
| 27 #undef TPM_STRONG_PERSISTENCE | |
| 28 #undef TPM_GENERATE_EK | |
| 29 #undef TPM_GENERATE_SEED_DAA | |
| 30 #undef TPM_USE_INTERNAL_PRNG | |
| 31 #undef TPM_ENABLE_PRNG_STATE_SETTING | |
| 32 | 23 |
| 33 /* log functions */ | 24 /* log functions */ |
| 34 | 25 |
| 26 enum { |
| 27 TPM_LOG_DEBUG, |
| 28 TPM_LOG_INFO, |
| 29 TPM_LOG_ERROR |
| 30 }; |
| 31 |
| 35 void tpm_log(int priority, const char *fmt, ...); | 32 void tpm_log(int priority, const char *fmt, ...); |
| 36 | 33 |
| 37 #define debug(fmt, ...) tpm_log(LOG_DEBUG, "%s:%d: Debug: " fmt "\n", \ | 34 #define debug(fmt, ...) tpm_log(TPM_LOG_DEBUG, "%s:%d: Debug: " fmt "\n", \ |
| 38 __FILE__, __LINE__, ## __VA_ARGS__) | 35 __FILE__, __LINE__, ## __VA_ARGS__) |
| 39 #define info(fmt, ...) tpm_log(LOG_INFO, "%s:%d: Info: " fmt "\n", \ | 36 #define info(fmt, ...) tpm_log(TPM_LOG_INFO, "%s:%d: Info: " fmt "\n", \ |
| 40 __FILE__, __LINE__, ## __VA_ARGS__) | 37 __FILE__, __LINE__, ## __VA_ARGS__) |
| 41 #define error(fmt, ...) tpm_log(LOG_ERR, "%s:%d: Error: " fmt "\n", \ | 38 #define error(fmt, ...) tpm_log(TPM_LOG_ERROR, "%s:%d: Error: " fmt "\n", \ |
| 42 __FILE__, __LINE__, ## __VA_ARGS__) | |
| 43 #define alert(fmt, ...) tpm_log(LOG_ALERT, "%s:%d: Alert: " fmt "\n", \ | |
| 44 __FILE__, __LINE__, ## __VA_ARGS__) | 39 __FILE__, __LINE__, ## __VA_ARGS__) |
| 45 | 40 |
| 46 /* memory allocation */ | 41 /* memory allocation */ |
| 47 | 42 |
| 48 void *tpm_malloc(size_t size); | 43 void *tpm_malloc(size_t size); |
| 49 | 44 |
| 50 void tpm_free(/*const*/ void *ptr); | 45 void tpm_free(/*const*/ void *ptr); |
| 51 | 46 |
| 52 /* random numbers */ | 47 /* random numbers */ |
| 53 | 48 |
| 54 void tpm_get_extern_random_bytes(void *buf, size_t nbytes); | 49 void tpm_get_extern_random_bytes(void *buf, size_t nbytes); |
| 55 | 50 |
| 56 /* usec since last call */ | 51 /* usec since last call */ |
| 57 | 52 |
| 58 uint64_t tpm_get_ticks(void); | 53 uint64_t tpm_get_ticks(void); |
| 59 | 54 |
| 60 /* file handling */ | 55 /* file handling */ |
| 61 | 56 |
| 62 int tpm_write_to_storage(uint8_t *data, size_t data_length); | 57 int tpm_write_to_storage(uint8_t *data, size_t data_length); |
| 63 int tpm_read_from_storage(uint8_t **data, size_t *data_length); | 58 int tpm_read_from_storage(uint8_t **data, size_t *data_length); |
| 64 | 59 |
| 65 #endif /* _TPM_EMULATOR_EXTERN_H_ */ | 60 #endif /* _TPM_EMULATOR_EXTERN_H_ */ |
| 66 | 61 |
| OLD | NEW |