ifapi_eventlog.h
/* SPDX-License-Identifier: BSD-2-Clause */
/*******************************************************************************
* Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
* All rights reserved.
*******************************************************************************/
#ifndef IFAPI_EVENTLOG_H
#define IFAPI_EVENTLOG_H
#include <json-c/json.h>
#include "tss2_tpm2_types.h"
#include "ifapi_io.h"
#include "efi_event.h"
#include "ifapi_ima_eventlog.h"
#include "ifapi_eventlog_system.h"
#define CONTENT_TYPE "content_type"
#define CONTENT "content"
typedef UINT32 IFAPI_EVENT_TYPE;
#define IFAPI_TSS_EVENT_TAG 2
#define IFAPI_IMA_EVENT_TAG 3
#define IFAPI_IMA_NG_EVENT_TAG 4
#define IFAPI_IMA_SIG_EVENT_TAG 5
#define IFAPI_PC_CLIENT 6
#define IFAPI_CEL_TAG 8
/* Definition of TPMI_CELMGTTYPE Type */
typedef UINT32 TPMI_CELMGTTYPE;
#define CEL_VERSION 1
#define FIRMWARE_END 2
#define CEL_TIMESTAMP 80
#define STATE_TRANS 81
/* Structures of canonical event log format. */
/* Definition of TPMS_CEL_VERSION Structure */
typedef struct {
UINT16 major; /* The major version */
UINT16 minor; /* The minor version */
} TPMS_CEL_VERSION;
/* Definition of TPMU_CAPABILITIES Union <OUT> */
typedef union {
TPMS_CEL_VERSION cel_version;
TPMS_EMPTY firmware_end;
UINT64 cel_timestamp;
} TPMU_CELMGT;
/* Definition of TPMS_EVENT_CELMGT Structure*/
typedef struct {
TPMI_CELMGTTYPE type; /* type of the cel event structure */
TPMU_CELMGT data; /* the type-specific cel event information */
} TPMS_EVENT_CELMGT;
typedef struct {
TPM2B_EVENT data;
char *event;
} IFAPI_TSS_EVENT;
typedef union {
IFAPI_TSS_EVENT tss_event;
IFAPI_IMA_EVENT ima_event;
IFAPI_FIRMWARE_EVENT firmware_event;
TPMS_EVENT_CELMGT cel_event;
} IFAPI_EVENT_UNION;
typedef struct IFAPI_EVENT {
UINT32 recnum;
TPM2_HANDLE pcr;
TPML_DIGEST_VALUES digests;
IFAPI_EVENT_TYPE content_type;
IFAPI_EVENT_UNION content;
bool verify;
} IFAPI_EVENT;
typedef struct {
TPMT_SIG_SCHEME sig_scheme;
TPMS_ATTEST attest;
} FAPI_QUOTE_INFO;
enum IFAPI_EVENTLOG_STATE {
IFAPI_EVENTLOG_STATE_INIT = 0,
IFAPI_EVENTLOG_STATE_READING,
IFAPI_EVENTLOG_STATE_APPENDING,
IFAPI_EVENTLOG_STATE_WRITING
};
typedef struct IFAPI_EVENTLOG {
enum IFAPI_EVENTLOG_STATE state;
char *log_dir;
const char *firmware_log_file;
const char *ima_log_file;
struct IFAPI_EVENT event;
TPM2_HANDLE pcrList[TPM2_MAX_PCRS];
size_t pcrListSize;
size_t pcrListIdx;
json_object *log;
} IFAPI_EVENTLOG;
TSS2_RC
ifapi_eventlog_initialize(
IFAPI_EVENTLOG *eventlog,
const char *log_dir,
const char *firmware_log_file,
const char *ima_log_file);
TSS2_RC
ifapi_eventlog_get_async(
IFAPI_EVENTLOG *eventlog,
IFAPI_IO *io,
const TPM2_HANDLE *pcrList,
size_t pcrListSize);
TSS2_RC
ifapi_eventlog_get_finish(
IFAPI_EVENTLOG *eventlog,
FAPI_QUOTE_INFO *fapi_quote_info,
IFAPI_IO *io,
char **log);
TSS2_RC
ifapi_eventlog_append_check(
IFAPI_EVENTLOG *eventlog,
IFAPI_IO *io);
TSS2_RC
ifapi_eventlog_append_finish(
IFAPI_EVENTLOG *eventlog,
IFAPI_IO *io,
const IFAPI_EVENT *event);
void
ifapi_cleanup_event(
IFAPI_EVENT * event);
#endif /* IFAPI_EVENTLOG_H */
ifapi_eventlog_append_finish
TSS2_RC ifapi_eventlog_append_finish(IFAPI_EVENTLOG *eventlog, IFAPI_IO *io, const IFAPI_EVENT *event)
Definition ifapi_eventlog.c:414
ifapi_cleanup_event
void ifapi_cleanup_event(IFAPI_EVENT *event)
Definition ifapi_eventlog.c:502
ifapi_eventlog_append_check
TSS2_RC ifapi_eventlog_append_check(IFAPI_EVENTLOG *eventlog, IFAPI_IO *io)
Definition ifapi_eventlog.c:342
ifapi_eventlog_get_async
TSS2_RC ifapi_eventlog_get_async(IFAPI_EVENTLOG *eventlog, IFAPI_IO *io, const TPM2_HANDLE *pcrList, size_t pcrListSize)
Definition ifapi_eventlog.c:78
FAPI_QUOTE_INFO
Definition ifapi_eventlog.h:89
FAPI_QUOTE_INFO::sig_scheme
TPMT_SIG_SCHEME sig_scheme
Definition ifapi_eventlog.h:90
FAPI_QUOTE_INFO::attest
TPMS_ATTEST attest
Definition ifapi_eventlog.h:91
IFAPI_EVENT
Definition ifapi_eventlog.h:77
IFAPI_EVENT::digests
TPML_DIGEST_VALUES digests
Definition ifapi_eventlog.h:80
IFAPI_EVENT::content_type
IFAPI_EVENT_TYPE content_type
Definition ifapi_eventlog.h:81
IFAPI_EVENT::recnum
UINT32 recnum
Definition ifapi_eventlog.h:78
IFAPI_EVENT::content
IFAPI_EVENT_UNION content
Definition ifapi_eventlog.h:82
IFAPI_EVENT::verify
bool verify
Definition ifapi_eventlog.h:83
IFAPI_EVENT::pcr
TPM2_HANDLE pcr
Definition ifapi_eventlog.h:79
IFAPI_EVENTLOG
Definition ifapi_eventlog.h:101
IFAPI_FIRMWARE_EVENT
Definition ifapi_eventlog_system.h:41
IFAPI_IMA_EVENT
Definition ifapi_ima_eventlog.h:50
IFAPI_IO
Definition ifapi_io.h:15
IFAPI_TSS_EVENT
Definition ifapi_eventlog.h:60
IFAPI_TSS_EVENT::data
TPM2B_EVENT data
Definition ifapi_eventlog.h:61
IFAPI_TSS_EVENT::event
char * event
Definition ifapi_eventlog.h:62
TPMS_CEL_VERSION
Definition ifapi_eventlog.h:40
TPMS_EVENT_CELMGT
Definition ifapi_eventlog.h:53
IFAPI_EVENT_UNION
Definition ifapi_eventlog.h:67
IFAPI_EVENT_UNION::ima_event
IFAPI_IMA_EVENT ima_event
Definition ifapi_eventlog.h:69
IFAPI_EVENT_UNION::firmware_event
IFAPI_FIRMWARE_EVENT firmware_event
Definition ifapi_eventlog.h:70
IFAPI_EVENT_UNION::tss_event
IFAPI_TSS_EVENT tss_event
Definition ifapi_eventlog.h:68
IFAPI_EVENT_UNION::cel_event
TPMS_EVENT_CELMGT cel_event
Definition ifapi_eventlog.h:71
TPMU_CELMGT
Definition ifapi_eventlog.h:46