OPTIGA Trust M  1.1.0
C++ library for Optiga Trust M Chip Security Controller
optiga_comms.h
Go to the documentation of this file.
1 
39 #ifndef _OPTIGA_COMMS_H_
40 #define _OPTIGA_COMMS_H_
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #include "optiga_lib_types.h"
48 #include "optiga_lib_common.h"
49 
50 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
51 // Offset for data
52 #define OPTIGA_COMMS_DATA_OFFSET (0x05)
53 // Overhead buffer size for user buffer
54 #define OPTIGA_COMMS_PRL_OVERHEAD (0x0D)
55 #else
56 #define OPTIGA_COMMS_DATA_OFFSET (0x00)
57 #define OPTIGA_COMMS_PRL_OVERHEAD (0x00)
58 #endif
59 
61 typedef struct optiga_comms
62 {
64  void * p_comms_ctx;
72  uint8_t state;
73 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
74  uint8_t protection_level;
80 #endif
81  void * p_pal_os_event_ctx;
84 
87 
110  void * context);
111 
131 
149  void *context);
150 
167  callback_handler_t handler);
212 LIBRARY_EXPORTS optiga_lib_status_t optiga_comms_open(optiga_comms_t * p_ctx);
213 
214 
239 LIBRARY_EXPORTS optiga_lib_status_t optiga_comms_reset(optiga_comms_t * p_ctx, uint8_t reset_type);
240 
302  const uint8_t * p_tx_data,
303  uint16_t tx_data_length,
304  uint8_t * p_rx_data,
305  uint16_t * p_rx_data_len);
306 
329 LIBRARY_EXPORTS optiga_lib_status_t optiga_comms_close(optiga_comms_t * p_ctx);
330 
331 
332 
333 #ifdef __cplusplus
334 }
335 #endif
336 
337 #endif /*_OPTIGA_COMMS_H_*/
338 
optiga_lib_status_t optiga_comms_set_callback_handler(optiga_comms_t *p_optiga_comms, callback_handler_t handler)
Sets the callback handler to OPTIGA comms instance.
uint8_t instance_init_state
Holds the instance initialization state.
Definition: optiga_comms.h:70
Optiga comms structure.
Definition: optiga_comms.h:61
uint8_t manage_context_operation
To provide the option to save and restore the optiga comms presentation layer context.
Definition: optiga_comms.h:79
struct optiga_comms optiga_comms_t
Optiga comms structure.
optiga_comms_t * optiga_comms_create(callback_handler_t callback, void *context)
Provides the singleton OPTIGA instance.
void * p_pal_os_event_ctx
Pointer to the pal os event instance/context.
Definition: optiga_comms.h:82
uint8_t protection_level
To provide the encryption and decryption need for command and response.
Definition: optiga_comms.h:75
LIBRARY_EXPORTS optiga_lib_status_t optiga_comms_open(optiga_comms_t *p_ctx)
Opens the communication channel with OPTIGA.
Definition: optiga_comms_ifx_i2c.c:113
This file contains the type definitions for the fundamental data types.
LIBRARY_EXPORTS optiga_lib_status_t optiga_comms_transceive(optiga_comms_t *p_ctx, const uint8_t *p_tx_data, uint16_t tx_data_length, uint8_t *p_rx_data, uint16_t *p_rx_data_len)
Sends and receives the APDU.
Definition: optiga_comms_ifx_i2c.c:154
void * p_comms_ctx
Comms structure pointer.
Definition: optiga_comms.h:64
LIBRARY_EXPORTS optiga_lib_status_t optiga_comms_close(optiga_comms_t *p_ctx)
Closes the communication channel with OPTIGA.
Definition: optiga_comms_ifx_i2c.c:184
upper_layer_callback_t upper_layer_handler
Upper layer handler.
Definition: optiga_comms.h:68
This file provides the prototypes for the commonly used functions and structures of OPTIGA Library.
LIBRARY_EXPORTS optiga_lib_status_t optiga_comms_reset(optiga_comms_t *p_ctx, uint8_t reset_type)
Resets the OPTIGA.
Definition: optiga_comms_ifx_i2c.c:137
This file defines the error codes for the all the layers and modules. OPTIGA host library return val...
void(* upper_layer_callback_t)(void *upper_layer_ctx, optiga_lib_status_t event)
typedef for application event handler
Definition: optiga_lib_types.h:103
uint8_t protocol_version
To provide the presentation layer protocol version to be used.
Definition: optiga_comms.h:77
optiga_lib_status_t optiga_comms_set_callback_context(optiga_comms_t *p_optiga_comms, void *context)
Sets the callers context to OPTIGA comms instance.
uint8_t state
OPTIGA comms state.
Definition: optiga_comms.h:72
uint16_t optiga_lib_status_t
typedef for OPTIGA host library status
Definition: optiga_lib_types.h:97
void optiga_comms_destroy(optiga_comms_t *optiga_comms)
Deinitializes the OPTIGA comms instance.
optiga_comms_t optiga_comms
optiga communication structure
void(* callback_handler_t)(void *callback_ctx, optiga_lib_status_t event)
typedef for event callback handler
Definition: optiga_lib_types.h:106
void * p_upper_layer_ctx
Upper layer context.
Definition: optiga_comms.h:66