This file defines APIs, types and data structures used in the OPTIGA utility module. More...
#include "optiga_cmd.h"
Go to the source code of this file.
Classes | |
union | optiga_util_params |
union for OPTIGA util parameters More... | |
struct | optiga_util |
OPTIGA util instance structure. More... | |
#define | OPTIGA_UTIL_WRITE_ONLY (0x00) |
Option to only write the data object. More... | |
#define | OPTIGA_UTIL_ERASE_AND_WRITE (0x40) |
Option to erase and write the data object. More... | |
#define | OPTIGA_UTIL_CONTEXT_NONE (0x00) |
To Initialize a clean application context. More... | |
#define | OPTIGA_UTIL_SET_COMMS_PROTECTION_LEVEL(p_instance, protection_level) |
Enables the protected I2C communication with OPTIGA for UTIL instances. More... | |
#define | OPTIGA_UTIL_SET_COMMS_PROTOCOL_VERSION(p_instance, version) |
Select the protocol version required for the I2C protected communication for UTIL instances. More... | |
#define | OPTIGA_UTIL_LOG_MESSAGE(msg) {} |
#define | OPTIGA_UTIL_LOG_HEX_DATA(array, array_len) {} |
#define | OPTIGA_UTIL_LOG_STATUS(return_value) {} |
typedef union optiga_util_params | optiga_util_params_t |
union for OPTIGA util parameters More... | |
typedef struct optiga_util | optiga_util_t |
OPTIGA util instance structure type. More... | |
void | optiga_util_set_comms_params (optiga_util_t *me, uint8_t configuration_type, uint8_t value) |
Sets/updates the OPTIGA Comms Shielded connection configuration in the respective (optiga_util) instance. More... | |
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. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_util_destroy (optiga_util_t *me) |
De-Initializes the OPTIGA util instance. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
This file defines APIs, types and data structures used in the OPTIGA utility module.
Copyright (c) 2019 Infineon Technologies AG
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
\endcopyright
#define OPTIGA_UTIL_CONTEXT_NONE (0x00) |
To Initialize a clean application context.
#define OPTIGA_UTIL_ERASE_AND_WRITE (0x40) |
Option to erase and write the data object.
#define OPTIGA_UTIL_LOG_HEX_DATA | ( | array, | |
array_len | |||
) | {} |
#define OPTIGA_UTIL_LOG_MESSAGE | ( | msg | ) | {} |
#define OPTIGA_UTIL_LOG_STATUS | ( | return_value | ) | {} |
#define OPTIGA_UTIL_SET_COMMS_PROTECTION_LEVEL | ( | p_instance, | |
protection_level | |||
) |
Enables the protected I2C communication with OPTIGA for UTIL instances.
Enables the protected I2C communication with OPTIGA
[in] | p_instance | Valid pointer to an instance |
[in] | protection_level | Required protection mode
|
#define OPTIGA_UTIL_SET_COMMS_PROTOCOL_VERSION | ( | p_instance, | |
version | |||
) |
Select the protocol version required for the I2C protected communication for UTIL instances.
Select the protocol version required for the I2C protected communication
[in] | p_instance | Valid pointer to an instance |
[in] | version | Required protocol version
|
#define OPTIGA_UTIL_WRITE_ONLY (0x00) |
Option to only write the data object.
typedef union optiga_util_params optiga_util_params_t |
union for OPTIGA util parameters
typedef struct optiga_util optiga_util_t |
OPTIGA util instance structure type.
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.
Closes the communication with OPTIGA for the given instance.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | perform_hibernate | Hibernate the application on OPTIGA. The values must be as defined below.
|
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Input arguments are NULL |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
main_xmc4800_sample.c
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.
Create an instance of optiga_util_t.
[in] | optiga_instance_id | Indicates the OPTIGA instance to be associated with optiga_util_t. Value should be defined as below
|
[in] | handler | Valid pointer to callback function |
[in] | caller_context | Pointer to upper layer context, contains user context data |
optiga_util_t | On success function will return pointer of optiga_util_t |
NULL | Input arguments are NULL. Low layer function fails. OPTIGA_CMD_MAX_REGISTRATIONS number of instances are already created. |
Example
main_xmc4800_sample.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_util_destroy | ( | optiga_util_t * | me | ) |
De-Initializes the OPTIGA util instance.
De-Initializes the optiga_util_t instance.
[in] | me | Valid instance of optiga_util_t |
OPTIGA_LIB_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
Example
main_xmc4800_sample.c
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.
Initializes the communication with OPTIGA for the given instance.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | perform_restore | Restore application on OPTIGA from a previous hibernate state. The values must be as defined below
|
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
main_xmc4800_sample.c
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.
Sends a fragment of data to be written to OPTIGA.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | fragment | Valid pointer to the buffer which contains fragment
|
[in] | fragment_length | Length of fragment to be written |
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
example_optiga_util_protected_update.c
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.
Sends the last fragment to finalize the protected update of data object.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | fragment | Valid pointer to the buffer which contains the last fragment.
|
[in] | fragment_length | Length of fragment to be written |
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
example_optiga_util_protected_update.c
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.
Initiates the start of protected update of object.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | manifest_version | Version of manifest to be written |
[in] | manifest | Valid pointer to the buffer which contains manifest
|
[in] | manifest_length | Length of manifest to be written |
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
example_optiga_util_protected_update.c
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.
Retrieves the requested data that is stored in the user provided data object.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | optiga_oid | OID of data object
|
[in] | offset | Offset from within data object
|
[in,out] | buffer | Valid pointer to the buffer to which data is read |
[in,out] | length | Valid pointer to the length of data to be read from data object
|
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
example_optiga_util_read_data.c
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.
Reads the metadata of the user provided data object.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | optiga_oid | OID of data object
|
[in,out] | buffer | Valid pointer to the buffer to which metadata is read |
[in,out] | length | Valid pointer to the length of metadata to be read from data object
|
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
example_optiga_util_read_data.c
void optiga_util_set_comms_params | ( | optiga_util_t * | me, |
uint8_t | configuration_type, | ||
uint8_t | value | ||
) |
Sets/updates the OPTIGA Comms Shielded connection configuration in the respective (optiga_util) instance.
Sets/updates the OPTIGA Comms Shielded connection configuration in the respective (optiga_util) instance.
[in,out] | me | Valid instance of optiga_util_t |
[in] | configuration_type | Configuration Type Possible Types are OPTIGA_COMMS_PROTECTION_LEVEL OPTIGA_COMMS_PROTOCOL_VERSION |
[in] | value | Value part for the respective configuration |
Example
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.
Increments the counter object by a value specified by user.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | optiga_counter_oid | OID of counter data object
|
[in] | count | Counter value to be updated |
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
example_optiga_util_update_count.c
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.
Writes the data provided by the user into the specified data object.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | optiga_oid | OID of data object
|
[in] | write_type | Type of write must be either OPTIGA_UTIL_WRITE_ONLY or OPTIGA_UTIL_ERASE_AND_WRITE. |
[in] | offset | Offset from within data object
|
[in] | buffer | Valid pointer to the buffer with user data to write |
[in] | length | Length of data to be written |
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. (Refer Solution Reference Manual) |
Example
example_optiga_util_write_data.c
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.
Writes metadata for the specified data object.
[in] | me | Valid instance of optiga_util_t created using optiga_util_create. |
[in] | optiga_oid | OID of data object
|
[in] | buffer | Valid pointer to the buffer with metadata to write |
[in] | length | Length of metadata to be written |
OPTIGA_UTIL_SUCCESS | Successful invocation |
OPTIGA_UTIL_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_UTIL_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
OPTIGA_DEVICE_ERROR | Command execution failure in OPTIGA and the LSB indicates the error code. |
Example
example_optiga_util_write_data.c