This file defines APIs, types and data structures used in the Command (cmd) module implementation. More...
#include "optiga_lib_common.h"
Go to the source code of this file.
This file defines APIs, types and data structures used in the Command (cmd) module implementation.
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_CMD_LOG_HEX_DATA | ( | array, | |
array_len | |||
) | {} |
#define OPTIGA_CMD_LOG_MESSAGE | ( | msg | ) | {} |
#define OPTIGA_CMD_LOG_STATUS | ( | return_value | ) | {} |
typedef struct optiga_cmd optiga_cmd_t |
OPTIGA command instance structure type.
typedef struct optiga_context optiga_context_t |
OPTIGA comms instance structure type.
optiga_lib_status_t optiga_cmd_calc_hash | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_calc_hash_params_t * | params | ||
) |
Generates hash on external data or data in OID.
Generates hash on external data or data in OID by issuing Calc Hash command to OPTIGA.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of CalcHash Command APDU.
|
[in] | params | InData of CalcHash Command APDU, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking CalcHash command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | Error due to insufficient buffer size.
|
optiga_lib_status_t optiga_cmd_calc_sign | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_calc_sign_params_t * | params | ||
) |
Calculate signature on digest.
Calculate signature on digest by issuing Calc Sign command to OPTIGA.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Calc Sign Command APDU.
|
[in] | params | InData of Calc Sign Command APDU, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking Calc Sign command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_INVALID_INPUT | Instance invoked for session oid, without acquiring the session (from optiga_cmd_gen_keypair). |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | Error due to insufficient buffer size.
|
optiga_lib_status_t optiga_cmd_calc_ssec | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_calc_ssec_params_t * | params | ||
) |
Calculates shared secret.
Calculates shared secret by issuing CalcSSec command to OPTIGA.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Calc SSec Command APDU.
|
[in] | params | Pointer to input parameters, must not be NULL. |
OPTIGA_LIB_SUCCESS | Successful invocation of optiga_comms module. |
OPTIGA_CMD_ERROR | Error occurred before invoking CalcSSec command optiga_comms_transceive returned a failure Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_INVALID_INPUT | Instance invoked for session oid, without acquiring the session (from optiga_cmd_gen_keypair). |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | APDU length formed is greater than OPTIGA_MAX_COMMS_BUFFER_SIZE. |
optiga_lib_status_t optiga_cmd_close_application | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
void * | params | ||
) |
Closes the OPTIGA Application.
Closes the OPTIGA Application by issuing the CloseApplication command.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Command APDU.
|
[in] | params | Secure connection related information, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking CloseApplication command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | APDU length formed is greater than OPTIGA_MAX_COMMS_BUFFER_SIZE. |
optiga_cmd_t* optiga_cmd_create | ( | uint8_t | optiga_instance_id, |
callback_handler_t | handler, | ||
void * | caller_context | ||
) |
Creates an instance of optiga_cmd_t.
Creates an instance of optiga_cmd_t.
[in] | optiga_instance_id | Indicates the OPTIGA configuration to associate with instance. |
[in] | handler | Pointer to callback function, must not be NULL. |
[in] | caller_context | Pointer to upper layer context. |
optiga_cmd_t | * On successful instance creation. |
NULL | Memory allocation failure. Already, OPTIGA_CMD_MAX_REGISTRATIONS number of instances is created. |
optiga_lib_status_t optiga_cmd_decrypt_asym | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_decrypt_asym_params_t * | params | ||
) |
Decrypts data using OPTIGA RSA private key.
Decrypts data using OPTIGA RSA private key by issuing Decrypt Asym command to OPTIGA.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Decrypt Asym Command APDU.
|
[in] | params | InData of Decrypt Asym Command APDU, must not be NULL. |
OPTIGA_LIB_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking Decrypt Asym command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | Error due to insufficient buffer size.
|
optiga_lib_status_t optiga_cmd_derive_key | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_derive_key_params_t * | params | ||
) |
Derives a key.
Derives a key by issuing DeriveKey command to OPTIGA.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Derive Key Command APDU.
|
[in] | params | InData of derive key Command APDU, must not be NULL. |
OPTIGA_LIB_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking derive key command optiga comms transceive returned a failure Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_INVALID_INPUT | Instance invoked for session oid, without acquiring the session(from optiga_cmd_calc_ssec). |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | APDU length formed is greater than OPTIGA_MAX_COMMS_BUFFER_SIZE. |
optiga_lib_status_t optiga_cmd_destroy | ( | optiga_cmd_t * | me | ) |
Destroys the instance of optiga_cmd_t.
Destroys the instance of optiga_cmd_t.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
OPTIGA_LIB_SUCCESS | Successful destruction of instance. |
optiga_lib_status_t optiga_cmd_encrypt_asym | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_encrypt_asym_params_t * | params | ||
) |
Encrypt data using RSA public key.
Encrypts data using RSA public key by issuing Encrypt Asym command to OPTIGA.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Encrypt Asym Command APDU.
|
[in] | params | InData of Encrypt Asym Command APDU, must not be NULL. |
OPTIGA_LIB_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking Encrypt Asym command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_INVALID_INPUT | Instance invoked for encrypting session, without acquiring the session |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | Error due to insufficient buffer size.
|
optiga_lib_status_t optiga_cmd_gen_keypair | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_gen_keypair_params_t * | params | ||
) |
Generates ECC or RSA key-pair.
Generate ECC/RSA key-pair by issuing Generate KeyPair command to OPTIGA.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Generate KeyPair Command APDU.
|
[in] | params | InData of Generate KeyPair Command APDU, must not be NULL. |
OPTIGA_LIB_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking Generate KeyPair command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | Error due to insufficient buffer size.
|
optiga_lib_status_t optiga_cmd_get_data_object | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_get_data_object_params_t * | params | ||
) |
Reads data or metadata of the specified data object.
Reads data or metadata of the specified data object, by issuing the GetDataObject command, based on input parameters.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Get Data Command APDU.
|
[in] | params | InData of Get Data Command APDU, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking GetDataObject command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | Error due to insufficient buffer size.
|
optiga_lib_status_t optiga_cmd_get_random | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_get_random_params_t * | params | ||
) |
Generates random data or pre-master secret for RSA key exchange.
Generates random data or pre-master secret for RSA key exchange, by issuing the GetRandom command to OPTIGA.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Get Random Command APDU.
|
[in] | params | InData of Get Random Command APDU, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking GetRandom command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | APDU length formed is greater than OPTIGA_MAX_COMMS_BUFFER_SIZE. |
optiga_lib_status_t optiga_cmd_open_application | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
void * | params | ||
) |
Opens the OPTIGA Application.
Opens the OPTIGA Application by issuing the OpenApplication command.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Command APDU.
|
[in] | params | Secure connection related information, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking OpenApplication command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | APDU length formed is greater than OPTIGA_MAX_COMMS_BUFFER_SIZE. |
optiga_lib_status_t optiga_cmd_release_lock | ( | const optiga_cmd_t * | me | ) |
Releases the OPTIGA cmd lock.
Releases the OPTIGA cmd lock.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
OPTIGA_CMD_SUCCESS | Successful release of the access layer lock. |
optiga_lib_status_t optiga_cmd_set_data_object | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_set_data_object_params_t * | params | ||
) |
Writes data or metadata to the specified data object.
Writes data or metadata to the specified data object, by issuing the SetDataObject command, based on input parameters.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Set Data Command APDU.
|
[in] | params | InData of Set Data Command APDU, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking SetDataObject command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | APDU length formed is greater than OPTIGA_MAX_COMMS_BUFFER_SIZE. |
optiga_lib_status_t optiga_cmd_set_object_protected | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_set_object_protected_params_t * | params | ||
) |
Writes protected object fragments to OPTIGA.
Writes manifest or data fragement(s) to the specified data object, by issuing the SetObjectProtected command, in a securely.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of Set Object Protected APDU.
|
[in] | params | InData of Set Object Protected APDU, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking SetObjectProtected command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | APDU length formed is greater than OPTIGA_MAX_COMMS_BUFFER_SIZE. |
OPTIGA_CMD_ERROR_INVALID_INPUT | Continue and final APDU command invoked without strict lock acquired for the instance. |
Release the strict sequence
optiga_lib_status_t optiga_cmd_verify_sign | ( | optiga_cmd_t * | me, |
uint8_t | cmd_param, | ||
optiga_verify_sign_params_t * | params | ||
) |
Verifies the signature over the given digest.
Verifies the signature over the given digest by issuing VerifySign command.
[in] | me | Valid instance of optiga_cmd_t created using optiga_cmd_create. |
[in] | cmd_param | Param of VerifySign Command APDU.
|
[in] | params | Parameters for InData of VerifySign Command APDU, must not be NULL. |
OPTIGA_CMD_SUCCESS | Successful invocation. |
OPTIGA_CMD_ERROR | Error occurred before invoking VerifySign command. Error in the asynchronous state machine. |
OPTIGA_CMD_ERROR_MEMORY_INSUFFICIENT | APDU length formed is greater than OPTIGA_MAX_COMMS_BUFFER_SIZE. |