OPTIGA Trust M  1.1.0
C++ library for Optiga Trust M Chip Security Controller
optiga_cmd.h
Go to the documentation of this file.
1 
38 #ifndef _OPTIGA_CMD_H_
39 #define _OPTIGA_CMD_H_
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #include "optiga_lib_common.h"
46 
48 typedef struct optiga_cmd optiga_cmd_t;
49 
52 
76 optiga_cmd_t * optiga_cmd_create(uint8_t optiga_instance_id,
77  callback_handler_t handler,
78  void * caller_context);
79 
100 
101 
121 
122 
152  uint8_t cmd_param,
153  void * params);
154 
183  uint8_t cmd_param,
184  void * params);
185 
217  uint8_t cmd_param,
219 
251  uint8_t cmd_param,
253 
254 #if defined (OPTIGA_CRYPT_RANDOM_ENABLED) || defined (OPTIGA_CRYPT_RSA_PRE_MASTER_SECRET_ENABLED)
255 
283  uint8_t cmd_param,
284  optiga_get_random_params_t * params);
285 #endif //OPTIGA_CRYPT_RANDOM_ENABLED || OPTIGA_CRYPT_RSA_PRE_MASTER_SECRET_ENABLED
286 
287 #ifdef OPTIGA_CRYPT_HASH_ENABLED
288 
317  uint8_t cmd_param,
318  optiga_calc_hash_params_t * params);
319 #endif //OPTIGA_CRYPT_HASH_ENABLED
320 
321 #if defined (OPTIGA_CRYPT_ECDSA_SIGN_ENABLED) || defined (OPTIGA_CRYPT_RSA_SIGN_ENABLED)
322 
352  uint8_t cmd_param,
353  optiga_calc_sign_params_t * params);
354 #endif //OPTIGA_CRYPT_ECDSA_SIGN_ENABLED || OPTIGA_CRYPT_RSA_SIGN_ENABLED
355 
356 #if defined (OPTIGA_CRYPT_ECDSA_VERIFY_ENABLED) || defined (OPTIGA_CRYPT_RSA_VERIFY_ENABLED)
357 
383  uint8_t cmd_param,
384  optiga_verify_sign_params_t * params);
385 #endif //OPTIGA_CRYPT_ECDSA_VERIFY_ENABLED || OPTIGA_CRYPT_RSA_VERIFY_ENABLED
386 
387 #ifdef OPTIGA_CRYPT_ECDH_ENABLED
388 
419  uint8_t cmd_param,
420  optiga_calc_ssec_params_t * params);
421 #endif //OPTIGA_CRYPT_ECDH_ENABLED
422 
423 #ifdef OPTIGA_CRYPT_TLS_PRF_SHA256_ENABLED
424 
454  uint8_t cmd_param,
455  optiga_derive_key_params_t * params);
456 #endif //OPTIGA_CRYPT_TLS_PRF_SHA256_ENABLED
457 
458 #if defined (OPTIGA_CRYPT_ECC_GENERATE_KEYPAIR_ENABLED) || defined (OPTIGA_CRYPT_RSA_GENERATE_KEYPAIR_ENABLED)
459 
488  uint8_t cmd_param,
489  optiga_gen_keypair_params_t * params);
490 #endif //(OPTIGA_CRYPT_ECC_GENERATE_KEYPAIR_ENABLED) || (OPTIGA_CRYPT_RSA_GENERATE_KEYPAIR_ENABLED)
491 
492 #ifdef OPTIGA_CRYPT_RSA_ENCRYPT_ENABLED
493 
523  uint8_t cmd_param,
525 #endif // OPTIGA_CRYPT_RSA_ENCRYPT_ENABLED
526 
527 #ifdef OPTIGA_CRYPT_RSA_DECRYPT_ENABLED
528 
557  uint8_t cmd_param,
559 #endif // OPTIGA_CRYPT_RSA_DECRYPT_ENABLED
560 
589  uint8_t cmd_param,
591 
592 #if defined (OPTIGA_LIB_ENABLE_LOGGING) && defined (OPTIGA_LIB_ENABLE_CMD_LOGGING)
593 
607 #define OPTIGA_CMD_LOG_MESSAGE(msg) \
608 {\
609  optiga_lib_print_message(msg,OPTIGA_COMMAND_LAYER,OPTIGA_COMMAND_LAYER_COLOR);\
610 }
611 
627 #define OPTIGA_CMD_LOG_HEX_DATA(array,array_len) \
628 {\
629  optiga_lib_print_array_hex_format(array,array_len,OPTIGA_UNPROTECTED_DATA_COLOR);\
630 }
631 
646 #define OPTIGA_CMD_LOG_STATUS(return_value) \
647 { \
648  if (OPTIGA_LIB_SUCCESS != return_value) \
649  { \
650  optiga_lib_print_status(OPTIGA_COMMAND_LAYER,OPTIGA_ERROR_COLOR,return_value); \
651  } \
652  else\
653  { \
654  optiga_lib_print_status(OPTIGA_COMMAND_LAYER,OPTIGA_COMMAND_LAYER_COLOR,return_value); \
655  } \
656 }
657 #else
658 
659 #define OPTIGA_CMD_LOG_MESSAGE(msg) {}
660 #define OPTIGA_CMD_LOG_HEX_DATA(array, array_len) {}
661 #define OPTIGA_CMD_LOG_STATUS(return_value) {}
662 
663 #endif
664 
665 #ifdef __cplusplus
666 }
667 #endif
668 
669 #endif /*_OPTIGA_CMD_H_ */
670 
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.
Definition: optiga_cmd.c:2775
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.
Definition: optiga_cmd.c:2241
OPTIGA Context which holds the communication buffer, comms instance and other required....
Definition: optiga_cmd.c:288
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.
Definition: optiga_cmd.c:1621
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.
Definition: optiga_cmd.c:1955
optiga_lib_status_t optiga_cmd_open_application(optiga_cmd_t *me, uint8_t cmd_param, void *params)
Opens the OPTIGA Application.
Definition: optiga_cmd.c:1397
optiga_lib_status_t optiga_cmd_close_application(optiga_cmd_t *me, uint8_t cmd_param, void *params)
Closes the OPTIGA Application.
Definition: optiga_cmd.c:1477
Specifies the structure for derivation of key using pseudo random function.
Definition: optiga_lib_common.h:413
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.
Definition: optiga_cmd.c:1831
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.
Definition: optiga_cmd.c:2914
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.
Definition: optiga_cmd.c:1726
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.
Definition: optiga_cmd.c:3208
Specifies the data structure for data to be written to OPTIGA.
Definition: optiga_lib_common.h:274
Specifies the data structure for data to be read from OPTIGA.
Definition: optiga_lib_common.h:251
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.
Definition: optiga_cmd.c:1148
Specifies the data structure for generate key pair.
Definition: optiga_lib_common.h:339
optiga_lib_status_t optiga_cmd_destroy(optiga_cmd_t *me)
Destroys the instance of optiga_cmd_t.
Definition: optiga_cmd.c:1191
Specifies the data structure for ecdh secret generation.
Definition: optiga_lib_common.h:398
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.
Definition: optiga_cmd.c:2424
Specifies the data structure for ECDSA signature verification.
Definition: optiga_lib_common.h:377
This file provides the prototypes for the commonly used functions and structures of OPTIGA Library.
Command context.
Definition: optiga_cmd.c:331
Specifies the structure for asymmetric encryption and decryption.
Definition: optiga_lib_common.h:434
Specifies the data structure for protected update.
Definition: optiga_lib_common.h:457
Specifies the data structure of calculate hash.
Definition: optiga_lib_common.h:297
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.
Definition: optiga_cmd.c:3108
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.
Definition: optiga_cmd.c:2600
Specifies the data structure for ECDSA signature.
Definition: optiga_lib_common.h:360
uint16_t optiga_lib_status_t
typedef for OPTIGA host library status
Definition: optiga_lib_types.h:97
optiga_lib_status_t optiga_cmd_release_lock(const optiga_cmd_t *me)
Releases the OPTIGA cmd lock.
Definition: optiga_cmd.c:780
void(* callback_handler_t)(void *callback_ctx, optiga_lib_status_t event)
typedef for event callback handler
Definition: optiga_lib_types.h:106
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.
Definition: optiga_cmd.c:2101
Specifies the data structure of random generation.
Definition: optiga_lib_common.h:323