OPTIGA™ Trust M
Host Library Documentation
|
This file implements the prototype declarations of OPTIGA Crypt module. More...
#include "optiga/cmd/optiga_cmd.h"
Go to the source code of this file.
Data Structures | |
union | optiga_crypt_params |
union for OPTIGA crypt parameters More... | |
struct | optiga_crypt |
OPTIGA crypt instance structure. More... | |
#define | OPTIGA_CRYPT_SET_COMMS_PROTECTION_LEVEL(p_instance, protection_level) {} |
Enables the protected I2C communication with OPTIGA for CRYPT instances. More... | |
#define | OPTIGA_CRYPT_SET_COMMS_PROTOCOL_VERSION(p_instance, version) {} |
Select the protocol version required for the I2C protected communication for CRYPT instances. More... | |
typedef union optiga_crypt_params | optiga_crypt_params_t |
union for OPTIGA crypt parameters More... | |
typedef struct optiga_crypt | optiga_crypt_t |
OPTIGA crypt instance structure type. More... | |
LIBRARY_EXPORTS optiga_crypt_t * | optiga_crypt_create (uint8_t optiga_instance_id, callback_handler_t handler, void *caller_context) |
Create an instance of optiga_crypt_t. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_destroy (optiga_crypt_t *me) |
Destroys an instance of optiga_crypt_t. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_random (optiga_crypt_t *me, optiga_rng_type_t rng_type, uint8_t *random_data, uint16_t random_data_length) |
Generates a random number. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hash (optiga_crypt_t *me, optiga_hash_type_t hash_algorithm, uint8_t source_of_data_to_hash, const void *data_to_hash, uint8_t *hash_output) |
Updates a hashing for input data and returns digest. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hash_start (optiga_crypt_t *me, optiga_hash_context_t *hash_ctx) |
Initializes a hash context. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hash_update (optiga_crypt_t *me, optiga_hash_context_t *hash_ctx, uint8_t source_of_data_to_hash, const void *data_to_hash) |
Updates a hash context with the input data. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hash_finalize (optiga_crypt_t *me, optiga_hash_context_t *hash_ctx, uint8_t *hash_output) |
Finalizes and exports the hash output. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_ecc_generate_keypair (optiga_crypt_t *me, optiga_ecc_curve_t curve_id, uint8_t key_usage, bool_t export_private_key, void *private_key, uint8_t *public_key, uint16_t *public_key_length) |
Generates a key pair based on ECC curves. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_ecdsa_sign (optiga_crypt_t *me, const uint8_t *digest, uint8_t digest_length, optiga_key_id_t private_key, uint8_t *signature, uint16_t *signature_length) |
Generates a signature for the given digest. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_ecdsa_verify (optiga_crypt_t *me, const uint8_t *digest, uint8_t digest_length, const uint8_t *signature, uint16_t signature_length, uint8_t public_key_source_type, const void *public_key) |
Verifies the signature over the given digest. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_ecdh (optiga_crypt_t *me, optiga_key_id_t private_key, public_key_from_host_t *public_key, bool_t export_to_host, uint8_t *shared_secret) |
Calculates the shared secret using ECDH algorithm. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_tls_prf (optiga_crypt_t *me, optiga_tls_prf_type_t type, uint16_t secret, const uint8_t *label, uint16_t label_length, const uint8_t *seed, uint16_t seed_length, uint16_t derived_key_length, bool_t export_to_host, uint8_t *derived_key) |
Derives a key. More... | |
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_tls_prf_sha256 (optiga_crypt_t *me, uint16_t secret, const uint8_t *label, uint16_t label_length, const uint8_t *seed, uint16_t seed_length, uint16_t derived_key_length, bool_t export_to_host, uint8_t *derived_key) |
Derives a key using TLS PRF SHA256. More... | |
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_tls_prf_sha384 (optiga_crypt_t *me, uint16_t secret, const uint8_t *label, uint16_t label_length, const uint8_t *seed, uint16_t seed_length, uint16_t derived_key_length, bool_t export_to_host, uint8_t *derived_key) |
Derives a key using TLS PRF SHA384. More... | |
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_tls_prf_sha512 (optiga_crypt_t *me, uint16_t secret, const uint8_t *label, uint16_t label_length, const uint8_t *seed, uint16_t seed_length, uint16_t derived_key_length, bool_t export_to_host, uint8_t *derived_key) |
Derives a key using TLS PRF SHA512. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_rsa_generate_keypair (optiga_crypt_t *me, optiga_rsa_key_type_t key_type, uint8_t key_usage, bool_t export_private_key, void *private_key, uint8_t *public_key, uint16_t *public_key_length) |
Generates a key pair based on RSA key type. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_rsa_sign (optiga_crypt_t *me, optiga_rsa_signature_scheme_t signature_scheme, const uint8_t *digest, uint8_t digest_length, optiga_key_id_t private_key, uint8_t *signature, uint16_t *signature_length, uint16_t salt_length) |
Generates a RSA signature for the given digest based on the input signature scheme. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_rsa_verify (optiga_crypt_t *me, optiga_rsa_signature_scheme_t signature_scheme, const uint8_t *digest, uint8_t digest_length, const uint8_t *signature, uint16_t signature_length, uint8_t public_key_source_type, const void *public_key, uint16_t salt_length) |
Verifies the RSA signature over the given digest. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_rsa_generate_pre_master_secret (optiga_crypt_t *me, const uint8_t *optional_data, uint16_t optional_data_length, uint16_t pre_master_secret_length) |
Generates a pre-master secret. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_rsa_encrypt_message (optiga_crypt_t *me, optiga_rsa_encryption_scheme_t encryption_scheme, const uint8_t *message, uint16_t message_length, const uint8_t *label, uint16_t label_length, uint8_t public_key_source_type, const void *public_key, uint8_t *encrypted_message, uint16_t *encrypted_message_length) |
Encrypts message using RSA public key. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_rsa_encrypt_session (optiga_crypt_t *me, optiga_rsa_encryption_scheme_t encryption_scheme, const uint8_t *label, uint16_t label_length, uint8_t public_key_source_type, const void *public_key, uint8_t *encrypted_message, uint16_t *encrypted_message_length) |
Encrypts session data using RSA public key. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_rsa_decrypt_and_export (optiga_crypt_t *me, optiga_rsa_encryption_scheme_t encryption_scheme, const uint8_t *encrypted_message, uint16_t encrypted_message_length, const uint8_t *label, uint16_t label_length, optiga_key_id_t private_key, uint8_t *message, uint16_t *message_length) |
Decrypts input data using OPTIGA private key and export it to the host. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_rsa_decrypt_and_store (optiga_crypt_t *me, optiga_rsa_encryption_scheme_t encryption_scheme, const uint8_t *encrypted_message, uint16_t encrypted_message_length, const uint8_t *label, uint16_t label_length, optiga_key_id_t private_key) |
Decrypts input data using OPTIGA private key and stores it in a OPTIGA session. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_encrypt (optiga_crypt_t *me, optiga_symmetric_encryption_mode_t encryption_mode, optiga_key_id_t symmetric_key_oid, const uint8_t *plain_data, uint32_t plain_data_length, const uint8_t *iv, uint16_t iv_length, const uint8_t *associated_data, uint16_t associated_data_length, uint8_t *encrypted_data, uint32_t *encrypted_data_length) |
Encrypt the data using symmetric encryption mode and export encrypted message to host. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_encrypt_ecb (optiga_crypt_t *me, optiga_key_id_t symmetric_key_oid, const uint8_t *plain_data, uint32_t plain_data_length, uint8_t *encrypted_data, uint32_t *encrypted_data_length) |
Encrypt the data using symmetric encryption scheme using ECB mode of operation. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_encrypt_start (optiga_crypt_t *me, optiga_symmetric_encryption_mode_t encryption_mode, optiga_key_id_t symmetric_key_oid, const uint8_t *plain_data, uint32_t plain_data_length, const uint8_t *iv, uint16_t iv_length, const uint8_t *associated_data, uint16_t associated_data_length, uint16_t total_plain_data_length, uint8_t *encrypted_data, uint32_t *encrypted_data_length) |
Initiates a symmetric encryption sequence for input data using symmetric key from OPTIGA. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_encrypt_continue (optiga_crypt_t *me, const uint8_t *plain_data, uint32_t plain_data_length, uint8_t *encrypted_data, uint32_t *encrypted_data_length) |
Encrypts input data using symmetric key from OPTIGA and exports block aligned encrypted data. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_encrypt_final (optiga_crypt_t *me, const uint8_t *plain_data, uint32_t plain_data_length, uint8_t *encrypted_data, uint32_t *encrypted_data_length) |
Encrypts input data using symmetric key from OPTIGA, exports block aligned encrypted data and completes the encryption sequence. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_decrypt (optiga_crypt_t *me, optiga_symmetric_encryption_mode_t encryption_mode, optiga_key_id_t symmetric_key_oid, const uint8_t *encrypted_data, uint32_t encrypted_data_length, const uint8_t *iv, uint16_t iv_length, const uint8_t *associated_data, uint16_t associated_data_length, uint8_t *plain_data, uint32_t *plain_data_length) |
Decrypt the encrypted data using symmetric encryption mode and export plain message to host. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_decrypt_ecb (optiga_crypt_t *me, optiga_key_id_t symmetric_key_oid, const uint8_t *encrypted_data, uint32_t encrypted_data_length, uint8_t *plain_data, uint32_t *plain_data_length) |
Decrypt the data using symmetric encryption scheme using ECB mode of operation. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_decrypt_start (optiga_crypt_t *me, optiga_symmetric_encryption_mode_t encryption_mode, optiga_key_id_t symmetric_key_oid, const uint8_t *encrypted_data, uint32_t encrypted_data_length, const uint8_t *iv, uint16_t iv_length, const uint8_t *associated_data, uint16_t associated_data_length, uint16_t total_encrypted_data_length, uint8_t *plain_data, uint32_t *plain_data_length) |
Initiate symmetric decryption sequence for input data using symmetric key from OPTIGA. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_decrypt_continue (optiga_crypt_t *me, const uint8_t *encrypted_data, uint32_t encrypted_data_length, uint8_t *plain_data, uint32_t *plain_data_length) |
Decrypts input encrypted data using symmetric key from OPTIGA and exports block aligned plain data. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_decrypt_final (optiga_crypt_t *me, const uint8_t *encrypted_data, uint32_t encrypted_data_length, uint8_t *plain_data, uint32_t *plain_data_length) |
Decrypts input data using symmetric key from OPTIGA, exports block aligned plain data and completes the decryption sequence. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hmac (optiga_crypt_t *me, optiga_hmac_type_t type, uint16_t secret, const uint8_t *input_data, uint32_t input_data_length, uint8_t *mac, uint32_t *mac_length) |
Generates HMAC on the input message using input secret from OPTIGA and exports the generated HMAC to the host. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hmac_start (optiga_crypt_t *me, optiga_hmac_type_t type, uint16_t secret, const uint8_t *input_data, uint32_t input_data_length) |
Initiates a HMAC generation sequence for the input data using input secret from OPTIGA. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hmac_update (optiga_crypt_t *me, const uint8_t *input_data, uint32_t input_data_length) |
Generates HMAC on the input message using input secret from OPTIGA, update the previously generated HMAC value internally. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hmac_finalize (optiga_crypt_t *me, const uint8_t *input_data, uint32_t input_data_length, uint8_t *mac, uint32_t *mac_length) |
Generates HMAC on the input message using input secret from OPTIGA and exports the finalized HMAC to host. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hkdf (optiga_crypt_t *me, optiga_hkdf_type_t type, uint16_t secret, const uint8_t *salt, uint16_t salt_length, const uint8_t *info, uint16_t info_length, uint16_t derived_key_length, bool_t export_to_host, uint8_t *derived_key) |
Derives a key or shared secret using HKDF operation from the secret stored in OPTIGA. More... | |
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hkdf_sha256 (optiga_crypt_t *me, uint16_t secret, const uint8_t *salt, uint16_t salt_length, const uint8_t *info, uint16_t info_length, uint16_t derived_key_length, bool_t export_to_host, uint8_t *derived_key) |
Derives a key or shared secret using HKDF-SHA256 operation from the secret stored in OPTIGA. More... | |
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hkdf_sha384 (optiga_crypt_t *me, uint16_t secret, const uint8_t *salt, uint16_t salt_length, const uint8_t *info, uint16_t info_length, uint16_t derived_key_length, bool_t export_to_host, uint8_t *derived_key) |
Derives a key or shared secret using HKDF-SHA384 operation from the secret stored in OPTIGA. More... | |
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hkdf_sha512 (optiga_crypt_t *me, uint16_t secret, const uint8_t *salt, uint16_t salt_length, const uint8_t *info, uint16_t info_length, uint16_t derived_key_length, bool_t export_to_host, uint8_t *derived_key) |
Derives a key or shared secret using HKDF-SHA512 operation from the secret stored in OPTIGA. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_symmetric_generate_key (optiga_crypt_t *me, optiga_symmetric_key_type_t key_type, uint8_t key_usage, bool_t export_symmetric_key, void *symmetric_key) |
Generates a symmetric key using OPTIGA. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_generate_auth_code (optiga_crypt_t *me, optiga_rng_type_t rng_type, const uint8_t *optional_data, uint16_t optional_data_length, uint8_t *random_data, uint16_t random_data_length) |
Generates a random number using OPTIGA and stores the same in acquired session context at OPTIGA. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_hmac_verify (optiga_crypt_t *me, optiga_hmac_type_t type, uint16_t secret, const uint8_t *input_data, uint32_t input_data_length, const uint8_t *hmac, uint32_t hmac_length) |
Performs the HMAC verification for the provided authorization value using OPTIGA. More... | |
LIBRARY_EXPORTS optiga_lib_status_t | optiga_crypt_clear_auto_state (optiga_crypt_t *me, uint16_t secret) |
This operation clears the AUTO state at OPTIGA for input secret OID. More... | |
This file implements the prototype declarations of OPTIGA Crypt module.
Definition in file optiga_crypt.h.
#define OPTIGA_CRYPT_SET_COMMS_PROTECTION_LEVEL | ( | p_instance, | |
protection_level | |||
) | {} |
Enables the protected I2C communication with OPTIGA for CRYPT instances.
Enables the protected I2C communication with OPTIGA
[in] | p_instance | Valid pointer to an instance |
[in] | protection_level | Required protection mode
|
Definition at line 2527 of file optiga_crypt.h.
#define OPTIGA_CRYPT_SET_COMMS_PROTOCOL_VERSION | ( | p_instance, | |
version | |||
) | {} |
Select the protocol version required for the I2C protected communication for CRYPT instances.
Select the protocol version required for the I2C protected communication
[in] | p_instance | Valid pointer to an instance |
[in] | version | Required protocol version
|
Definition at line 2555 of file optiga_crypt.h.
typedef union optiga_crypt_params optiga_crypt_params_t |
union for OPTIGA crypt parameters
typedef struct optiga_crypt optiga_crypt_t |
OPTIGA crypt instance structure type.
Definition at line 1 of file optiga_crypt.h.
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_clear_auto_state | ( | optiga_crypt_t * | me, |
uint16_t | secret | ||
) |
This operation clears the AUTO state at OPTIGA for input secret OID.
Clears the AUTO state and session if it's already acquired.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | secret | OPTIGA OID with input secret. It should be of AUTOREF type |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete |
Example
example_optiga_crypt_clear_auto_state.c
LIBRARY_EXPORTS optiga_crypt_t* optiga_crypt_create | ( | uint8_t | optiga_instance_id, |
callback_handler_t | handler, | ||
void * | caller_context | ||
) |
Create an instance of optiga_crypt_t.
Create an instance of optiga_crypt_t.
[in] | optiga_instance_id | Indicates the OPTIGA instance to be associated with optiga_crypt_t. Should be defined as below: Use OPTIGA_INSTANCE_ID_0. |
[in] | handler | Pointer to callback function, must not be NULL. |
[in] | caller_context | Pointer to upper layer context. Contains user context data. |
optiga_crypt_t | On success function will return pointer of optiga_crypt_t. |
NULL | Input arguments are NULL. Low layer function fails. OPTIGA_CMD_MAX_REGISTRATIONS number of instances are already created. |
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_destroy | ( | optiga_crypt_t * | me | ) |
Destroys an instance of optiga_crypt_t.
Destroys the optiga_crypt_t instance.
[in] | me | Valid instance of optiga_crypt_t. |
OPTIGA_LIB_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_ERROR_INSTANCE_IN_USE | The previous operation with the same instance is not complete. |
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_ecc_generate_keypair | ( | optiga_crypt_t * | me, |
optiga_ecc_curve_t | curve_id, | ||
uint8_t | key_usage, | ||
bool_t | export_private_key, | ||
void * | private_key, | ||
uint8_t * | public_key, | ||
uint16_t * | public_key_length | ||
) |
Generates a key pair based on ECC curves.
Generates an ECC key-pair based on the input curve.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | curve_id | ECC curve id as optiga_ecc_curve. |
[in] | key_usage | Key usage defined in optiga_key_usage_t.
|
[in] | export_private_key | TRUE (1) or Non-Zero value - Exports private key to the host. FALSE (0) - Exports only public key to the host and writes private key to OPTIGA. The input key_usage is ignored. |
[in] | private_key | Buffer to store private key or private key OID of OPTIGA, must not be NULL.
|
[in,out] | public_key | Buffer to store public key, must not be NULL. |
[in] | public_key_length | Initially set as length of buffer to store public_key, later updated as actual length of public_key. |
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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_crypt_ecc_generate_keypair.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_ecdh | ( | optiga_crypt_t * | me, |
optiga_key_id_t | private_key, | ||
public_key_from_host_t * | public_key, | ||
bool_t | export_to_host, | ||
uint8_t * | shared_secret | ||
) |
Calculates the shared secret using ECDH algorithm.
Calculates the shared secret using ECDH algorithm
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | private_key | Object ID of the private key stored in OPTIGA.
|
[in] | public_key | Pointer to the public key structure for shared secret generation with its properties, must not be NULL.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the generated shared secret to Host. FALSE (0) - Stores the generated shared secret into the session object ID acquired by the instance. |
[in,out] | shared_secret | Pointer to the shared secret buffer, only if export_to_host is TRUE. The size of the buffer shall be equal or more than the key size. Otherwise provide NULL as input. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. Session is not available in instance and the private_key type is OPTIGA_KEY_ID_SESSION_BASED |
OPTIGA_CRYPT_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_crypt_ecdh.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_ecdsa_sign | ( | optiga_crypt_t * | me, |
const uint8_t * | digest, | ||
uint8_t | digest_length, | ||
optiga_key_id_t | private_key, | ||
uint8_t * | signature, | ||
uint16_t * | signature_length | ||
) |
Generates a signature for the given digest.
Generates a signature for the given digest using private key stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | digest | Digest on which signature is generated. |
[in] | digest_length | Length of the input digest. |
[in] | private_key | Private key OID to generate signature. |
[in,out] | signature | Pointer to store generated signature, must not be NULL.
|
[in,out] | signature_length | Length of signature. Initial value set as length of buffer, later updated as the actual length of generated signature. |
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. Session is not available in instance and the private_key type is OPTIGA_KEY_ID_SESSION_BASED |
OPTIGA_CRYPT_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_crypt_ecdsa_sign.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_ecdsa_verify | ( | optiga_crypt_t * | me, |
const uint8_t * | digest, | ||
uint8_t | digest_length, | ||
const uint8_t * | signature, | ||
uint16_t | signature_length, | ||
uint8_t | public_key_source_type, | ||
const void * | public_key | ||
) |
Verifies the signature over the given digest.
Verifies the signature over a given digest provided with the input data.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | digest | Pointer to a given digest buffer, must not be NULL. |
[in] | digest_length | Length of digest. |
[in] | signature | Pointer to a given signature buffer, must not be NULL. |
[in] | signature_length | Length of signature. |
[in] | public_key_source_type | Public key from host / public key of certificate OID from OPTIGA. Value must be one of the below
|
[in] | public_key | Public key from host / OID of certificate object. Value must be one of the below
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_ecdsa_verify.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_generate_auth_code | ( | optiga_crypt_t * | me, |
optiga_rng_type_t | rng_type, | ||
const uint8_t * | optional_data, | ||
uint16_t | optional_data_length, | ||
uint8_t * | random_data, | ||
uint16_t | random_data_length | ||
) |
Generates a random number using OPTIGA and stores the same in acquired session context at OPTIGA.
Generates random stream code for user provided length.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | rng_type | Type of random data generator.
|
[in] | optional_data | Optional data that gets prepended to the generated random secret.
|
[in] | optional_data_length | Length of the optional data provided. It is ignored if optional_data is NULL
|
[in,out] | random_data | Pointer to the buffer into which random data is stored, must not be NULL. |
[in] | random_data_length | Length of random data to be generated.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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) |
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hash | ( | optiga_crypt_t * | me, |
optiga_hash_type_t | hash_algorithm, | ||
uint8_t | source_of_data_to_hash, | ||
const void * | data_to_hash, | ||
uint8_t * | hash_output | ||
) |
Updates a hashing for input data and returns digest.
Updates hashing for the given data and returns digest.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | hash_algorithm | Hash algorithm of optiga_hash_type_t. |
[in] | source_of_data_to_hash | Data from host / Data in OPTIGA. Must be one of the below
|
[in] | data_to_hash | Data for hashing either in hash_data_from_host_t or in hash_data_in_optiga_t |
[in,out] | hash_output | Pointer to the valid buffer to store hash output. |
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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_crypt_hash.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hash_finalize | ( | optiga_crypt_t * | me, |
optiga_hash_context_t * | hash_ctx, | ||
uint8_t * | hash_output | ||
) |
Finalizes and exports the hash output.
Finalizes the hash context and returns hash as output.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | hash_ctx | Pointer to optiga_hash_context_t containing hash context from OPTIGA, must not be NULL.
|
[in,out] | hash_output | Output Hash. |
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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_crypt_hash.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hash_start | ( | optiga_crypt_t * | me, |
optiga_hash_context_t * | hash_ctx | ||
) |
Initializes a hash context.
Sets up a hash context and exports it.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in,out] | hash_ctx | Pointer to optiga_hash_context_t to store the hash context from OPTIGA.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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_crypt_hash.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hash_update | ( | optiga_crypt_t * | me, |
optiga_hash_context_t * | hash_ctx, | ||
uint8_t | source_of_data_to_hash, | ||
const void * | data_to_hash | ||
) |
Updates a hash context with the input data.
Updates hashing for the given data and hash context then export the updated hash context.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | hash_ctx | Pointer to optiga_hash_context_t containing hash context from OPTIGA, must not be NULL
|
[in] | source_of_data_to_hash | Data from host / Data in optiga. Must be one of the below
|
[in] | data_to_hash | Data for hashing either in hash_data_from_host or in hash_data_in_optiga |
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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_crypt_hash.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hkdf | ( | optiga_crypt_t * | me, |
optiga_hkdf_type_t | type, | ||
uint16_t | secret, | ||
const uint8_t * | salt, | ||
uint16_t | salt_length, | ||
const uint8_t * | info, | ||
uint16_t | info_length, | ||
uint16_t | derived_key_length, | ||
bool_t | export_to_host, | ||
uint8_t * | derived_key | ||
) |
Derives a key or shared secret using HKDF operation from the secret stored in OPTIGA.
Derives a key or shared secret using HKDF operation from the secret stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | type | HKDF scheme as optiga_hkdf_type_t. |
[in] | secret | Object ID of the secret stored in OPTIGA.
|
[in] | salt | Pointer to buffer containing salt value, can be NULL if not applicable. |
[in] | salt_length | Length of salt. |
[in] | info | Pointer to buffer containing application specific information, can be NULL if not applicable. |
[in] | info_length | Length of info. |
[in] | derived_key_length | Length of derived key.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the derived key to Host. FALSE (0) - Stores the derived key into the session object ID acquired by the instance. |
[in,out] | derived_key | Pointer to the valid buffer with a minimum size of derived_key_length, in case of exporting the key to host(export_to_host is non-zero value). Otherwise set to NULL. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. Session is not available in instance and the secret type is OPTIGA_KEY_ID_SESSION_BASED |
OPTIGA_CRYPT_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_crypt_hkdf.c
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hkdf_sha256 | ( | optiga_crypt_t * | me, |
uint16_t | secret, | ||
const uint8_t * | salt, | ||
uint16_t | salt_length, | ||
const uint8_t * | info, | ||
uint16_t | info_length, | ||
uint16_t | derived_key_length, | ||
bool_t | export_to_host, | ||
uint8_t * | derived_key | ||
) |
Derives a key or shared secret using HKDF-SHA256 operation from the secret stored in OPTIGA.
Derives a key or shared secret using HKDF-SHA256 operation from the secret stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | secret | Object ID of the secret stored in OPTIGA.
|
[in] | salt | Pointer to buffer containing salt value, can be NULL if not applicable. |
[in] | salt_length | Length of salt. |
[in] | info | Pointer to buffer containing application specific information, can be NULL if not applicable. |
[in] | info_length | Length of info. |
[in] | derived_key_length | Length of derived key.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the derived key to Host. FALSE (0) - Stores the derived key into the session object ID acquired by the instance. |
[in,out] | derived_key | Pointer to the valid buffer with a minimum size of derived_key_length, in case of exporting the key to host(export_to_host is non-zero value). Otherwise set to NULL. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. Session is not available in instance and the secret type is OPTIGA_KEY_ID_SESSION_BASED |
OPTIGA_CRYPT_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_crypt_hkdf.c
Definition at line 2145 of file optiga_crypt.h.
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hkdf_sha384 | ( | optiga_crypt_t * | me, |
uint16_t | secret, | ||
const uint8_t * | salt, | ||
uint16_t | salt_length, | ||
const uint8_t * | info, | ||
uint16_t | info_length, | ||
uint16_t | derived_key_length, | ||
bool_t | export_to_host, | ||
uint8_t * | derived_key | ||
) |
Derives a key or shared secret using HKDF-SHA384 operation from the secret stored in OPTIGA.
Derives a key or shared secret using HKDF-SHA384 operation from the secret stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | secret | Object ID of the secret stored in OPTIGA.
|
[in] | salt | Pointer to buffer containing salt value, can be NULL if not applicable. |
[in] | salt_length | Length of salt. |
[in] | info | Pointer to buffer containing application specific information, can be NULL if not applicable. |
[in] | info_length | Length of info. |
[in] | derived_key_length | Length of derived key.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the derived key to Host. FALSE (0) - Stores the derived key into the session object ID acquired by the instance. |
[in,out] | derived_key | Pointer to the valid buffer with a minimum size of derived_key_length, in case of exporting the key to host(export_to_host is non-zero value). Otherwise set to NULL. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. Session is not available in instance and the secret type is OPTIGA_KEY_ID_SESSION_BASED |
OPTIGA_CRYPT_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
None
Definition at line 2216 of file optiga_crypt.h.
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hkdf_sha512 | ( | optiga_crypt_t * | me, |
uint16_t | secret, | ||
const uint8_t * | salt, | ||
uint16_t | salt_length, | ||
const uint8_t * | info, | ||
uint16_t | info_length, | ||
uint16_t | derived_key_length, | ||
bool_t | export_to_host, | ||
uint8_t * | derived_key | ||
) |
Derives a key or shared secret using HKDF-SHA512 operation from the secret stored in OPTIGA.
Derives a key or shared secret using HKDF-SHA384 operation from the secret stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | secret | Object ID of the secret stored in OPTIGA.
|
[in] | salt | Pointer to buffer containing salt value, can be NULL if not applicable. |
[in] | salt_length | Length of salt. |
[in] | info | Pointer to buffer containing application specific information, can be NULL if not applicable. |
[in] | info_length | Length of info. |
[in] | derived_key_length | Length of derived key.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the derived key to Host. FALSE (0) - Stores the derived key into the session object ID acquired by the instance. |
[in,out] | derived_key | Pointer to the valid buffer with a minimum size of derived_key_length, in case of exporting the key to host(export_to_host is non-zero value). Otherwise set to NULL. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. Session is not available in instance and the secret type is OPTIGA_KEY_ID_SESSION_BASED |
OPTIGA_CRYPT_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
None
Definition at line 2287 of file optiga_crypt.h.
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hmac | ( | optiga_crypt_t * | me, |
optiga_hmac_type_t | type, | ||
uint16_t | secret, | ||
const uint8_t * | input_data, | ||
uint32_t | input_data_length, | ||
uint8_t * | mac, | ||
uint32_t * | mac_length | ||
) |
Generates HMAC on the input message using input secret from OPTIGA and exports the generated HMAC to the host.
Generates HMAC on the input message using input secret from OPTIGA and exports the generated HMAC to host.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | type | HMAC type |
[in] | secret | OPTIGA OID with input secret
|
[in] | input_data | Pointer to input data for HMAC generation. |
[in] | input_data_length | Length of input data for HMAC generation.
|
[in,out] | mac | Pointer to buffer to store generated HMAC |
[in,out] | mac_length | Pointer to length of the mac. Initial value set as length of buffer, later updated as the actual length of generated HMAC.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_hmac.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hmac_finalize | ( | optiga_crypt_t * | me, |
const uint8_t * | input_data, | ||
uint32_t | input_data_length, | ||
uint8_t * | mac, | ||
uint32_t * | mac_length | ||
) |
Generates HMAC on the input message using input secret from OPTIGA and exports the finalized HMAC to host.
Generates HMAC on the input message using input secret from OPTIGA and exports the finalized HMAC to host.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | input_data | Pointer to input data for HMAC generation. |
[in] | input_data_length | Length of input data for HMAC generation.
|
[in,out] | mac | Pointer to buffer to store generated HMAC |
[in,out] | mac_length | Pointer to length of the mac. Initial value set as length of buffer, later updated as the actual length of generated HMAC.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_hmac.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hmac_start | ( | optiga_crypt_t * | me, |
optiga_hmac_type_t | type, | ||
uint16_t | secret, | ||
const uint8_t * | input_data, | ||
uint32_t | input_data_length | ||
) |
Initiates a HMAC generation sequence for the input data using input secret from OPTIGA.
Initiates a HMAC generation sequence for the input data.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | type | HMAC type |
[in] | secret | OPTIGA OID with input secret
|
[in] | input_data | Pointer to input data for HMAC generation. |
[in] | input_data_length | Length of input data for HMAC generation.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_hmac.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hmac_update | ( | optiga_crypt_t * | me, |
const uint8_t * | input_data, | ||
uint32_t | input_data_length | ||
) |
Generates HMAC on the input message using input secret from OPTIGA, update the previously generated HMAC value internally.
Generates HMAC on the input message using input secret from OPTIGA and updates the previously generated HMAC value internally.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | input_data | Pointer to input data for HMAC generation. |
[in] | input_data_length | Length of input data for HMAC generation.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_hmac.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hmac_verify | ( | optiga_crypt_t * | me, |
optiga_hmac_type_t | type, | ||
uint16_t | secret, | ||
const uint8_t * | input_data, | ||
uint32_t | input_data_length, | ||
const uint8_t * | hmac, | ||
uint32_t | hmac_length | ||
) |
Performs the HMAC verification for the provided authorization value using OPTIGA.
Verifies HMAC generated at host with HMAC generated from OPTIGA for the provided authorization value.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | type | HMAC type as optiga_hmac_type_t |
[in] | secret | OPTIGA OID with input secret
|
[in] | input_data | Pointer to input data for HMAC generation.
|
[in] | input_data_length | Length of input data.
|
[in] | hmac | Pointer to buffer of HMAC generated at host which gets verified at OPTIGA. |
[in] | hmac_length | Length of the generated hmac at host.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_hmac_verify.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_random | ( | optiga_crypt_t * | me, |
optiga_rng_type_t | rng_type, | ||
uint8_t * | random_data, | ||
uint16_t | random_data_length | ||
) |
Generates a random number.
Generates the requested random stream of data for the user provided length.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | rng_type | Type of random data generator.
|
[in,out] | random_data | Pointer to the buffer into which random data is stored, must not be NULL. |
[in] | random_data_length | Length of random data to be generated.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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_crypt_random.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_rsa_decrypt_and_export | ( | optiga_crypt_t * | me, |
optiga_rsa_encryption_scheme_t | encryption_scheme, | ||
const uint8_t * | encrypted_message, | ||
uint16_t | encrypted_message_length, | ||
const uint8_t * | label, | ||
uint16_t | label_length, | ||
optiga_key_id_t | private_key, | ||
uint8_t * | message, | ||
uint16_t * | message_length | ||
) |
Decrypts input data using OPTIGA private key and export it to the host.
Decrypts input data using RSA private key from OPTIGA and exports the decrypted data to the host.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encryption_scheme | RSA encryption scheme. |
[in] | encrypted_message | Pointer to the data to be decrypted. |
[in] | encrypted_message_length | Length of the data to be decrypted. |
[in] | label | Pointer to a label (Reserved for future use). |
[in] | label_length | Length of the label (Reserved for future use). |
[in] | private_key | RSA private key in OPTIGA |
[in,out] | message | Pointer to buffer to store decrypted message. |
[in,out] | message_length | Pointer to length of the decrypted message. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_rsa_decrypt_and_store | ( | optiga_crypt_t * | me, |
optiga_rsa_encryption_scheme_t | encryption_scheme, | ||
const uint8_t * | encrypted_message, | ||
uint16_t | encrypted_message_length, | ||
const uint8_t * | label, | ||
uint16_t | label_length, | ||
optiga_key_id_t | private_key | ||
) |
Decrypts input data using OPTIGA private key and stores it in a OPTIGA session.
Decrypts input data using RSA private key from OPTIGA and stores it in a OPTIGA session.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encryption_scheme | RSA encryption scheme. |
[in] | encrypted_message | Pointer to the data to be decrypted. |
[in] | encrypted_message_length | Length of the data to be decrypted. |
[in] | label | Pointer to a label (Reserved for future use). |
[in] | label_length | Length of the label (Reserved for future use). |
[in] | private_key | RSA private key in OPTIGA. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_rsa_encrypt_message | ( | optiga_crypt_t * | me, |
optiga_rsa_encryption_scheme_t | encryption_scheme, | ||
const uint8_t * | message, | ||
uint16_t | message_length, | ||
const uint8_t * | label, | ||
uint16_t | label_length, | ||
uint8_t | public_key_source_type, | ||
const void * | public_key, | ||
uint8_t * | encrypted_message, | ||
uint16_t * | encrypted_message_length | ||
) |
Encrypts message using RSA public key.
Encrypts message using RSA public key which is either provided by the host or stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encryption_scheme | RSA encryption scheme. |
[in] | message | Pointer to message to be encrypted. |
[in] | message_length | Length of the message to be encrypted. |
[in] | label | Pointer to a label (Reserved for future use). |
[in] | label_length | Length of the label (Reserved for future use). |
[in] | public_key_source_type | Public key from host / public key of certificate OID from OPTIGA. Value must be one of the below
|
[in] | public_key | Public key from host / public key of certificate OID. Value must be one of the below
|
[in,out] | encrypted_message | Pointer to buffer to store encrypted message. |
[in,out] | encrypted_message_length | Pointer to length of the encrypted message.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_encrypt_message.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_rsa_encrypt_session | ( | optiga_crypt_t * | me, |
optiga_rsa_encryption_scheme_t | encryption_scheme, | ||
const uint8_t * | label, | ||
uint16_t | label_length, | ||
uint8_t | public_key_source_type, | ||
const void * | public_key, | ||
uint8_t * | encrypted_message, | ||
uint16_t * | encrypted_message_length | ||
) |
Encrypts session data using RSA public key.
Encrypts session data using RSA public key which is either provided by the host or stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encryption_scheme | RSA encryption scheme. |
[in] | label | Pointer to a label (used only is case of RSAES_OAEP_SHA256 otherwise ignored). |
[in] | label_length | Length of the label (used only is case of RSAES_OAEP_SHA256 otherwise ignored). |
[in] | public_key_source_type | Public key from host / public key of certificate OID from OPTIGA. Value must be one of the below
|
[in] | public_key | Public key from host / public key of certificate OID. Value must be one of the below
|
[in,out] | encrypted_message | Pointer to buffer to store encrypted message. |
[in,out] | encrypted_message_length | Pointer to length of the encrypted message. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_encrypt_session.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_rsa_generate_keypair | ( | optiga_crypt_t * | me, |
optiga_rsa_key_type_t | key_type, | ||
uint8_t | key_usage, | ||
bool_t | export_private_key, | ||
void * | private_key, | ||
uint8_t * | public_key, | ||
uint16_t * | public_key_length | ||
) |
Generates a key pair based on RSA key type.
Generates a RSA key-pair based on the type of the key.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | key_type | RSA key type defined in optiga_rsa_key_type_t. |
[in] | key_usage | Key usage defined in optiga_key_usage_t.
|
[in] | export_private_key | TRUE (1) or a non-zero value - Exports private key to the host. FALSE (0) - Exports only public key to the host and writes private key to OPTIGA. The input key_usage is ignored. |
[in,out] | private_key | Buffer to store private key or private key OID of OPTIGA, must not be NULL.
|
[in,out] | public_key | Buffer to store public key, must not be NULL. |
[in,out] | public_key_length | Initially set as length of public_key, later updated as actual length of public_key. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_rsa_generate_keypair.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_rsa_generate_pre_master_secret | ( | optiga_crypt_t * | me, |
const uint8_t * | optional_data, | ||
uint16_t | optional_data_length, | ||
uint16_t | pre_master_secret_length | ||
) |
Generates a pre-master secret.
Generates a pre-master secret for RSA key exchange and stores in the acquired session
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | optional_data | Optional data that gets prepended to the generated random secret.
|
[in] | optional_data_length | Length of the optional data provided. It is ignored if optional_data is NULL
|
[in] | pre_master_secret_length | Length of the shared secret to be generated.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided.
|
OPTIGA_CRYPT_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_crypt_encrypt_session.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_rsa_sign | ( | optiga_crypt_t * | me, |
optiga_rsa_signature_scheme_t | signature_scheme, | ||
const uint8_t * | digest, | ||
uint8_t | digest_length, | ||
optiga_key_id_t | private_key, | ||
uint8_t * | signature, | ||
uint16_t * | signature_length, | ||
uint16_t | salt_length | ||
) |
Generates a RSA signature for the given digest based on the input signature scheme.
Generates a signature for the given digest using private key stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | signature_scheme | RSA signature scheme defined in optiga_rsa_signature_scheme_t |
[in] | digest | Digest on which signature is generated. |
[in] | digest_length | Length of the input digest. |
[in] | private_key | Private key OID to generate signature. This is static private key only. |
[in,out] | signature | Pointer to store generated signature, must not be NULL. |
[in] | signature_length | Length of signature. Initial value set as length of buffer, later updated as the actual length of generated signature.
|
[in] | salt_length | Reserved for future use. Parameter for RSA PSS signature scheme. |
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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_crypt_rsa_sign.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_rsa_verify | ( | optiga_crypt_t * | me, |
optiga_rsa_signature_scheme_t | signature_scheme, | ||
const uint8_t * | digest, | ||
uint8_t | digest_length, | ||
const uint8_t * | signature, | ||
uint16_t | signature_length, | ||
uint8_t | public_key_source_type, | ||
const void * | public_key, | ||
uint16_t | salt_length | ||
) |
Verifies the RSA signature over the given digest.
Verifies the signature over a given digest provided with the input data.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | signature_scheme | RSA signature scheme defined in optiga_rsa_signature_scheme_t |
[in] | digest | Pointer to a given digest buffer, must not be NULL. |
[in] | digest_length | Length of digest. |
[in] | signature | Pointer to a given signature buffer, must not be NULL. |
[in] | signature_length | Length of signature. |
[in] | public_key_source_type | Public key from host / public key of certificate OID from OPTIGA. Value must be one of the below
|
[in] | public_key | Public key from host / public key of certificate OID. Value must be one of the below
|
[in] | salt_length | Reserved for future use. Parameter for RSA PSS signature scheme. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_rsa_verify.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_decrypt | ( | optiga_crypt_t * | me, |
optiga_symmetric_encryption_mode_t | encryption_mode, | ||
optiga_key_id_t | symmetric_key_oid, | ||
const uint8_t * | encrypted_data, | ||
uint32_t | encrypted_data_length, | ||
const uint8_t * | iv, | ||
uint16_t | iv_length, | ||
const uint8_t * | associated_data, | ||
uint16_t | associated_data_length, | ||
uint8_t * | plain_data, | ||
uint32_t * | plain_data_length | ||
) |
Decrypt the encrypted data using symmetric encryption mode and export plain message to host.
Decrypt the encrypted data using symmetric key from OPTIGA and export the plain data to host.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encryption_mode | Symmetric encryption mode |
[in] | symmetric_key_oid | OPTIGA symmetric key OID
|
[in] | encrypted_data | Pointer to the data to be decrypted. |
[in] | encrypted_data_length | Length of the data to be decrypted.
|
[in] | iv | Pointer to an IV(initialization vector) or nonce.
|
[in] | iv_length | Length of the IV
|
[in] | associated_data | Pointer to associated data
|
[in] | associated_data_length | Length of associated data
|
[in,out] | plain_data | Pointer to buffer to store plain data. |
[in,out] | plain_data_length | Pointer to length of the plain_data. Initial value set as length of buffer, later updated as the actual length of plain data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_decrypt_continue | ( | optiga_crypt_t * | me, |
const uint8_t * | encrypted_data, | ||
uint32_t | encrypted_data_length, | ||
uint8_t * | plain_data, | ||
uint32_t * | plain_data_length | ||
) |
Decrypts input encrypted data using symmetric key from OPTIGA and exports block aligned plain data.
Decrypts input encrypted data using symmetric key from OPTIGA and exports block aligned plain data.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encrypted_data | Pointer to the data to be decrypted. |
[in] | encrypted_data_length | Length of the data to be decrypted.
|
[in,out] | plain_data | Pointer to buffer to store plain data. |
[in,out] | plain_data_length | Pointer to length of the plain_data. Initial value set as length of buffer, later updated as the actual length of plain data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_decrypt_ecb | ( | optiga_crypt_t * | me, |
optiga_key_id_t | symmetric_key_oid, | ||
const uint8_t * | encrypted_data, | ||
uint32_t | encrypted_data_length, | ||
uint8_t * | plain_data, | ||
uint32_t * | plain_data_length | ||
) |
Decrypt the data using symmetric encryption scheme using ECB mode of operation.
Decrypt the data using symmetric encryption scheme using ECB mode of operation.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | symmetric_key_oid | OID of the symmetric key object to be used to decrypt the data.
|
[in] | encrypted_data | Pointer to the encrypted data to be decrypted. |
[in] | encrypted_data_length | Length of the encrypted data to be decrypted. |
[in,out] | plain_data | Pointer to buffer to store decrypted data. |
[in,out] | plain_data_length | Pointer to length of the plain_data. Initial value set as length of buffer, later updated as the actual length of plain data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt_ecb.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_decrypt_final | ( | optiga_crypt_t * | me, |
const uint8_t * | encrypted_data, | ||
uint32_t | encrypted_data_length, | ||
uint8_t * | plain_data, | ||
uint32_t * | plain_data_length | ||
) |
Decrypts input data using symmetric key from OPTIGA, exports block aligned plain data and completes the decryption sequence.
Decrypts input data using symmetric key from OPTIGA, exports block aligned plain data and completes the decryption sequence.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encrypted_data | Pointer to the data to be decrypted. |
[in] | encrypted_data_length | Length of the data to be decrypted.
|
[in,out] | plain_data | Pointer to buffer to store plain data. |
[in,out] | plain_data_length | Pointer to length of the plain_data. Initial value set as length of buffer, later updated as the actual length of plain data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_decrypt_start | ( | optiga_crypt_t * | me, |
optiga_symmetric_encryption_mode_t | encryption_mode, | ||
optiga_key_id_t | symmetric_key_oid, | ||
const uint8_t * | encrypted_data, | ||
uint32_t | encrypted_data_length, | ||
const uint8_t * | iv, | ||
uint16_t | iv_length, | ||
const uint8_t * | associated_data, | ||
uint16_t | associated_data_length, | ||
uint16_t | total_encrypted_data_length, | ||
uint8_t * | plain_data, | ||
uint32_t * | plain_data_length | ||
) |
Initiate symmetric decryption sequence for input data using symmetric key from OPTIGA.
Initiate symmetric decryption sequence for input data using symmetric key from OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encryption_mode | Symmetric encryption mode |
[in] | symmetric_key_oid | OPTIGA symmetric key OID
|
[in] | encrypted_data | Pointer to the data to be decrypted. |
[in] | encrypted_data_length | Length of the data to be decrypted.
|
[in] | iv | Pointer to an IV(initialization vector) or nonce.
|
[in] | iv_length | Length of the IV
|
[in] | associated_data | Pointer to associated data
|
[in] | associated_data_length | Length of associated data
|
[in] | total_encrypted_data_length | Length of total data to be decrypted until optiga_crypt_symmetric_decrypt_final.
|
[in,out] | plain_data | Pointer to buffer to store plain data. |
[in,out] | plain_data_length | Pointer to length of the plain_data. Initial value set as length of buffer, later updated as the actual length of plain data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_encrypt | ( | optiga_crypt_t * | me, |
optiga_symmetric_encryption_mode_t | encryption_mode, | ||
optiga_key_id_t | symmetric_key_oid, | ||
const uint8_t * | plain_data, | ||
uint32_t | plain_data_length, | ||
const uint8_t * | iv, | ||
uint16_t | iv_length, | ||
const uint8_t * | associated_data, | ||
uint16_t | associated_data_length, | ||
uint8_t * | encrypted_data, | ||
uint32_t * | encrypted_data_length | ||
) |
Encrypt the data using symmetric encryption mode and export encrypted message to host.
Encrypt the input message using symmetric key from OPTIGA and export the encrypted message to host.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encryption_mode | Symmetric encryption mode |
[in] | symmetric_key_oid | OPTIGA symmetric key OID
|
[in] | plain_data | Pointer to the data to be encrypted. |
[in] | plain_data_length | Length of the data to be encrypted.
|
[in] | iv | Pointer to an IV(initialization vector) or nonce.
|
[in] | iv_length | Length of the IV
|
[in] | associated_data | Pointer to associated data
|
[in] | associated_data_length | Length of associated data
|
[in,out] | encrypted_data | Pointer to buffer to store encrypted data |
[in,out] | encrypted_data_length | Pointer to length of the encrypted_data. Initial value set as length of buffer, later updated as the actual length of encrypted data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_encrypt_continue | ( | optiga_crypt_t * | me, |
const uint8_t * | plain_data, | ||
uint32_t | plain_data_length, | ||
uint8_t * | encrypted_data, | ||
uint32_t * | encrypted_data_length | ||
) |
Encrypts input data using symmetric key from OPTIGA and exports block aligned encrypted data.
Encrypts input data using symmetric key from OPTIGA and exports block aligned encrypted data.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | plain_data | Pointer to the data to be encrypted. |
[in] | plain_data_length | Length of the data to be encrypted.
|
[in,out] | encrypted_data | Pointer to buffer to store encrypted data. Can be NULL for MAC based operations. |
[in,out] | encrypted_data_length | Pointer to length of the encrypted_data. Initial value set as length of buffer, later updated as the actual length of encrypted data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_encrypt_ecb | ( | optiga_crypt_t * | me, |
optiga_key_id_t | symmetric_key_oid, | ||
const uint8_t * | plain_data, | ||
uint32_t | plain_data_length, | ||
uint8_t * | encrypted_data, | ||
uint32_t * | encrypted_data_length | ||
) |
Encrypt the data using symmetric encryption scheme using ECB mode of operation.
Encrypt the data using symmetric encryption scheme using ECB mode of operation.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | symmetric_key_oid | OID of the symmetric key object to be used to encrypt the data.
|
[in] | plain_data | Pointer to the data to be encrypted. |
[in] | plain_data_length | Length of the data to be encrypted. |
[in,out] | encrypted_data | Pointer to buffer to store encrypted data. |
[in,out] | encrypted_data_length | Pointer to length of the encrypted_data. Initial value set as length of buffer, later updated as the actual length of encrypted data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt_ecb.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_encrypt_final | ( | optiga_crypt_t * | me, |
const uint8_t * | plain_data, | ||
uint32_t | plain_data_length, | ||
uint8_t * | encrypted_data, | ||
uint32_t * | encrypted_data_length | ||
) |
Encrypts input data using symmetric key from OPTIGA, exports block aligned encrypted data and completes the encryption sequence.
Encrypts input data using symmetric key from OPTIGA, exports block aligned encrypted data and completes the encryption sequence.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | plain_data | Pointer to the data to be encrypted. |
[in] | plain_data_length | Length of the data to be encrypted.
|
[in,out] | encrypted_data | Pointer to buffer to store encrypted data. |
[in,out] | encrypted_data_length | Pointer to length of the encrypted_data. Initial value set as length of buffer, later updated as the actual length of encrypted data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_encrypt_start | ( | optiga_crypt_t * | me, |
optiga_symmetric_encryption_mode_t | encryption_mode, | ||
optiga_key_id_t | symmetric_key_oid, | ||
const uint8_t * | plain_data, | ||
uint32_t | plain_data_length, | ||
const uint8_t * | iv, | ||
uint16_t | iv_length, | ||
const uint8_t * | associated_data, | ||
uint16_t | associated_data_length, | ||
uint16_t | total_plain_data_length, | ||
uint8_t * | encrypted_data, | ||
uint32_t * | encrypted_data_length | ||
) |
Initiates a symmetric encryption sequence for input data using symmetric key from OPTIGA.
Initiates a symmetric encryption sequence for input data using symmetric key from OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | encryption_mode | Symmetric encryption mode |
[in] | symmetric_key_oid | OPTIGA symmetric key OID
|
[in] | plain_data | Pointer to the data to be encrypted. |
[in] | plain_data_length | Length of the data to be encrypted.
|
[in] | iv | Pointer to an IV(initialization vector) or nonce.
|
[in] | iv_length | Length of the IV
|
[in] | associated_data | Pointer to associated data
|
[in] | associated_data_length | Length of associated data
|
[in] | total_plain_data_length | Length of total data to be encrypted until optiga_crypt_symmetric_encrypt_final.
|
[in,out] | encrypted_data | Pointer to buffer to store encrypted data. Can be NULL for MAC based operations. |
[in,out] | encrypted_data_length | Pointer to length of the encrypted_data. Initial value set as length of buffer, later updated as the actual length of encrypted data.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided |
OPTIGA_CRYPT_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_crypt_symmetric_encrypt_decrypt.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_symmetric_generate_key | ( | optiga_crypt_t * | me, |
optiga_symmetric_key_type_t | key_type, | ||
uint8_t | key_usage, | ||
bool_t | export_symmetric_key, | ||
void * | symmetric_key | ||
) |
Generates a symmetric key using OPTIGA.
Generates a symmetric key using OPTIGA for different key sizes.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | key_type | Key type of optiga_symmetric_key_type_t. |
[in] | key_usage | Key usage defined in optiga_key_usage_t.
|
[in] | export_symmetric_key | TRUE (1) or Non-Zero value - Exports symmetric key to the host. FALSE (0) - Stores symmetric key in OPTIGA. |
[in,out] | symmetric_key | Pointer to buffer of symmetric key.
|
OPTIGA_CRYPT_SUCCESS | Successful invocation. |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided. |
OPTIGA_CRYPT_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_crypt_symmetric_generate_key.c
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_tls_prf | ( | optiga_crypt_t * | me, |
optiga_tls_prf_type_t | type, | ||
uint16_t | secret, | ||
const uint8_t * | label, | ||
uint16_t | label_length, | ||
const uint8_t * | seed, | ||
uint16_t | seed_length, | ||
uint16_t | derived_key_length, | ||
bool_t | export_to_host, | ||
uint8_t * | derived_key | ||
) |
Derives a key.
Derives a key using the secret stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | type | Type of scheme to be used for TLS PRF as optiga_tls_prf_type_t. |
[in] | secret | Object ID where the secret is stored in OPTIGA.
|
[in] | label | Pointer to the label, can be NULL if not applicable. |
[in] | label_length | Length of the label. |
[in] | seed | Valid pointer to the seed, must not be NULL. |
[in] | seed_length | Length of the seed. |
[in] | derived_key_length | Length of derived key.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the derived key to Host. FALSE (0) - Stores the derived key into the session object ID acquired by the instance. |
[in,out] | derived_key | Pointer to the valid buffer with a minimum size of derived_key_length, in case of exporting the key to host(export_to_host is non-zero value). Otherwise set to NULL. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | - Wrong Input arguments provided
|
OPTIGA_CRYPT_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_crypt_tls_prf_sha256.c
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_tls_prf_sha256 | ( | optiga_crypt_t * | me, |
uint16_t | secret, | ||
const uint8_t * | label, | ||
uint16_t | label_length, | ||
const uint8_t * | seed, | ||
uint16_t | seed_length, | ||
uint16_t | derived_key_length, | ||
bool_t | export_to_host, | ||
uint8_t * | derived_key | ||
) |
Derives a key using TLS PRF SHA256.
Derives a key TLS PRF SHA256 using the secret stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | secret | Object ID where the secret is stored in OPTIGA.
|
[in] | label | Pointer to the label, can be NULL if not applicable. |
[in] | label_length | Length of the label. |
[in] | seed | Valid pointer to the seed, must not be NULL. |
[in] | seed_length | Length of the seed. |
[in] | derived_key_length | Length of derived key.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the derived key to Host. FALSE (0) - Stores the derived key into the session object ID acquired by the instance. |
[in,out] | derived_key | Pointer to the valid buffer with a minimum size of derived_key_length, in case of exporting the key to host(export_to_host is non-zero value). Otherwise set to NULL. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided
|
OPTIGA_CRYPT_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_crypt_tls_prf_sha256.c
Definition at line 706 of file optiga_crypt.h.
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_tls_prf_sha384 | ( | optiga_crypt_t * | me, |
uint16_t | secret, | ||
const uint8_t * | label, | ||
uint16_t | label_length, | ||
const uint8_t * | seed, | ||
uint16_t | seed_length, | ||
uint16_t | derived_key_length, | ||
bool_t | export_to_host, | ||
uint8_t * | derived_key | ||
) |
Derives a key using TLS PRF SHA384.
Derives a key using the secret stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | secret | Object ID where the secret is stored in OPTIGA.
|
[in] | label | Pointer to the label, can be NULL if not applicable. |
[in] | label_length | Length of the label. |
[in] | seed | Valid pointer to the seed, must not be NULL. |
[in] | seed_length | Length of the seed. |
[in] | derived_key_length | Length of derived key.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the derived key to Host. FALSE (0) - Stores the derived key into the session object ID acquired by the instance. |
[in,out] | derived_key | Pointer to the valid buffer with a minimum size of derived_key_length, in case of exporting the key to host(export_to_host is non-zero value). Otherwise set to NULL. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided
|
OPTIGA_CRYPT_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
None
Definition at line 776 of file optiga_crypt.h.
_STATIC_INLINE LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_tls_prf_sha512 | ( | optiga_crypt_t * | me, |
uint16_t | secret, | ||
const uint8_t * | label, | ||
uint16_t | label_length, | ||
const uint8_t * | seed, | ||
uint16_t | seed_length, | ||
uint16_t | derived_key_length, | ||
bool_t | export_to_host, | ||
uint8_t * | derived_key | ||
) |
Derives a key using TLS PRF SHA512.
Derives a key using the secret stored in OPTIGA.
[in] | me | Valid instance of optiga_crypt_t created using optiga_crypt_create. |
[in] | secret | Object ID where the secret is stored in OPTIGA.
|
[in] | label | Pointer to the label, can be NULL if not applicable. |
[in] | label_length | Length of the label. |
[in] | seed | Valid pointer to the seed, must not be NULL. |
[in] | seed_length | Length of the seed. |
[in] | derived_key_length | Length of derived key.
|
[in] | export_to_host | TRUE (1) or Non-Zero value - Exports the derived key to Host. FALSE (0) - Stores the derived key into the session object ID acquired by the instance. |
[in,out] | derived_key | Pointer to the valid buffer with a minimum size of derived_key_length, in case of exporting the key to host(export_to_host is non-zero value). Otherwise set to NULL. |
OPTIGA_CRYPT_SUCCESS | Successful invocation |
OPTIGA_CRYPT_ERROR_INVALID_INPUT | Wrong Input arguments provided
|
OPTIGA_CRYPT_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
None
Definition at line 846 of file optiga_crypt.h.