ifapi_policy_execute.h
/* SPDX-License-Identifier: BSD-2-Clause */
/*******************************************************************************
* Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
* All rights reserved.
*******************************************************************************/
#ifndef FAPI_POLICY_EXECUTE_H
#define FAPI_POLICY_EXECUTE_H
#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <json-c/json.h>
#include <json-c/json_util.h>
#include "tss2_esys.h"
#include "tss2_fapi.h"
TSS2_RC
ifapi_extend_authorization(
TPMS_POLICY *policy,
TPMS_POLICYAUTHORIZATION *authorization);
typedef TSS2_RC(*Policy_Compare_Object)(
TPMS_POLICY *policy,
void *object1,
void *object2,
bool *found);
struct POLICY_LIST {
const char *path;
TPMS_POLICY policy;
struct POLICY_LIST *next;
};
struct policy_object_node {
const char *path;
TPMS_POLICY policy;
struct policy_object_node *next;
};
enum IFAPI_STATE_POLICY_EXCECUTE {
POLICY_EXECUTE_INIT = 0,
POLICY_EXECUTE_FINISH,
POLICY_EXECUTE_CALLBACK,
POLICY_LOAD_KEY,
POLICY_LOAD_KEYEDHASH,
POLICY_FLUSH_KEY,
POLICY_VERIFY,
POLICY_AUTH_CALLBACK,
POLICY_AUTH_SENT,
POLICY_EXEC_ESYS
};
typedef struct IFAPI_POLICY_CALLBACK_CTX IFAPI_POLICY_CALLBACK_CTX;
struct IFAPI_POLICY_EXEC_CTX {
enum IFAPI_STATE_POLICY_EXCECUTE state;
TPML_DIGEST digest_list;
IFAPI_POLICY_EXEC_CTX *next;
IFAPI_POLICY_EXEC_CTX *prev;
ESYS_TR session;
TPMS_POLICY *policy;
ESYS_TR policySessionSav;
ESYS_TR *enc_session;
ESYS_TR object_handle;
ESYS_TR nv_index;
ESYS_TR auth_handle;
IFAPI_OBJECT auth_objectNV;
IFAPI_OBJECT *auth_object;
ESYS_TR auth_session;
TPMI_ALG_HASH hash_alg;
void *app_data;
NODE_OBJECT_T *policy_elements;
TPM2B_DIGEST *nonceTPM;
uint8_t *buffer;
size_t buffer_size;
TPM2B_NAME name;
char *pem_key;
struct POLICY_LIST *policy_list;
bool flush_handle;
TSS2_POLICY_EXEC_CALLBACKS callbacks;
};
TSS2_RC
ifapi_policyeval_execute_prepare(
IFAPI_POLICY_EXEC_CTX *pol_ctx,
TPMI_ALG_HASH hash_alg,
TPMS_POLICY *policy);
TSS2_RC
ifapi_policyeval_execute(
ESYS_CONTEXT *esys_ctx,
IFAPI_POLICY_EXEC_CTX *current_policy,
bool do_flush);
#endif /* FAPI_POLICY_EXECUTE_H */
ESYS_TR
uint32_t ESYS_TR
Definition tss2_esys.h:16
ESYS_CONTEXT
Definition esys_int.h:162
ifapi_extend_authorization
TSS2_RC ifapi_extend_authorization(TPMS_POLICY *policy, TPMS_POLICYAUTHORIZATION *authorization)
Definition ifapi_policy_execute.c:93
ifapi_policyeval_execute_prepare
TSS2_RC ifapi_policyeval_execute_prepare(IFAPI_POLICY_EXEC_CTX *pol_ctx, TPMI_ALG_HASH hash_alg, TPMS_POLICY *policy)
Definition ifapi_policy_execute.c:1846
IFAPI_POLICY_EXEC_CTX
Definition ifapi_policy_execute.h:67
IFAPI_POLICY_EXEC_CTX::app_data
void * app_data
Definition ifapi_policy_execute.h:86
IFAPI_POLICY_EXEC_CTX::state
enum IFAPI_STATE_POLICY_EXCECUTE state
Definition ifapi_policy_execute.h:68
IFAPI_POLICY_EXEC_CTX::policy_elements
NODE_OBJECT_T * policy_elements
Definition ifapi_policy_execute.h:87
IFAPI_POLICY_EXEC_CTX::policySessionSav
ESYS_TR policySessionSav
Definition ifapi_policy_execute.h:76
IFAPI_POLICY_EXEC_CTX::flush_handle
bool flush_handle
Definition ifapi_policy_execute.h:95
IFAPI_POLICY_EXEC_CTX::policy_list
struct POLICY_LIST * policy_list
Definition ifapi_policy_execute.h:93
IFAPI_POLICY_EXEC_CTX::prev
IFAPI_POLICY_EXEC_CTX * prev
Definition ifapi_policy_execute.h:73
IFAPI_POLICY_EXEC_CTX::session
ESYS_TR session
Definition ifapi_policy_execute.h:74
IFAPI_POLICY_EXEC_CTX::auth_objectNV
IFAPI_OBJECT auth_objectNV
Definition ifapi_policy_execute.h:82
IFAPI_POLICY_EXEC_CTX::enc_session
ESYS_TR * enc_session
Definition ifapi_policy_execute.h:77
IFAPI_POLICY_EXEC_CTX::callbacks
TSS2_POLICY_EXEC_CALLBACKS callbacks
Definition ifapi_policy_execute.h:96
IFAPI_POLICY_EXEC_CTX::next
IFAPI_POLICY_EXEC_CTX * next
Definition ifapi_policy_execute.h:72
IFAPI_POLICY_EXEC_CTX::auth_object
IFAPI_OBJECT * auth_object
Definition ifapi_policy_execute.h:83
IFAPI_POLICY_EXEC_CTX::pem_key
char * pem_key
Definition ifapi_policy_execute.h:92
POLICY_LIST
Definition ifapi_policy_execute.h:34
POLICY_LIST::path
const char * path
Definition ifapi_policy_execute.h:35
POLICY_LIST::next
struct POLICY_LIST * next
Definition ifapi_policy_execute.h:37
POLICY_LIST::policy
TPMS_POLICY policy
Definition ifapi_policy_execute.h:36
TPMS_POLICYAUTHORIZATION
Definition ifapi_policy_types.h:128
TPMS_POLICY
Definition ifapi_policy_types.h:275
policy_object_node
Definition ifapi_policy_execute.h:44
policy_object_node::path
const char * path
Definition ifapi_policy_execute.h:45
policy_object_node::policy
TPMS_POLICY policy
Definition ifapi_policy_execute.h:46
policy_object_node::next
struct policy_object_node * next
Definition ifapi_policy_execute.h:47