tpm2-tss 4.1.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-c/json.h>
10
11#include "fapi_types.h"
12
13/* Defines from kernel ima.h" */
14#define TCG_EVENT_NAME_LEN_MAX 255
15#define IMA_TEMPLATE_FIELD_ID_MAX_LEN 16
16#define IMA_TEMPLATE_NUM_FIELDS_MAX 15
17
18/* Define from kernel crypt.h */
19#define CRYPTO_MAX_ALG_NAME 128
20
21typedef UINT32 IFAPI_IMA_EVENT_TYPE;
22#define IFAPI_IMA_EVENT_TAG_IMA 1
23#define IFAPI_IMA_EVENT_TAG_NG 2
24#define IFAPI_IMA_EVENT_TAG_SIG 3
26/* Structure to store event header and data of IMA template */
27typedef struct {
28 /* Switch whether conversion from little endian to big endian
29 is needed if on a big endian machine with the option
30 --ima_canonical_fmt ima is forced to produce a little endian log. */
31 bool convert_to_big_endian;
32
33 /* header is the First part of the template which will be read
34 beforte the rest of the event will be read and parsed. */
35 struct {
36 UINT32 pcr;
37 UINT8 digest[TPM2_SHA512_DIGEST_SIZE + sizeof(UINT32) + 3];
38 } header;
39 UINT32 ima_type_size;
40 size_t hash_size;
41 TPMI_ALG_HASH hash_alg;
42 char ima_type[TCG_EVENT_NAME_LEN_MAX + 1];
43 char *name;
44 UINT32 event_size;
45 UINT8 *event_buffer;
47
50typedef struct {
51 IFAPI_IMA_EVENT_TYPE template_name;
54
55TSS2_RC
56ifapi_json_IFAPI_IMA_EVENT_deserialize(json_object *jso, IFAPI_IMA_EVENT *out);
57
58TSS2_RC
59ifapi_json_IFAPI_IMA_EVENT_TYPE_deserialize_txt(json_object *jso,
60 IFAPI_IMA_EVENT_TYPE *out);
61
62TSS2_RC ifapi_read_ima_event_log(
63 const char *filename,
64 const uint32_t *pcrList,
65 const size_t pcrListSize,
66 json_object **jso_list);
67
68TSS2_RC
69ifapi_get_ima_eventname(IFAPI_IMA_EVENT *event, char **name);
70
71#endif /* IFAPI_IMA_EVENTLOG_H */
Definition ifapi_ima_eventlog.h:50
UINT8_ARY template_value
Definition ifapi_ima_eventlog.h:52
Definition ifapi_ima_eventlog.h:27
UINT8 * event_buffer
Definition ifapi_ima_eventlog.h:45
Definition fapi_types.h:15