OPTIGA™ Trust M
Host Library Documentation
optiga_util.h
Go to the documentation of this file.
1 
39 #ifndef _OPTIGA_UTIL_H_
40 #define _OPTIGA_UTIL_H_
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #include "optiga/cmd/optiga_cmd.h"
47 
49 #define OPTIGA_UTIL_WRITE_ONLY (0x00)
50 #define OPTIGA_UTIL_ERASE_AND_WRITE (0x40)
52 
53 
55 #define OPTIGA_UTIL_CONTEXT_NONE (0x00)
56 
58 typedef union optiga_util_params
59 {
60  // set data object params
62  // get data object params
64  // set object protected params
67 
70 {
80  uint16_t instance_state;
81 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
82  uint8_t protection_level;
85  uint8_t protocol_version;
86 #endif //OPTIGA_COMMS_SHIELDED_CONNECTION
87 
88 };
90 typedef struct optiga_util optiga_util_t;
91 
92 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
93 
119 void optiga_util_set_comms_params(optiga_util_t * me,
120  uint8_t parameter_type,
121  uint8_t value);
122 #endif
123 
153 LIBRARY_EXPORTS optiga_util_t * optiga_util_create(uint8_t optiga_instance_id,
155  void * caller_context);
156 
181 
214  bool_t perform_restore);
215 
252  bool_t perform_hibernate);
253 
289  uint16_t optiga_oid,
290  uint16_t offset,
291  uint8_t * buffer,
292  uint16_t * length);
293 
328  uint16_t optiga_oid,
329  uint8_t * buffer,
330  uint16_t * length);
331 
367  uint16_t optiga_oid,
368  uint8_t write_type,
369  uint16_t offset,
370  const uint8_t * buffer,
371  uint16_t length);
372 
405  uint16_t optiga_oid,
406  const uint8_t * buffer,
407  uint8_t length);
408 
444  uint8_t manifest_version,
445  const uint8_t * manifest,
446  uint16_t manifest_length);
447 
482  const uint8_t * fragment,
483  uint16_t fragment_length);
484 
517  const uint8_t * fragment,
518  uint16_t fragment_length);
519 
550  uint16_t optiga_counter_oid,
551  uint8_t count);
552 
578 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
579 #define OPTIGA_UTIL_SET_COMMS_PROTECTION_LEVEL(p_instance, protection_level) \
580 { \
581  optiga_util_set_comms_params(p_instance, \
582  OPTIGA_COMMS_PROTECTION_LEVEL, \
583  protection_level); \
584 }
585 #else
586 #define OPTIGA_UTIL_SET_COMMS_PROTECTION_LEVEL(p_instance, protection_level) {}
587 #endif
588 
605 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
606 #define OPTIGA_UTIL_SET_COMMS_PROTOCOL_VERSION(p_instance, version) \
607 { \
608  optiga_util_set_comms_params(p_instance, \
609  OPTIGA_COMMS_PROTOCOL_VERSION, \
610  version);\
611 }
612 #else
613 #define OPTIGA_UTIL_SET_COMMS_PROTOCOL_VERSION(p_instance, version) {}
614 #endif
615 
616 #ifdef __cplusplus
617 }
618 #endif
619 
620 #endif /*_OPTIGA_UTIL_H_ */
621 
optiga_cmd_t
struct optiga_cmd optiga_cmd_t
OPTIGA command instance structure type.
Definition: optiga_cmd.h:48
optiga_util_params_t
union optiga_util_params optiga_util_params_t
union for OPTIGA util parameters
optiga_util_protected_update_start
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_protected_update_start(optiga_util_t *me, uint8_t manifest_version, const uint8_t *manifest, uint16_t manifest_length)
Initiates the start of protected update of object by writing manifest into OPTIGA object.
optiga_util_protected_update_continue
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_protected_update_continue(optiga_util_t *me, const uint8_t *fragment, uint16_t fragment_length)
Sends fragment(s) of data to be written to OPTIGA.
optiga_set_data_object
Specifies the data structure for data to be written to OPTIGA.
Definition: optiga_lib_common.h:379
optiga_util_close_application
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_close_application(optiga_util_t *me, bool_t perform_hibernate)
Closes the application on OPTIGA and closes the communication with optiga.
optiga_get_data_object
Specifies the data structure for data to be read from OPTIGA.
Definition: optiga_lib_common.h:356
optiga_util::my_cmd
optiga_cmd_t * my_cmd
pointer to optiga command instance
Definition: optiga_util.h:74
optiga_util::caller_context
void * caller_context
Callback context.
Definition: optiga_util.h:76
optiga_util_write_metadata
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_write_metadata(optiga_util_t *me, uint16_t optiga_oid, const uint8_t *buffer, uint8_t length)
Writes metadata for the user provided data object.
optiga_util_write_data
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_write_data(optiga_util_t *me, uint16_t optiga_oid, uint8_t write_type, uint16_t offset, const uint8_t *buffer, uint16_t length)
Writes data to optiga.
optiga_util_update_count
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_update_count(optiga_util_t *me, uint16_t optiga_counter_oid, uint8_t count)
Increments the counter object by a value specified by user.
optiga_util
OPTIGA util instance structure.
Definition: optiga_util.h:70
optiga_util_params
union for OPTIGA util parameters
Definition: optiga_util.h:59
optiga_util_protected_update_final
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_protected_update_final(optiga_util_t *me, const uint8_t *fragment, uint16_t fragment_length)
Sends the last fragment to finalize the protected update of data object.
optiga_util::instance_state
uint16_t instance_state
To provide the busy/free status of the util instance.
Definition: optiga_util.h:80
optiga_util_read_metadata
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_read_metadata(optiga_util_t *me, uint16_t optiga_oid, uint8_t *buffer, uint16_t *length)
Reads metadata of the specified data object from optiga.
optiga_util_params::optiga_set_object_protected_params
optiga_set_object_protected_params_t optiga_set_object_protected_params
Definition: optiga_util.h:65
optiga_util_params::optiga_get_data_object_params
optiga_get_data_object_params_t optiga_get_data_object_params
Definition: optiga_util.h:63
optiga_util_destroy
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_destroy(optiga_util_t *me)
De-Initializes the OPTIGA util instance.
optiga_util_params::optiga_set_data_object_params
optiga_set_data_object_params_t optiga_set_data_object_params
Definition: optiga_util.h:61
bool_t
uint8_t bool_t
Typedef for a boolean.
Definition: optiga_lib_types.h:84
optiga_set_object_protected_params
Specifies the data structure for protected update.
Definition: optiga_lib_common.h:568
optiga_util_open_application
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_open_application(optiga_util_t *me, bool_t perform_restore)
Initializes the communication with optiga and open the application on OPTIGA.
optiga_cmd.h
This file defines APIs, types and data structures used in the Command (cmd) module implementation.
manifest
Definition: protected_update_data_set.h:210
callback_handler_t
void(* callback_handler_t)(void *callback_ctx, optiga_lib_status_t event)
typedef for event callback handler
Definition: optiga_lib_types.h:99
optiga_util::params
optiga_util_params_t params
Details/references (pointers) to the Application Inputs.
Definition: optiga_util.h:72
optiga_util::handler
callback_handler_t handler
Callback handler.
Definition: optiga_util.h:78
optiga_lib_status_t
uint16_t optiga_lib_status_t
typedef for OPTIGA host library status
Definition: optiga_lib_types.h:90
optiga_util_create
LIBRARY_EXPORTS optiga_util_t * optiga_util_create(uint8_t optiga_instance_id, callback_handler_t handler, void *caller_context)
Create an instance of optiga_util_t.
optiga_util_read_data
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_read_data(optiga_util_t *me, uint16_t optiga_oid, uint16_t offset, uint8_t *buffer, uint16_t *length)
Reads data from optiga.