OPTIGA™ Trust M
Host Library Documentation
optiga_crypt.h
Go to the documentation of this file.
1 
38 #ifndef _OPTIGA_CRYPT_H_
39 #define _OPTIGA_CRYPT_H_
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #include "optiga/cmd/optiga_cmd.h"
46 
48 typedef union optiga_crypt_params
49 {
58 #if defined (OPTIGA_CRYPT_RSA_ENCRYPT_ENABLED) || defined (OPTIGA_CRYPT_RSA_DECRYPT_ENABLED)
61 #endif
68 #if defined (OPTIGA_CRYPT_SYM_ENCRYPT_ENABLED) && defined (OPTIGA_CRYPT_SYM_DECRYPT_ENABLED)
71 #endif
72 #ifdef OPTIGA_CRYPT_SYM_GENERATE_KEY_ENABLED
75 #endif
77 
80 {
90  uint16_t instance_state;
91 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
92  uint8_t protection_level;
95  uint8_t protocol_version;
96 #endif //OPTIGA_COMMS_SHIELDED_CONNECTION
97 
98 };
99 
101 typedef struct optiga_crypt optiga_crypt_t;
102 
103 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
104 
130 void optiga_crypt_set_comms_params(optiga_crypt_t * me,
131  uint8_t parameter_type,
132  uint8_t value);
133 #endif
134 
162 LIBRARY_EXPORTS optiga_crypt_t * optiga_crypt_create(uint8_t optiga_instance_id,
164  void * caller_context);
165 
188 
189 #ifdef OPTIGA_CRYPT_RANDOM_ENABLED
190 
226  optiga_rng_type_t rng_type,
227  uint8_t * random_data,
228  uint16_t random_data_length);
229 #endif //OPTIGA_CRYPT_RANDOM_ENABLED
230 
231 #ifdef OPTIGA_CRYPT_HASH_ENABLED
232 
266  optiga_hash_type_t hash_algorithm,
267  uint8_t source_of_data_to_hash,
268  const void * data_to_hash,
269  uint8_t * hash_output);
270 
307  optiga_hash_context_t * hash_ctx);
308 
309 
348  optiga_hash_context_t * hash_ctx,
349  uint8_t source_of_data_to_hash,
350  const void * data_to_hash);
351 
389  optiga_hash_context_t * hash_ctx,
390  uint8_t * hash_output);
391 
392 #endif //OPTIGA_CRYPT_HASH_ENABLED
393 
394 
395 #ifdef OPTIGA_CRYPT_ECC_GENERATE_KEYPAIR_ENABLED
396 
440  optiga_ecc_curve_t curve_id,
441  uint8_t key_usage,
442  bool_t export_private_key,
443  void * private_key,
444  uint8_t * public_key,
445  uint16_t * public_key_length);
446 #endif //OPTIGA_CRYPT_ECC_GENERATE_KEYPAIR_ENABLED
447 
448 #ifdef OPTIGA_CRYPT_ECDSA_SIGN_ENABLED
449 
487  const uint8_t * digest,
488  uint8_t digest_length,
489  optiga_key_id_t private_key,
490  uint8_t * signature,
491  uint16_t * signature_length);
492 #endif //OPTIGA_CRYPT_ECDSA_SIGN_ENABLED
493 
494 #ifdef OPTIGA_CRYPT_ECDSA_VERIFY_ENABLED
495 
535  const uint8_t * digest,
536  uint8_t digest_length,
537  const uint8_t * signature,
538  uint16_t signature_length,
539  uint8_t public_key_source_type,
540  const void * public_key);
541 #endif //OPTIGA_CRYPT_ECDSA_VERIFY_ENABLED
542 
543 #ifdef OPTIGA_CRYPT_ECDH_ENABLED
544 
588  optiga_key_id_t private_key,
589  public_key_from_host_t * public_key,
590  bool_t export_to_host,
591  uint8_t * shared_secret);
592 #endif //OPTIGA_CRYPT_ECDH_ENABLED
593 
594 #if defined (OPTIGA_CRYPT_TLS_PRF_SHA256_ENABLED) || defined (OPTIGA_CRYPT_TLS_PRF_SHA384_ENABLED) || defined (OPTIGA_CRYPT_TLS_PRF_SHA512_ENABLED)
595 
647  uint16_t secret,
648  const uint8_t * label,
649  uint16_t label_length,
650  const uint8_t * seed,
651  uint16_t seed_length,
652  uint16_t derived_key_length,
653  bool_t export_to_host,
654  uint8_t * derived_key);
655 #endif // OPTIGA_CRYPT_TLS_PRF_SHA256_ENABLED || OPTIGA_CRYPT_TLS_PRF_SHA384_ENABLED || OPTIGA_CRYPT_TLS_PRF_SHA512_ENABLED
656 
657 #ifdef OPTIGA_CRYPT_TLS_PRF_SHA256_ENABLED
658 
707  uint16_t secret,
708  const uint8_t * label,
709  uint16_t label_length,
710  const uint8_t * seed,
711  uint16_t seed_length,
712  uint16_t derived_key_length,
713  bool_t export_to_host,
714  uint8_t * derived_key)
715 {
716  return (optiga_crypt_tls_prf(me,
718  secret,
719  label,
720  label_length,
721  seed,
722  seed_length,
723  derived_key_length,
724  export_to_host,
725  derived_key));
726 }
727 #endif // OPTIGA_CRYPT_TLS_PRF_SHA256_ENABLED
728 #ifdef OPTIGA_CRYPT_TLS_PRF_SHA384_ENABLED
729 
777  uint16_t secret,
778  const uint8_t * label,
779  uint16_t label_length,
780  const uint8_t * seed,
781  uint16_t seed_length,
782  uint16_t derived_key_length,
783  bool_t export_to_host,
784  uint8_t * derived_key)
785 {
786  return (optiga_crypt_tls_prf(me,
788  secret,
789  label,
790  label_length,
791  seed,
792  seed_length,
793  derived_key_length,
794  export_to_host,
795  derived_key));
796 }
797 #endif // OPTIGA_CRYPT_TLS_PRF_SHA384_ENABLED
798 #ifdef OPTIGA_CRYPT_TLS_PRF_SHA512_ENABLED
799 
847  uint16_t secret,
848  const uint8_t * label,
849  uint16_t label_length,
850  const uint8_t * seed,
851  uint16_t seed_length,
852  uint16_t derived_key_length,
853  bool_t export_to_host,
854  uint8_t * derived_key)
855 {
856  return (optiga_crypt_tls_prf(me,
858  secret,
859  label,
860  label_length,
861  seed,
862  seed_length,
863  derived_key_length,
864  export_to_host,
865  derived_key));
866 }
867 #endif //OPTIGA_CRYPT_TLS_PRF_SHA512_ENABLED
868 
869 
870 #ifdef OPTIGA_CRYPT_RSA_GENERATE_KEYPAIR_ENABLED
871 
918  uint8_t key_usage,
919  bool_t export_private_key,
920  void * private_key,
921  uint8_t * public_key,
922  uint16_t * public_key_length);
923 #endif //OPTIGA_CRYPT_RSA_GENERATE_KEYPAIR_ENABLED
924 
925 
926 #ifdef OPTIGA_CRYPT_RSA_SIGN_ENABLED
927 
965  optiga_rsa_signature_scheme_t signature_scheme,
966  const uint8_t * digest,
967  uint8_t digest_length,
968  optiga_key_id_t private_key,
969  uint8_t * signature,
970  uint16_t * signature_length,
971  uint16_t salt_length);
972 #endif //OPTIGA_CRYPT_RSA_SIGN_ENABLED
973 
974 #ifdef OPTIGA_CRYPT_RSA_VERIFY_ENABLED
975 
1017  optiga_rsa_signature_scheme_t signature_scheme,
1018  const uint8_t * digest,
1019  uint8_t digest_length,
1020  const uint8_t * signature,
1021  uint16_t signature_length,
1022  uint8_t public_key_source_type,
1023  const void * public_key,
1024  uint16_t salt_length);
1025 #endif //OPTIGA_CRYPT_RSA_VERIFY_ENABLED
1026 
1027 #ifdef OPTIGA_CRYPT_RSA_PRE_MASTER_SECRET_ENABLED
1028 
1072  const uint8_t * optional_data,
1073  uint16_t optional_data_length,
1074  uint16_t pre_master_secret_length);
1075 #endif //OPTIGA_CRYPT_RSA_PRE_MASTER_SECRET_ENABLED
1076 
1077 #ifdef OPTIGA_CRYPT_RSA_ENCRYPT_ENABLED
1078 
1125  optiga_rsa_encryption_scheme_t encryption_scheme,
1126  const uint8_t * message,
1127  uint16_t message_length,
1128  const uint8_t * label,
1129  uint16_t label_length,
1130  uint8_t public_key_source_type,
1131  const void * public_key,
1132  uint8_t * encrypted_message,
1133  uint16_t * encrypted_message_length);
1134 
1180  optiga_rsa_encryption_scheme_t encryption_scheme,
1181  const uint8_t * label,
1182  uint16_t label_length,
1183  uint8_t public_key_source_type,
1184  const void * public_key,
1185  uint8_t * encrypted_message,
1186  uint16_t * encrypted_message_length);
1187 
1188 #endif //OPTIGA_CRYPT_RSA_ENCRYPT_ENABLED
1189 
1190 #ifdef OPTIGA_CRYPT_RSA_DECRYPT_ENABLED
1191 
1233  optiga_rsa_encryption_scheme_t encryption_scheme,
1234  const uint8_t * encrypted_message,
1235  uint16_t encrypted_message_length,
1236  const uint8_t * label,
1237  uint16_t label_length,
1238  optiga_key_id_t private_key,
1239  uint8_t * message,
1240  uint16_t * message_length);
1241 
1280  optiga_rsa_encryption_scheme_t encryption_scheme,
1281  const uint8_t * encrypted_message,
1282  uint16_t encrypted_message_length,
1283  const uint8_t * label,
1284  uint16_t label_length,
1285  optiga_key_id_t private_key);
1286 
1287 #endif //OPTIGA_CRYPT_RSA_DECRYPT_ENABLED
1288 
1289 #ifdef OPTIGA_CRYPT_SYM_ENCRYPT_ENABLED
1290 
1344  encryption_mode,
1345  optiga_key_id_t symmetric_key_oid,
1346  const uint8_t * plain_data,
1347  uint32_t plain_data_length,
1348  const uint8_t * iv,
1349  uint16_t iv_length,
1350  const uint8_t * associated_data,
1351  uint16_t associated_data_length,
1352  uint8_t * encrypted_data,
1353  uint32_t * encrypted_data_length);
1354 
1397  optiga_key_id_t symmetric_key_oid,
1398  const uint8_t * plain_data,
1399  uint32_t plain_data_length,
1400  uint8_t * encrypted_data,
1401  uint32_t * encrypted_data_length);
1402 
1460  encryption_mode,
1461  optiga_key_id_t symmetric_key_oid,
1462  const uint8_t * plain_data,
1463  uint32_t plain_data_length,
1464  const uint8_t * iv,
1465  uint16_t iv_length,
1466  const uint8_t * associated_data,
1467  uint16_t associated_data_length,
1468  uint16_t total_plain_data_length,
1469  uint8_t * encrypted_data,
1470  uint32_t * encrypted_data_length);
1471 
1514  const uint8_t * plain_data,
1515  uint32_t plain_data_length,
1516  uint8_t * encrypted_data,
1517  uint32_t * encrypted_data_length);
1518 
1562  const uint8_t * plain_data,
1563  uint32_t plain_data_length,
1564  uint8_t * encrypted_data,
1565  uint32_t * encrypted_data_length);
1566 #endif //OPTIGA_CRYPT_SYM_ENCRYPT_ENABLED
1567 
1568 #ifdef OPTIGA_CRYPT_SYM_DECRYPT_ENABLED
1569 
1623  encryption_mode,
1624  optiga_key_id_t symmetric_key_oid,
1625  const uint8_t * encrypted_data,
1626  uint32_t encrypted_data_length,
1627  const uint8_t * iv,
1628  uint16_t iv_length,
1629  const uint8_t * associated_data,
1630  uint16_t associated_data_length,
1631  uint8_t * plain_data,
1632  uint32_t * plain_data_length);
1675  optiga_key_id_t symmetric_key_oid,
1676  const uint8_t * encrypted_data,
1677  uint32_t encrypted_data_length,
1678  uint8_t * plain_data,
1679  uint32_t * plain_data_length);
1680 
1739  encryption_mode,
1740  optiga_key_id_t symmetric_key_oid,
1741  const uint8_t * encrypted_data,
1742  uint32_t encrypted_data_length,
1743  const uint8_t * iv,
1744  uint16_t iv_length,
1745  const uint8_t * associated_data,
1746  uint16_t associated_data_length,
1747  uint16_t total_encrypted_data_length,
1748  uint8_t * plain_data,
1749  uint32_t * plain_data_length);
1750 
1793  const uint8_t * encrypted_data,
1794  uint32_t encrypted_data_length,
1795  uint8_t * plain_data,
1796  uint32_t * plain_data_length);
1797 
1841  const uint8_t * encrypted_data,
1842  uint32_t encrypted_data_length,
1843  uint8_t * plain_data,
1844  uint32_t * plain_data_length);
1845 #endif //OPTIGA_CRYPT_SYM_DECRYPT_ENABLED
1846 
1847 
1848 #ifdef OPTIGA_CRYPT_HMAC_ENABLED
1849 
1893  optiga_hmac_type_t type,
1894  uint16_t secret,
1895  const uint8_t * input_data,
1896  uint32_t input_data_length,
1897  uint8_t * mac,
1898  uint32_t * mac_length);
1899 
1942  optiga_hmac_type_t type,
1943  uint16_t secret,
1944  const uint8_t * input_data,
1945  uint32_t input_data_length);
1946 
1984  const uint8_t * input_data,
1985  uint32_t input_data_length);
1986 
2030  const uint8_t * input_data,
2031  uint32_t input_data_length,
2032  uint8_t * mac,
2033  uint32_t * mac_length);
2034 #endif //OPTIGA_CRYPT_HMAC_ENABLED
2035 
2036 #ifdef OPTIGA_CRYPT_HKDF_ENABLED
2037 
2087  optiga_hkdf_type_t type,
2088  uint16_t secret,
2089  const uint8_t * salt,
2090  uint16_t salt_length,
2091  const uint8_t * info,
2092  uint16_t info_length,
2093  uint16_t derived_key_length,
2094  bool_t export_to_host,
2095  uint8_t * derived_key);
2096 
2146  uint16_t secret,
2147  const uint8_t * salt,
2148  uint16_t salt_length,
2149  const uint8_t * info,
2150  uint16_t info_length,
2151  uint16_t derived_key_length,
2152  bool_t export_to_host,
2153  uint8_t * derived_key)
2154 {
2155  return (optiga_crypt_hkdf(me,
2157  secret,
2158  salt,
2159  salt_length,
2160  info,
2161  info_length,
2162  derived_key_length,
2163  export_to_host,
2164  derived_key));
2165 }
2166 
2217  uint16_t secret,
2218  const uint8_t * salt,
2219  uint16_t salt_length,
2220  const uint8_t * info,
2221  uint16_t info_length,
2222  uint16_t derived_key_length,
2223  bool_t export_to_host,
2224  uint8_t * derived_key)
2225 {
2226  return (optiga_crypt_hkdf(me,
2228  secret,
2229  salt,
2230  salt_length,
2231  info,
2232  info_length,
2233  derived_key_length,
2234  export_to_host,
2235  derived_key));
2236 }
2237 
2288  uint16_t secret,
2289  const uint8_t * salt,
2290  uint16_t salt_length,
2291  const uint8_t * info,
2292  uint16_t info_length,
2293  uint16_t derived_key_length,
2294  bool_t export_to_host,
2295  uint8_t * derived_key)
2296 {
2297  return (optiga_crypt_hkdf(me,
2299  secret,
2300  salt,
2301  salt_length,
2302  info,
2303  info_length,
2304  derived_key_length,
2305  export_to_host,
2306  derived_key));
2307 }
2308 #endif //OPTIGA_CRYPT_HKDF_ENABLED
2309 
2310 #ifdef OPTIGA_CRYPT_SYM_GENERATE_KEY_ENABLED
2311 
2352  uint8_t key_usage,
2353  bool_t export_symmetric_key,
2354  void * symmetric_key);
2355 #endif //OPTIGA_CRYPT_SYM_GENERATE_KEY_ENABLED
2356 
2357 #ifdef OPTIGA_CRYPT_GENERATE_AUTH_CODE_ENABLED
2358 
2401  optiga_rng_type_t rng_type,
2402  const uint8_t * optional_data,
2403  uint16_t optional_data_length,
2404  uint8_t * random_data,
2405  uint16_t random_data_length);
2406 #endif //OPTIGA_CRYPT_GENERATE_AUTH_CODE_ENABLED
2407 
2408 #ifdef OPTIGA_CRYPT_HMAC_VERIFY_ENABLED
2409 
2454  optiga_hmac_type_t type,
2455  uint16_t secret,
2456  const uint8_t * input_data,
2457  uint32_t input_data_length,
2458  const uint8_t * hmac,
2459  uint32_t hmac_length);
2460 #endif // OPTIGA_CRYPT_HMAC_VERIFY_ENABLED
2461 #ifdef OPTIGA_CRYPT_CLEAR_AUTO_STATE_ENABLED
2462 
2490  uint16_t secret);
2491 
2492 #endif //OPTIGA_CRYPT_CLEAR_AUTO_STATE_ENABLED
2493 
2519 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
2520 #define OPTIGA_CRYPT_SET_COMMS_PROTECTION_LEVEL(p_instance, protection_level) \
2521 { \
2522  optiga_crypt_set_comms_params(p_instance, \
2523  OPTIGA_COMMS_PROTECTION_LEVEL, \
2524  protection_level);\
2525 }
2526 #else
2527 #define OPTIGA_CRYPT_SET_COMMS_PROTECTION_LEVEL(p_instance, protection_level) {}
2528 #endif
2529 
2547 #ifdef OPTIGA_COMMS_SHIELDED_CONNECTION
2548 #define OPTIGA_CRYPT_SET_COMMS_PROTOCOL_VERSION(p_instance, version) \
2549 { \
2550  optiga_crypt_set_comms_params(p_instance, \
2551  OPTIGA_COMMS_PROTOCOL_VERSION, \
2552  version);\
2553 }
2554 #else
2555 #define OPTIGA_CRYPT_SET_COMMS_PROTOCOL_VERSION(p_instance, version) {}
2556 #endif
2557 
2558 #ifdef __cplusplus
2559 }
2560 #endif
2561 
2562 #endif /*_OPTIGA_CRYPT_H_*/
2563 
optiga_calc_ssec
Specifies the data structure for ecdh secret generation.
Definition: optiga_lib_common.h:505
optiga_symmetric_enc_dec_params
Specifies the data structure for symmetric encrypt and decrypt.
Definition: optiga_lib_common.h:584
optiga_crypt_hkdf
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.
optiga_crypt_create
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.
optiga_crypt_tls_prf_sha256
_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.
Definition: optiga_crypt.h:706
optiga_crypt_symmetric_generate_key
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.
optiga_crypt_generate_auth_code
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.
optiga_crypt_params_t
union optiga_crypt_params optiga_crypt_params_t
union for OPTIGA crypt parameters
optiga_rsa_key_type_t
enum optiga_rsa_key_type optiga_rsa_key_type_t
Specifies the RSA key type in OPTIGA.
optiga_cmd_t
struct optiga_cmd optiga_cmd_t
OPTIGA command instance structure type.
Definition: optiga_cmd.h:48
optiga_crypt_params::optiga_symmetric_enc_dec_params
optiga_encrypt_sym_params_t optiga_symmetric_enc_dec_params
derive key params
Definition: optiga_crypt.h:70
optiga_rsa_signature_scheme_t
enum optiga_rsa_signature_scheme optiga_rsa_signature_scheme_t
Specifies the RSA signature schemes type in OPTIGA.
optiga_crypt_rsa_encrypt_message
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.
OPTIGA_HKDF_SHA_384
@ OPTIGA_HKDF_SHA_384
Key derivation using HKDF-SHA384.
Definition: optiga_lib_common.h:265
optiga_hkdf_type_t
enum optiga_hkdf_type optiga_hkdf_type_t
Specifies the HKDF key derivation types in OPTIGA.
optiga_crypt_hmac_finalize
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 ...
optiga_crypt_random
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.
optiga_crypt_rsa_decrypt_and_store
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.
optiga_symmetric_encryption_mode_t
enum optiga_symmetric_encryption_mode optiga_symmetric_encryption_mode_t
Specifies the symmetric encryption schemes type in OPTIGA.
optiga_crypt_ecdh
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.
optiga_crypt_hmac_start
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.
optiga_crypt_hmac_update
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 H...
optiga_crypt_rsa_generate_pre_master_secret
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.
optiga_crypt_tls_prf
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.
optiga_crypt_params::optiga_gen_keypair_params
optiga_gen_keypair_params_t optiga_gen_keypair_params
get key pair params
Definition: optiga_crypt.h:53
optiga_hash_context
Specifies the structure to the Hash context details managed by OPTIGA.
Definition: optiga_lib_common.h:306
_STATIC_INLINE
#define _STATIC_INLINE
Definition: optiga_lib_types.h:120
optiga_crypt_symmetric_encrypt_ecb
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.
optiga_get_random
Specifies the data structure of random generation.
Definition: optiga_lib_common.h:428
optiga_crypt_hmac
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 ...
key_type
key_type
Definition: protected_update_data_set.h:60
optiga_crypt_symmetric_decrypt_start
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.
optiga_ecc_curve_t
enum optiga_ecc_curve optiga_ecc_curve_t
Specifies the key curve type in OPTIGA.
optiga_hash_type_t
enum optiga_hash_type optiga_hash_type_t
Specifies the hashing algorithm type in OPTIGA.
optiga_crypt::params
optiga_crypt_params_t params
Details/references (pointers) to the Application Inputs.
Definition: optiga_crypt.h:82
optiga_crypt::caller_context
void * caller_context
Caller context.
Definition: optiga_crypt.h:86
optiga_gen_symkey_params
Specifies the data structure for symmetric generate key.
Definition: optiga_lib_common.h:628
public_key_from_host
Specifies the data structure of the Public Key details (key, size and type)
Definition: optiga_lib_common.h:343
OPTIGA_TLS12_PRF_SHA_256
@ OPTIGA_TLS12_PRF_SHA_256
Key derivation using TLSv1.2 PRF SHA256.
Definition: optiga_lib_common.h:277
optiga_tls_prf_type_t
enum optiga_tls_prf_type optiga_tls_prf_type_t
Specifies the key derivation types.
optiga_crypt_rsa_decrypt_and_export
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.
optiga_crypt_params::optiga_calc_sign_params
optiga_calc_sign_params_t optiga_calc_sign_params
calc sign params
Definition: optiga_crypt.h:55
optiga_crypt_params::optiga_encrypt_asym_params
optiga_encrypt_asym_params_t optiga_encrypt_asym_params
asymmetric encryption params
Definition: optiga_crypt.h:60
optiga_rsa_encryption_scheme_t
enum optiga_rsa_encryption_scheme optiga_rsa_encryption_scheme_t
Specifies the RSA encryption schemes.
optiga_rng_type_t
enum optiga_rng_type optiga_rng_type_t
Specifies the random generation types.
optiga_crypt
OPTIGA crypt instance structure.
Definition: optiga_crypt.h:80
optiga_calc_hash
Specifies the data structure of calculate hash.
Definition: optiga_lib_common.h:402
optiga_crypt_params::optiga_verify_sign_params
optiga_verify_sign_params_t optiga_verify_sign_params
verify sign params
Definition: optiga_crypt.h:57
optiga_crypt_rsa_generate_keypair
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.
OPTIGA_HKDF_SHA_256
@ OPTIGA_HKDF_SHA_256
Key derivation using HKDF-SHA256.
Definition: optiga_lib_common.h:263
optiga_crypt_symmetric_decrypt
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.
OPTIGA_TLS12_PRF_SHA_512
@ OPTIGA_TLS12_PRF_SHA_512
Key derivation using TLSv1.2 PRF SHA512.
Definition: optiga_lib_common.h:284
optiga_crypt_params::optiga_calc_ssec_params
optiga_calc_ssec_params_t optiga_calc_ssec_params
calc ssec params
Definition: optiga_crypt.h:65
optiga_crypt_hkdf_sha256
_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.
Definition: optiga_crypt.h:2145
optiga_crypt_destroy
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_destroy(optiga_crypt_t *me)
Destroys an instance of optiga_crypt_t.
optiga_crypt::my_cmd
optiga_cmd_t * my_cmd
Command module instance.
Definition: optiga_crypt.h:84
optiga_hmac_type_t
enum optiga_hmac_type optiga_hmac_type_t
Specifies the HMAC generation types in OPTIGA.
optiga_symmetric_key_type_t
enum optiga_symmetric_key_type optiga_symmetric_key_type_t
Specifies the symmetric key types supported by OPTIGA.
optiga_crypt_symmetric_decrypt_final
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 t...
optiga_verify_sign
Specifies the data structure for ECDSA signature verification.
Definition: optiga_lib_common.h:484
optiga_key_id_t
enum optiga_key_id optiga_key_id_t
Specifies the key location in OPTIGA.
optiga_crypt_symmetric_decrypt_ecb
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.
key_usage
key_usage
Definition: protected_update_data_set.h:83
optiga_crypt_hkdf_sha384
_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.
Definition: optiga_crypt.h:2216
optiga_crypt_symmetric_encrypt_start
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.
optiga_crypt_symmetric_encrypt_final
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 complet...
optiga_enc_dec_asym
Specifies the structure for asymmetric encryption and decryption.
Definition: optiga_lib_common.h:546
optiga_crypt_hash_finalize
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.
bool_t
uint8_t bool_t
Typedef for a boolean.
Definition: optiga_lib_types.h:84
optiga_crypt_hash
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.
optiga_crypt_ecdsa_verify
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.
optiga_crypt_ecc_generate_keypair
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.
optiga_crypt::handler
callback_handler_t handler
Callback handler.
Definition: optiga_crypt.h:88
optiga_crypt_tls_prf_sha512
_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.
Definition: optiga_crypt.h:846
optiga_calc_sign
Specifies the data structure for ECDSA signature.
Definition: optiga_lib_common.h:467
optiga_crypt::instance_state
uint16_t instance_state
To provide the busy/free status of the crypt instance.
Definition: optiga_crypt.h:90
optiga_cmd.h
This file defines APIs, types and data structures used in the Command (cmd) module implementation.
optiga_crypt_symmetric_encrypt_continue
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.
optiga_crypt_hash_start
LIBRARY_EXPORTS optiga_lib_status_t optiga_crypt_hash_start(optiga_crypt_t *me, optiga_hash_context_t *hash_ctx)
Initializes a hash context.
OPTIGA_TLS12_PRF_SHA_384
@ OPTIGA_TLS12_PRF_SHA_384
Key derivation using TLSv1.2 PRF SHA384.
Definition: optiga_lib_common.h:280
optiga_crypt_params::optiga_derive_key_params
optiga_derive_key_params_t optiga_derive_key_params
derive key params
Definition: optiga_crypt.h:67
optiga_gen_keypair
Specifies the data structure for generate key pair.
Definition: optiga_lib_common.h:446
optiga_crypt_rsa_verify
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.
optiga_crypt_rsa_sign
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.
callback_handler_t
void(* callback_handler_t)(void *callback_ctx, optiga_lib_status_t event)
typedef for event callback handler
Definition: optiga_lib_types.h:99
optiga_crypt_hash_update
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.
optiga_crypt_hmac_verify
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.
optiga_crypt_tls_prf_sha384
_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.
Definition: optiga_crypt.h:776
optiga_crypt_params
union for OPTIGA crypt parameters
Definition: optiga_crypt.h:49
optiga_crypt_ecdsa_sign
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.
optiga_crypt_symmetric_encrypt
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.
optiga_crypt_clear_auto_state
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.
optiga_crypt_params::optiga_gen_sym_key_params
optiga_gen_symkey_params_t optiga_gen_sym_key_params
generate symmetric key params
Definition: optiga_crypt.h:74
optiga_crypt_params::optiga_calc_hash_params
optiga_calc_hash_params_t optiga_calc_hash_params
calc hash params
Definition: optiga_crypt.h:63
optiga_crypt_rsa_encrypt_session
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.
optiga_crypt_hkdf_sha512
_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.
Definition: optiga_crypt.h:2287
optiga_lib_status_t
uint16_t optiga_lib_status_t
typedef for OPTIGA host library status
Definition: optiga_lib_types.h:90
OPTIGA_HKDF_SHA_512
@ OPTIGA_HKDF_SHA_512
Key derivation using HKDF-SHA512.
Definition: optiga_lib_common.h:267
optiga_crypt_symmetric_decrypt_continue
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.
optiga_derive_key
Specifies the structure for derivation of key using pseudo random function.
Definition: optiga_lib_common.h:520
optiga_crypt_params::optiga_get_random_params
optiga_get_random_params_t optiga_get_random_params
get random params
Definition: optiga_crypt.h:51