Move common debug, memory & nvfile units to src/

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-08-05 14:21:54 +04:00 committed by Stefan Berger
parent aa579cee5b
commit e60c35ecf9
13 changed files with 23 additions and 29 deletions

View File

@ -46,6 +46,12 @@
extern "C" {
#endif
/* This value is used to limit memory allocation to prevent resource overload. */
#ifndef TPM_ALLOC_MAX
#define TPM_ALLOC_MAX 0x20000 /* 128k bytes */
#endif
TPM_RESULT TPM_Malloc(unsigned char **buffer, uint32_t size);
TPM_RESULT TPM_Realloc(unsigned char **buffer, uint32_t size);
void TPM_Free(unsigned char *buffer);

View File

@ -17,6 +17,10 @@ common_CFLAGS = -include tpm_library_conf.h \
$(SANITIZERS) \
$(FUZZER)
# build with libtpms callback support
common_CFLAGS += -DTPM_LIBTPMS_CALLBACKS
# let the default NVRAM write to disk
common_CFLAGS += -DTPM_NV_DISK
#
# TPM1.2
@ -40,10 +44,6 @@ libtpms_tpm12_la_CFLAGS += -DTPM_VOLATILE_LOAD
libtpms_tpm12_la_CFLAGS += -DTPM_ENABLE_ACTIVATE
# build with AES support for symmetric crypto
libtpms_tpm12_la_CFLAGS += -DTPM_AES
# build with libtpms callback support
libtpms_tpm12_la_CFLAGS += -DTPM_LIBTPMS_CALLBACKS
# let the default NVRAM write to disk
libtpms_tpm12_la_CFLAGS += -DTPM_NV_DISK
# build a POSIX type of TPM
libtpms_tpm12_la_CFLAGS += -DTPM_POSIX
# build without maintenance commands
@ -60,7 +60,6 @@ libtpms_tpm12_la_SOURCES = \
tpm12/tpm_cryptoh.c \
tpm12/tpm_counter.c \
tpm12/tpm_daa.c \
tpm12/tpm_debug.c \
tpm12/tpm_delegate.c \
tpm12/tpm_digest.c \
tpm12/tpm_error.c \
@ -71,10 +70,8 @@ libtpms_tpm12_la_SOURCES = \
tpm12/tpm_key.c \
tpm12/tpm_load.c \
tpm12/tpm_maint.c \
tpm12/tpm_memory.c \
tpm12/tpm_migration.c \
tpm12/tpm_nonce.c \
tpm12/tpm_nvfile.c \
tpm12/tpm_nvram.c \
tpm12/tpm_openssl_helpers.c \
tpm12/tpm_owner.c \
@ -106,7 +103,7 @@ noinst_HEADERS = \
tpm12/tpm_crypto.h \
tpm12/tpm_cryptoh.h \
tpm12/tpm_daa.h \
tpm12/tpm_debug.h \
tpm_debug.h \
tpm12/tpm_delegate.h \
tpm12/tpm_digest.h \
tpm12/tpm_global.h \
@ -120,7 +117,7 @@ noinst_HEADERS = \
tpm12/tpm_maint.h \
tpm12/tpm_migration.h \
tpm12/tpm_nonce.h \
tpm12/tpm_nvfile.h \
tpm_nvfile.h \
tpm12/tpm_nvram_const.h \
tpm12/tpm_nvram.h \
tpm12/tpm_openssl_helpers.h \
@ -182,8 +179,6 @@ libtpms_tpm2_la_CFLAGS = $(common_CFLAGS)
libtpms_tpm2_la_CFLAGS += -D_POSIX_
libtpms_tpm2_la_CFLAGS += -DTPM_POSIX
# build with libtpms callback support
libtpms_tpm2_la_CFLAGS += -DTPM_LIBTPMS_CALLBACKS
libtpms_tpm2_la_SOURCES = \
tpm2/ACT_spt.c \
@ -573,7 +568,10 @@ endif # WITH_TPM2
#
libtpms_la_SOURCES = \
tpm_library.c
tpm_debug.c \
tpm_library.c \
tpm_memory.c \
tpm_nvfile.c
libtpms_la_CFLAGS = $(common_CFLAGS)

View File

@ -143,12 +143,6 @@
TPM buffer limits
*/
/* This value is used to limit memory allocation to prevent resource overload. */
#ifndef TPM_ALLOC_MAX
#define TPM_ALLOC_MAX 0x20000 /* 128k bytes */
#endif
/* This is the increment by which the TPM_STORE_BUFFER grows. A larger number saves realloc's. A
smaller number saves memory.

View File

@ -42,6 +42,7 @@
#include <limits.h>
#include "tpm_constants.h"
#include "tpm_memory.h"
#include "tpm_types.h"
#include "tpm_nvram_const.h"

View File

@ -39,9 +39,6 @@
#include <stdio.h>
#include "tpm_commands.h"
#include "tpm_load.h"
#include "tpm_debug.h"
#undef printf

View File

@ -60,7 +60,7 @@
# include <openssl/evp.h>
#endif
#include "tpm12/tpm_debug.h"
#include "tpm_debug.h"
#include "tpm_error.h"
#include "tpm_library.h"
#include "tpm_library_intern.h"

View File

@ -40,7 +40,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "tpm_constants.h"
#include "tpm_debug.h"
#include "tpm_error.h"

View File

@ -58,7 +58,6 @@
#include "tpm_debug.h"
#include "tpm_error.h"
#include "tpm_memory.h"
#include "tpm_nvram.h"
#include "tpm_nvfile.h"
@ -100,7 +99,7 @@ char state_directory[FILENAME_MAX];
TPM_RESULT TPM_NVRAM_Init(void)
{
TPM_RESULT rc = 0;
char *tpm_state_path;
char *tpm_state_path = NULL;
size_t length;
#ifdef TPM_LIBTPMS_CALLBACKS

View File

@ -45,7 +45,7 @@
#include <string.h>
#include <stdbool.h>
#include "tpm12/tpm_debug.h"
#include "tpm_debug.h"
#include "tpm_error.h"
#include "tpm12/tpm_init.h"
#include "tpm_library_intern.h"
@ -53,7 +53,7 @@
#include "tpm12/tpm_startup.h"
#include "tpm12/tpm_global.h"
#include "tpm12/tpm_permanent.h"
#include "tpm12/tpm_nvfile.h"
#include "tpm_nvfile.h"
static TPM_RESULT TPM12_MainInit(void)
{

View File

@ -46,7 +46,7 @@
#include "tpm12/tpm_crypto.h"
#include "tpm12/tpm_cryptoh.h"
#include "tpm12/tpm_debug.h"
#include "tpm_debug.h"
#include "tpm_error.h"
#include "tpm12/tpm_digest.h"
#include "tpm12/tpm_global.h"

View File

@ -62,7 +62,7 @@
#include "tpm2/crypto/openssl/ExpDCache_fp.h"
#define TPM_HAVE_TPM2_DECLARATIONS
#include "tpm12/tpm_nvfile.h" // TPM_NVRAM_Loaddata()
#include "tpm_nvfile.h" // TPM_NVRAM_Loaddata()
#include "tpm_error.h"
#include "tpm_library_intern.h"
#include "tpm_nvfilename.h"