1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2017 - 2018, Intel Corporation 4 * All rights reserved. 5 */ 6 #ifndef TPM2_COMMAND_H 7 #define TPM2_COMMAND_H 8 9 #include <glib-object.h> 10 #include <tss2/tss2_tpm2_types.h> 11 12 #include "connection.h" 13 14 G_BEGIN_DECLS 15 16 typedef struct _Tpm2CommandClass { 17 GObjectClass parent; 18 } Tpm2CommandClass; 19 20 typedef struct _Tpm2Command { 21 GObject parent_instance; 22 TPMA_CC attributes; 23 Connection *connection; 24 guint8 *buffer; 25 size_t buffer_size; 26 } Tpm2Command; 27 28 #include "command-attrs.h" 29 30 #define TYPE_TPM2_COMMAND (tpm2_command_get_type ()) 31 #define TPM2_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TPM2_COMMAND, Tpm2Command)) 32 #define TPM2_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TPM2_COMMAND, Tpm2CommandClass)) 33 #define IS_TPM2_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TPM2_COMMAND)) 34 #define IS_TPM2_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TPM2_COMMAND)) 35 #define TPM2_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TPM2_COMMAND, Tpm2CommandClass)) 36 37 #define TPM2_COMMAND_MAX_HANDLES 3 38 39 GType tpm2_command_get_type (void); 40 Tpm2Command* tpm2_command_new (Connection *connection, 41 guint8 *buffer, 42 size_t size, 43 TPMA_CC attrs); 44 Tpm2Command* tpm2_command_new_context_save (TPM2_HANDLE); 45 Tpm2Command* tpm2_command_new_context_load (uint8_t *buf, 46 size_t size); 47 TPMA_CC tpm2_command_get_attributes (Tpm2Command *command); 48 TPMA_SESSION tpm2_command_get_auth_attrs (Tpm2Command *command, 49 size_t auth_offset); 50 TPM2_HANDLE tpm2_command_get_auth_handle (Tpm2Command *command, 51 size_t offset); 52 guint8* tpm2_command_get_buffer (Tpm2Command *command); 53 TPM2_CC tpm2_command_get_code (Tpm2Command *command); 54 guint8 tpm2_command_get_handle_count (Tpm2Command *command); 55 TPM2_HANDLE tpm2_command_get_handle (Tpm2Command *command, 56 guint8 handle_number); 57 gboolean tpm2_command_get_handles (Tpm2Command *command, 58 TPM2_HANDLE handles[], 59 size_t *count); 60 gboolean tpm2_command_set_handle (Tpm2Command *command, 61 TPM2_HANDLE handle, 62 guint8 handle_number); 63 TSS2_RC tpm2_command_get_flush_handle (Tpm2Command *command, 64 TPM2_HANDLE *handle); 65 guint32 tpm2_command_get_size (Tpm2Command *command); 66 TPMI_ST_COMMAND_TAG tpm2_command_get_tag (Tpm2Command *command); 67 Connection* tpm2_command_get_connection (Tpm2Command *command); 68 TPM2_CAP tpm2_command_get_cap (Tpm2Command *command); 69 UINT32 tpm2_command_get_prop (Tpm2Command *command); 70 UINT32 tpm2_command_get_prop_count (Tpm2Command *command); 71 gboolean tpm2_command_has_auths (Tpm2Command *command); 72 UINT32 tpm2_command_get_auths_size (Tpm2Command *command); 73 gboolean tpm2_command_foreach_auth (Tpm2Command *command, 74 GFunc func, 75 gpointer user_data); 76 77 G_END_DECLS 78 79 #endif /* TPM2_COMMAND_H */ 80