tpm2-tss 4.2.0
TPM Software stack 2.0 TCG spec compliant implementation
ifapi_ima_eventlog.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*******************************************************************************
3 * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4 * All rights reserved.
5 *******************************************************************************/
6#ifndef IFAPI_IMA_EVENTLOG_H
7#define IFAPI_IMA_EVENTLOG_H
8
9#include <json.h> // for json_object
10#include <stdbool.h> // for bool
11#include <stddef.h> // for size_t
12#include <stdint.h> // for uint32_t
13
14#include "fapi_types.h" // for UINT8_ARY
15#include "tss2_common.h" // for UINT32, TSS2_RC, UINT8
16#include "tss2_tpm2_types.h" // for TPM2_SHA512_DIGEST_SIZE, TPMI_ALG_HASH
17
18/* Defines from kernel ima.h" */
19#define TCG_EVENT_NAME_LEN_MAX 255
20#define IMA_TEMPLATE_FIELD_ID_MAX_LEN 16
21#define IMA_TEMPLATE_NUM_FIELDS_MAX 15
22
23/* Define from kernel crypt.h */
24#define CRYPTO_MAX_ALG_NAME 128
25
26typedef UINT32 IFAPI_IMA_EVENT_TYPE;
27#define IFAPI_IMA_EVENT_TAG_IMA 1
28#define IFAPI_IMA_EVENT_TAG_NG 2
29#define IFAPI_IMA_EVENT_TAG_SIG 3
30
31/* Structure to store event header and data of IMA template */
32typedef struct {
33 /* Switch whether conversion from little endian to big endian
34 is needed if on a big endian machine with the option
35 --ima_canonical_fmt ima is forced to produce a little endian log. */
36 bool convert_to_big_endian;
37
38 /* header is the First part of the template which will be read
39 beforte the rest of the event will be read and parsed. */
40 struct {
41 UINT32 pcr;
42 UINT8 digest[TPM2_SHA512_DIGEST_SIZE + sizeof(UINT32) + 3];
43 } header;
44 UINT32 ima_type_size;
45 size_t hash_size;
46 TPMI_ALG_HASH hash_alg;
47 char ima_type[TCG_EVENT_NAME_LEN_MAX + 1];
48 char *name;
49 UINT32 event_size;
50 UINT8 *event_buffer;
52
55typedef struct {
56 IFAPI_IMA_EVENT_TYPE template_name;
59
60TSS2_RC
62
63TSS2_RC
64ifapi_json_IFAPI_IMA_EVENT_TYPE_deserialize_txt(json_object *jso, IFAPI_IMA_EVENT_TYPE *out);
65
66TSS2_RC ifapi_read_ima_event_log(const char *filename,
67 const uint32_t *pcrList,
68 const size_t pcrListSize,
69 json_object **jso_list);
70
71TSS2_RC
72ifapi_get_ima_eventname(IFAPI_IMA_EVENT *event, char **name);
73
74#endif /* IFAPI_IMA_EVENTLOG_H */
TSS2_RC ifapi_json_IFAPI_IMA_EVENT_deserialize(json_object *jso, IFAPI_IMA_EVENT *out)
Definition ifapi_ima_eventlog.c:854
Definition ifapi_ima_eventlog.h:55
UINT8_ARY template_value
Definition ifapi_ima_eventlog.h:57
Definition ifapi_ima_eventlog.h:32
UINT8 * event_buffer
Definition ifapi_ima_eventlog.h:50
Definition fapi_types.h:15