From 79013219556263bd4a3a43678a5e1d0faddba5ba Mon Sep 17 00:00:00 2001 From: Bryan Hunt Date: Tue, 14 Mar 2023 20:55:53 -0600 Subject: [PATCH] Release v3.5.0 (20230314) --- CMakeLists.txt | 6 +- app/wpc/atca_config.h | 1 + app/wpc/wpc_apis.c | 4 +- cryptoauthlib-manual.pdf | Bin 132 -> 132 bytes harmony/config/cryptoauthlib.py | 7 + harmony/config/device_instance.py | 6 +- harmony/module.py | 2 +- harmony/templates/atca_config.h.ftl | 7 + lib/CMakeLists.txt | 3 +- lib/atca_basic.c | 241 +++++---- lib/atca_basic.h | 4 + lib/atca_cfgs.c | 71 ++- lib/atca_cfgs.h | 11 - lib/atca_config.h.in | 7 + lib/atca_config_check.h | 9 +- lib/atca_devtypes.h | 29 +- lib/atca_iface.c | 3 + lib/atca_version.h | 6 +- lib/calib/calib_basic.c | 19 +- lib/calib/calib_basic.h | 198 +++++--- lib/calib/calib_command.c | 40 +- lib/calib/calib_command.h | 24 +- lib/calib/calib_config_check.h | 71 +-- lib/calib/calib_counter.c | 6 +- lib/calib/calib_delete.c | 132 +++++ lib/calib/calib_execution.c | 15 +- lib/calib/calib_helpers.c | 102 ++-- lib/calib/calib_info.c | 26 +- lib/calib/calib_lock.c | 85 ++-- lib/calib/calib_nonce.c | 4 +- lib/calib/calib_read.c | 351 +++++++------ lib/calib/calib_sha.c | 6 +- lib/calib/calib_sign.c | 40 +- lib/calib/calib_write.c | 273 +++++----- lib/cmake/pkcs11.cmake | 1 + lib/crypto/atca_crypto_hw_aes_cbc.c | 22 +- lib/cryptoauthlib.h | 8 +- lib/hal/hal_swi_gpio.c | 28 +- lib/hal/kit_protocol.c | 10 + lib/host/atca_host.c | 52 ++ lib/host/atca_host.h | 16 + lib/host/atca_host_config_check.h | 13 + lib/pkcs11/pkcs11_config.h.in | 5 + lib/pkcs11/pkcs11_digest.c | 11 +- lib/pkcs11/pkcs11_encrypt.c | 14 +- lib/pkcs11/pkcs11_init.c | 7 +- lib/pkcs11/pkcs11_key.c | 633 ++++++++++++++---------- lib/pkcs11/pkcs11_session.c | 8 +- module.xml | 2 +- python/cryptoauthlib/iface.py | 12 +- python/cryptoauthlib/library.py | 31 +- python/setup.py | 2 +- python/tox.ini | 3 +- release_notes.md | 48 ++ test/CMakeLists.txt | 5 + test/README.md | 2 + test/api_atcab/atca_tests_aes.c | 18 +- test/api_atcab/atca_tests_aes_cbc.c | 32 +- test/api_atcab/atca_tests_aes_cbcmac.c | 4 +- test/api_atcab/atca_tests_aes_ccm.c | 10 +- test/api_atcab/atca_tests_aes_cmac.c | 6 +- test/api_atcab/atca_tests_aes_ctr.c | 14 +- test/api_atcab/atca_tests_aes_gcm.c | 12 +- test/api_atcab/atca_tests_counter.c | 53 +- test/api_atcab/atca_tests_derivekey.c | 12 +- test/api_atcab/atca_tests_ecdh.c | 14 +- test/api_atcab/atca_tests_gendig.c | 25 +- test/api_atcab/atca_tests_genkey.c | 7 +- test/api_atcab/atca_tests_helper.c | 79 ++- test/api_atcab/atca_tests_hmac.c | 11 +- test/api_atcab/atca_tests_info.c | 43 +- test/api_atcab/atca_tests_kdf.c | 15 +- test/api_atcab/atca_tests_lock.c | 10 +- test/api_atcab/atca_tests_mac.c | 20 +- test/api_atcab/atca_tests_nonce.c | 10 +- test/api_atcab/atca_tests_otpzero.c | 15 +- test/api_atcab/atca_tests_privwrite.c | 17 +- test/api_atcab/atca_tests_random.c | 12 +- test/api_atcab/atca_tests_read.c | 41 +- test/api_atcab/atca_tests_secureboot.c | 9 +- test/api_atcab/atca_tests_selftest.c | 35 +- test/api_atcab/atca_tests_sha.c | 47 +- test/api_atcab/atca_tests_sign.c | 25 +- test/api_atcab/atca_tests_startup.c | 11 +- test/api_atcab/atca_tests_updateextra.c | 4 +- test/api_atcab/atca_tests_verify.c | 45 +- test/api_atcab/atca_tests_write.c | 104 +++- test/api_calib/test_calib.c | 84 ++++ test/api_calib/test_calib.h | 11 +- test/api_calib/test_calib_config.c | 5 +- test/api_calib/test_calib_delete.c | 73 +++ test/api_calib/test_calib_info.c | 98 ++++ test/api_crypto/test_crypto_aes.c | 6 +- test/api_crypto/test_crypto_pad.c | 8 +- test/api_crypto/test_crypto_pbkdf2.c | 15 +- test/api_crypto/test_crypto_pk.c | 10 +- test/api_crypto/test_crypto_sha.c | 30 +- test/atca_test.c | 12 +- test/atca_test.h | 27 +- test/atca_test_config.c | 81 ++- test/atca_test_console.c | 2 +- test/cmd-processor.c | 6 + test/integration/test_mbedtls.c | 8 +- test/jwt/atca_jwt_test.c | 35 +- test/tng/tng_atca_test.c | 4 +- test/tng/tng_atcacert_client_test.c | 25 +- test/vectors/ecdh_nist_vectors.c | 192 +++---- test/vectors/ecdsa_nist_vectors.c | 120 ++--- 108 files changed, 2951 insertions(+), 1403 deletions(-) create mode 100644 lib/calib/calib_delete.c create mode 100644 test/api_calib/test_calib.c create mode 100644 test/api_calib/test_calib_delete.c create mode 100644 test/api_calib/test_calib_info.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ac1a6015..a67af6214 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.1.0) project (cryptoauthlib C) # Set the current release version -set(VERSION "3.4.1") +set(VERSION "3.5.0") set(VERSION_MAJOR 3) -set(VERSION_MINOR 4) -set(VERSION_PATCH 1) +set(VERSION_MINOR 5) +set(VERSION_PATCH 0) # Build Options option(BUILD_TESTS "Create Test Application with library" OFF) diff --git a/app/wpc/atca_config.h b/app/wpc/atca_config.h index d2d4ae6f4..a22b72fd3 100644 --- a/app/wpc/atca_config.h +++ b/app/wpc/atca_config.h @@ -96,6 +96,7 @@ extern atca_plib_i2c_api_t sercom2_plib_i2c_api; #define ATCAB_AES_EN FEATURE_DISABLED #define ATCAB_AES_GCM_EN FEATURE_DISABLED #define ATCAB_COUNTER_EN FEATURE_DISABLED +#define ATCAB_DELETE_EN FEATURE_DISABLED #define ATCAB_DERIVEKEY_EN FEATURE_DISABLED #define ATCAB_ECDH_EN FEATURE_DISABLED #define ATCAB_ECDH_ENC_EN FEATURE_DISABLED diff --git a/app/wpc/wpc_apis.c b/app/wpc/wpc_apis.c index c45cbab47..f51de3bcd 100644 --- a/app/wpc/wpc_apis.c +++ b/app/wpc/wpc_apis.c @@ -220,7 +220,7 @@ ATCA_STATUS wpc_msg_digests( if (ATCA_SUCCESS == wpccert_get_slot_info(&handle, NULL, slot)) { if (ATCA_SUCCESS != (status = atcab_read_bytes_zone_ext(device, ATCA_ZONE_DATA, handle, 0, - digest, ATCA_SHA256_DIGEST_SIZE+1))) + digest, ATCA_SHA256_DIGEST_SIZE))) { ATCA_TRACE(status, "atcab_read_bytes_zone execution failed"); return wpc_msg_error(response, resp_len, WPC_ERROR_UNSPECIFIED, 0); @@ -419,7 +419,7 @@ ATCA_STATUS wpc_auth_signature( { ATCA_STATUS status; - uint8_t TBSAuth_data[53]; + uint8_t TBSAuth_data[54]; uint8_t tbs_digest[ATCA_SHA_DIGEST_SIZE]; uint8_t *data = TBSAuth_data; diff --git a/cryptoauthlib-manual.pdf b/cryptoauthlib-manual.pdf index 765a596d322b70577d8a9acdfd3abd95663bd544..204193c562c65c5ebe32125a66283b03bb0ccc3d 100644 GIT binary patch delta 85 zcmV~$u@S%^2mrvdb&8Ath=5CE2Ml`1LGGgh4|n37pVV3g;6^JG8+gz^Lbe-_68 diff --git a/harmony/config/cryptoauthlib.py b/harmony/config/cryptoauthlib.py index 3b29ef623..08b2be5bb 100644 --- a/harmony/config/cryptoauthlib.py +++ b/harmony/config/cryptoauthlib.py @@ -520,6 +520,13 @@ def instantiateComponent(calComponent): calCounterEnabledSymbol.setVisible(True) calCounterEnabledSymbol.setDefaultValue(True) + # DELETE + calDeleteEnabledSymbol = calComponent.createBooleanSymbol("cal_delete", deviceCommands) + calDeleteEnabledSymbol.setLabel("Support Delete?") + calDeleteEnabledSymbol.setDescription("Enable support for Delete Command") + calDeleteEnabledSymbol.setVisible(True) + calDeleteEnabledSymbol.setDefaultValue(False) + # DERIVEKEY calDerivekeyEnabledSymbol = calComponent.createBooleanSymbol("cal_derivekey", deviceCommands) calDerivekeyEnabledSymbol.setLabel("Support Derivekey?") diff --git a/harmony/config/device_instance.py b/harmony/config/device_instance.py index 229685c9b..3d178e479 100644 --- a/harmony/config/device_instance.py +++ b/harmony/config/device_instance.py @@ -23,8 +23,8 @@ *****************************************************************************""" _DEFAULT_I2C_ADDRESS = {'ecc': 0xC0, 'sha': 0xC8, 'ecc204': 0x66, 'ta100': 0x2e} -_SWI_DEVICES = ['ATSHA204A', 'ATSHA206A', 'ATECC108A', 'ATECC508A', 'ATECC608', 'ECC204'] -_I2C_DEVICES = ['ATSHA204A', 'ATECC108A', 'ATECC508A', 'ATECC608', 'TA100', 'ECC204'] +_SWI_DEVICES = ['ATSHA204A', 'ATSHA206A', 'ATECC108A', 'ATECC508A', 'ATECC608', 'ECC204', 'TA010'] +_I2C_DEVICES = ['ATSHA204A', 'ATECC108A', 'ATECC508A', 'ATECC608', 'TA100', 'ECC204', 'TA010'] _SPI_DEVICES = ['TA100'] caldevcfglist = [] @@ -183,7 +183,7 @@ def instantiateComponent(deviceComponent, index): deviceAddress = deviceComponent.createHexSymbol("I2C_ADDR", interfaceType) deviceAddress.setLabel("I2C Address") - if 'ECC204' in deviceID: + if (('ECC204' in deviceID) or ('TA010' in deviceID)): deviceAddress.setDefaultValue(_DEFAULT_I2C_ADDRESS['ecc204']) elif 'ECC' in deviceID: deviceAddress.setDefaultValue(_DEFAULT_I2C_ADDRESS['ecc']) diff --git a/harmony/module.py b/harmony/module.py index 8ee02ca84..b36a878db 100644 --- a/harmony/module.py +++ b/harmony/module.py @@ -23,7 +23,7 @@ import os -_CALIB_SUPPORTED_DEVICES = ['ATECC108A', 'ATECC508A', 'ATECC608', 'ATSHA204A', 'ATSHA206A', 'ECC204'] +_CALIB_SUPPORTED_DEVICES = ['ATECC108A', 'ATECC508A', 'ATECC608', 'ATSHA204A', 'ATSHA206A', 'ECC204', 'TA010'] _TALIB_SUPPORTED_DEVICES = ['TA100'] def loadModule(): diff --git a/harmony/templates/atca_config.h.ftl b/harmony/templates/atca_config.h.ftl index 7313e3a99..e207461a9 100644 --- a/harmony/templates/atca_config.h.ftl +++ b/harmony/templates/atca_config.h.ftl @@ -196,6 +196,13 @@ <#lt>#define ATCAB_COUNTER_EN (FEATURE_ENABLED) +/* Delete Command */ +<#if cal_delete == false> + <#lt>#define ATCAB_DELETE_EN (FEATURE_DISABLED) +<#else> + <#lt>#define ATCAB_DELETE_EN (FEATURE_ENABLED) + + /* Derivekey Command */ <#if cal_derivekey == false> <#lt>#define ATCAB_DERIVEKEY_EN (FEATURE_DISABLED) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 9e28f8a06..c36790f20 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -44,6 +44,7 @@ option(ATCA_ATECC508A_SUPPORT "Include support for ATECC508A device" ON) option(ATCA_ATECC608_SUPPORT "Include support for ATECC608 device" ON) option(ATCA_TA100_SUPPORT "Include support for TA100 device" OFF) option(ATCA_ECC204_SUPPORT "Include support for ECC204 device" ON) +option(ATCA_TA010_SUPPORT "Include support for TA010 device" ON) # RTOS Selection if (TARGET zephyr_interface) @@ -210,7 +211,7 @@ endif(ATCA_OPENSSL) if (ATCA_ATSHA204A_SUPPORT OR ATCA_ATSHA206A_SUPPORT OR ATCA_ATECC108A_SUPPORT OR ATCA_ATECC508A_SUPPORT OR - ATCA_ATECC608_SUPPORT OR ATCA_ECC204_SUPPORT) + ATCA_ATECC608_SUPPORT OR ATCA_ECC204_SUPPORT OR ATCA_TA010_SUPPORT) set(LIB_SRC ${LIB_SRC} ${CALIB_SRC} ${HOST_SRC}) endif() diff --git a/lib/atca_basic.c b/lib/atca_basic.c index 586d453e6..24c81a9a4 100644 --- a/lib/atca_basic.c +++ b/lib/atca_basic.c @@ -96,7 +96,7 @@ ATCA_STATUS atcab_init_ext(ATCADevice* device, ATCAIfaceCfg *cfg) } #endif -#if defined(ATCA_ATECC608_SUPPORT) || defined(ATCA_ECC204_SUPPORT) +#if defined(ATCA_ATECC608_SUPPORT) || ATCA_CA2_SUPPORT if (ATCA_SUCCESS == status) { #ifdef ATCA_ATECC608_SUPPORT @@ -110,10 +110,10 @@ ATCA_STATUS atcab_init_ext(ATCADevice* device, ATCAIfaceCfg *cfg) } #endif - #ifdef ATCA_ECC204_SUPPORT + #if ATCA_CA2_SUPPORT /* To compatible with kitprotocol firmware on otherside */ /* On kitprotocol firmware, during discovery time itself ECC204 would have woke up */ - if ((ECC204 == cfg->devtype) && (ATCA_HID_IFACE == cfg->iface_type || ATCA_UART_IFACE == cfg->iface_type)) + if (atcab_is_ca2_device(cfg->devtype) && (ATCA_HID_IFACE == cfg->iface_type || ATCA_UART_IFACE == cfg->iface_type)) { (*device)->device_state = ATCA_DEVICE_STATE_ACTIVE; } @@ -256,6 +256,14 @@ bool atcab_is_ca_device(ATCADeviceType dev_type) return (dev_type < TA100) ? true : false; } +/** \brief Check whether the device is cryptoauth device + * \return True if device is cryptoauth device or False. + */ +bool atcab_is_ca2_device(ATCADeviceType dev_type) +{ + return ((dev_type & 0xF0) == 0x20) ? true : false; +} + /** \brief Check whether the device is Trust Anchor device * \return True if device is Trust Anchor device or False. */ @@ -274,7 +282,7 @@ ATCA_STATUS atcab_wakeup(void) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_wakeup(_gDevice); @@ -301,7 +309,7 @@ ATCA_STATUS atcab_idle(void) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_idle(_gDevice); @@ -328,7 +336,7 @@ ATCA_STATUS atcab_sleep(void) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sleep(_gDevice); @@ -362,7 +370,7 @@ ATCA_STATUS atcab_get_zone_size(uint8_t zone, uint16_t slot, size_t* size) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_get_zone_size(_gDevice, zone, slot, size); @@ -398,7 +406,7 @@ ATCA_STATUS atcab_aes(uint8_t mode, uint16_t key_id, const uint8_t* aes_in, uint ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if defined(ATCA_ATECC608_SUPPORT) status = calib_aes(_gDevice, mode, key_id, aes_in, aes_out); @@ -432,7 +440,7 @@ ATCA_STATUS atcab_aes_encrypt_ext(ATCADevice device, uint16_t key_id, uint8_t ke ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if defined(ATCA_ATECC608_SUPPORT) status = calib_aes_encrypt(device, key_id, key_block, plaintext, ciphertext); @@ -484,7 +492,7 @@ ATCA_STATUS atcab_aes_decrypt_ext(ATCADevice device, uint16_t key_id, uint8_t ke ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if defined(ATCA_ATECC608_SUPPORT) status = calib_aes_decrypt(device, key_id, key_block, ciphertext, plaintext); @@ -534,7 +542,7 @@ ATCA_STATUS atcab_aes_gfm(const uint8_t* h, const uint8_t* input, uint8_t* outpu ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if defined(ATCA_ATECC608_SUPPORT) status = calib_aes_gfm(_gDevice, h, input, output); @@ -571,7 +579,7 @@ ATCA_STATUS atcab_aes_gcm_init(atca_aes_gcm_ctx_t* ctx, uint16_t key_id, uint8_t ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_aes_gcm_init(_gDevice, ctx, key_id, key_block, iv, iv_size); @@ -614,7 +622,7 @@ ATCA_STATUS atcab_aes_gcm_init_rand(atca_aes_gcm_ctx_t* ctx, uint16_t key_id, ui ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_aes_gcm_init_rand(_gDevice, ctx, key_id, key_block, rand_size, free_field, free_field_size, iv); @@ -650,7 +658,7 @@ ATCA_STATUS atcab_aes_gcm_aad_update(atca_aes_gcm_ctx_t* ctx, const uint8_t* aad ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_aes_gcm_aad_update(_gDevice, ctx, aad, aad_size); @@ -683,7 +691,7 @@ ATCA_STATUS atcab_aes_gcm_encrypt_update(atca_aes_gcm_ctx_t* ctx, const uint8_t* ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_aes_gcm_encrypt_update(_gDevice, ctx, plaintext, plaintext_size, ciphertext); @@ -713,7 +721,7 @@ ATCA_STATUS atcab_aes_gcm_encrypt_finish(atca_aes_gcm_ctx_t* ctx, uint8_t* tag, ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_aes_gcm_encrypt_finish(_gDevice, ctx, tag, tag_size); @@ -746,7 +754,7 @@ ATCA_STATUS atcab_aes_gcm_decrypt_update(atca_aes_gcm_ctx_t* ctx, const uint8_t* ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_aes_gcm_decrypt_update(_gDevice, ctx, ciphertext, ciphertext_size, plaintext); @@ -777,7 +785,7 @@ ATCA_STATUS atcab_aes_gcm_decrypt_finish(atca_aes_gcm_ctx_t* ctx, const uint8_t* ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_aes_gcm_decrypt_finish(_gDevice, ctx, tag, tag_size, is_verified); @@ -813,7 +821,7 @@ ATCA_STATUS atcab_checkmac(uint8_t mode, uint16_t key_id, const uint8_t* challen ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_checkmac(_gDevice, mode, key_id, challenge, response, other_data); @@ -845,7 +853,7 @@ ATCA_STATUS atcab_counter(uint8_t mode, uint16_t counter_id, uint32_t* counter_v ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_counter(_gDevice, mode, counter_id, counter_value); @@ -875,7 +883,7 @@ ATCA_STATUS atcab_counter_increment(uint16_t counter_id, uint32_t* counter_value ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_counter_increment(_gDevice, counter_id, counter_value); @@ -904,7 +912,7 @@ ATCA_STATUS atcab_counter_read(uint16_t counter_id, uint32_t* counter_value) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_counter_read(_gDevice, counter_id, counter_value); @@ -942,7 +950,7 @@ ATCA_STATUS atcab_derivekey(uint8_t mode, uint16_t key_id, const uint8_t* mac) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_derivekey(_gDevice, mode, key_id, mac); @@ -980,7 +988,7 @@ ATCA_STATUS atcab_ecdh_base(uint8_t mode, uint16_t key_id, const uint8_t* public ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #ifdef ATCA_ECC_SUPPORT status = calib_ecdh_base(_gDevice, mode, key_id, public_key, pms, out_nonce); @@ -1014,7 +1022,7 @@ ATCA_STATUS atcab_ecdh(uint16_t key_id, const uint8_t* public_key, uint8_t* pms) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #ifdef ATCA_ECC_SUPPORT status = calib_ecdh(_gDevice, key_id, public_key, pms); @@ -1061,7 +1069,7 @@ ATCA_STATUS atcab_ecdh_enc(uint16_t key_id, const uint8_t* public_key, uint8_t* ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #ifdef ATCA_ECC_SUPPORT #ifdef ATCA_USE_CONSTANT_HOST_NONCE @@ -1100,7 +1108,7 @@ ATCA_STATUS atcab_ecdh_ioenc(uint16_t key_id, const uint8_t* public_key, uint8_t ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #ifdef ATCA_ATECC608_SUPPORT status = calib_ecdh_ioenc(_gDevice, key_id, public_key, pms, io_key); @@ -1135,7 +1143,7 @@ ATCA_STATUS atcab_ecdh_tempkey(const uint8_t* public_key, uint8_t* pms) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #ifdef ATCA_ATECC608_SUPPORT status = calib_ecdh_tempkey(_gDevice, public_key, pms); @@ -1171,7 +1179,7 @@ ATCA_STATUS atcab_ecdh_tempkey_ioenc(const uint8_t* public_key, uint8_t* pms, co ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #ifdef ATCA_ATECC608_SUPPORT status = calib_ecdh_tempkey_ioenc(_gDevice, public_key, pms, io_key); @@ -1207,7 +1215,7 @@ ATCA_STATUS atcab_gendig(uint8_t zone, uint16_t key_id, const uint8_t* other_dat ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_gendig(_gDevice, zone, key_id, other_data, other_data_size); @@ -1249,7 +1257,7 @@ ATCA_STATUS atcab_genkey_base(uint8_t mode, uint16_t key_id, const uint8_t* othe ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_genkey_base(_gDevice, mode, key_id, other_data, public_key); @@ -1284,7 +1292,7 @@ ATCA_STATUS atcab_genkey(uint16_t key_id, uint8_t* public_key) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_genkey(_gDevice, key_id, public_key); @@ -1319,7 +1327,7 @@ ATCA_STATUS atcab_get_pubkey_ext(ATCADevice device, uint16_t key_id, uint8_t* pu ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_get_pubkey(device, key_id, public_key); @@ -1374,7 +1382,7 @@ ATCA_STATUS atcab_hmac(uint8_t mode, uint16_t key_id, uint8_t* digest) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if defined(ATCA_ATSHA204A_SUPPORT) || defined(ATCA_ATECC108A_SUPPORT) || defined(ATCA_ATECC508A_SUPPORT) status = calib_hmac(_gDevice, mode, key_id, digest); @@ -1411,7 +1419,7 @@ ATCA_STATUS atcab_info_base(uint8_t mode, uint16_t param2, uint8_t* out_data) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_info_base(_gDevice, mode, param2, out_data); @@ -1437,7 +1445,7 @@ ATCA_STATUS atcab_info(uint8_t* revision) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_info(_gDevice, revision); @@ -1455,6 +1463,61 @@ ATCA_STATUS atcab_info(uint8_t* revision) } return status; } + +/** \brief Use the Info command to get the lock status + * \param[in] param2 selects the zone and slot + * \param[out] is_locked returns lock status here + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS atcab_info_lock_status(uint16_t param2, uint8_t *is_locked) +{ + ATCA_STATUS status = ATCA_UNIMPLEMENTED; + ATCADeviceType dev_type = atcab_get_device_type(); + + if (atcab_is_ca2_device(dev_type)) + { +#if ATCA_CA2_SUPPORT + status = calib_info_lock_status(_gDevice, param2, is_locked); +#endif + } + else if (atcab_is_ta_device(dev_type)) + { + status = ATCA_UNIMPLEMENTED; + } + else + { + status = ATCA_NOT_INITIALIZED; + } + return status; +} + +/** \brief Use the Info command to get the chip status + * \param[out] chip status returns chip status here + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS atcab_info_chip_status(uint8_t* chip_status) +{ + ATCA_STATUS status = ATCA_UNIMPLEMENTED; + ATCADeviceType dev_type = atcab_get_device_type(); + + if (atcab_is_ca2_device(dev_type)) + { +#if ATCA_CA2_SUPPORT + status = calib_info_chip_status(_gDevice, chip_status); +#endif + } + else if (atcab_is_ta_device(dev_type)) + { + status = ATCA_UNIMPLEMENTED; + } + else + { + status = ATCA_NOT_INITIALIZED; + } + return status; +} #endif #if ATCAB_INFO_LATCH_EN && defined(ATCA_USE_ATCAB_FUNCTIONS) @@ -1470,7 +1533,7 @@ ATCA_STATUS atcab_info_set_latch(bool state) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_info_set_latch(_gDevice, state); @@ -1499,7 +1562,7 @@ ATCA_STATUS atcab_info_get_latch(bool* state) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_info_get_latch(_gDevice, state); @@ -1548,7 +1611,7 @@ ATCA_STATUS atcab_kdf(uint8_t mode, uint16_t key_id, const uint32_t details, con ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_kdf(_gDevice, mode, key_id, details, message, out_data, out_nonce); @@ -1583,7 +1646,7 @@ ATCA_STATUS atcab_lock(uint8_t mode, uint16_t summary_crc) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_lock(_gDevice, mode, summary_crc); @@ -1611,7 +1674,7 @@ ATCA_STATUS atcab_lock_config_zone(void) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_lock_config_zone(_gDevice); @@ -1645,7 +1708,7 @@ ATCA_STATUS atcab_lock_config_zone_crc(uint16_t summary_crc) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_lock_config_zone_crc(_gDevice, summary_crc); @@ -1676,7 +1739,7 @@ ATCA_STATUS atcab_lock_data_zone(void) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_lock_data_zone(_gDevice); @@ -1710,7 +1773,7 @@ ATCA_STATUS atcab_lock_data_zone_crc(uint16_t summary_crc) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_lock_data_zone_crc(_gDevice, summary_crc); @@ -1742,7 +1805,7 @@ ATCA_STATUS atcab_lock_data_slot(uint16_t slot) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_lock_data_slot(_gDevice, slot); @@ -1783,7 +1846,7 @@ ATCA_STATUS atcab_mac(uint8_t mode, uint16_t key_id, const uint8_t* challenge, u ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_mac(_gDevice, mode, key_id, challenge, digest); @@ -1827,7 +1890,7 @@ ATCA_STATUS atcab_nonce_base(uint8_t mode, uint16_t zero, const uint8_t* num_in, ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_nonce_base(_gDevice, mode, zero, num_in, rand_out); @@ -1856,7 +1919,7 @@ ATCA_STATUS atcab_nonce(const uint8_t* num_in) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_nonce(_gDevice, num_in); @@ -1895,7 +1958,7 @@ ATCA_STATUS atcab_nonce_load(uint8_t target, const uint8_t* num_in, uint16_t num ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_nonce_load(_gDevice, target, num_in, num_in_size); @@ -1928,7 +1991,7 @@ ATCA_STATUS atcab_nonce_rand(const uint8_t* num_in, uint8_t* rand_out) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_nonce_rand(_gDevice, num_in, rand_out); @@ -1957,7 +2020,7 @@ ATCA_STATUS atcab_challenge(const uint8_t* num_in) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_challenge(_gDevice, num_in); @@ -1990,7 +2053,7 @@ ATCA_STATUS atcab_challenge_seed_update(const uint8_t* num_in, uint8_t* rand_out ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_challenge_seed_update(_gDevice, num_in, rand_out); @@ -2034,7 +2097,7 @@ ATCA_STATUS atcab_priv_write(uint16_t key_id, const uint8_t priv_key[36], uint16 ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #ifdef ATCA_ECC_SUPPORT #ifdef ATCA_USE_CONSTANT_HOST_NONCE @@ -2072,7 +2135,7 @@ ATCA_STATUS atcab_random_ext(ATCADevice device, uint8_t* rand_out) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_random(device, rand_out); @@ -2129,7 +2192,7 @@ ATCA_STATUS atcab_read_zone(uint8_t zone, uint16_t slot, uint8_t block, uint8_t ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_read_zone_ext(_gDevice, zone, slot, block, offset, data, len); @@ -2161,7 +2224,7 @@ ATCA_STATUS atcab_is_locked(uint8_t zone, bool* is_locked) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_is_locked_ext(_gDevice, zone, is_locked); @@ -2201,7 +2264,7 @@ ATCA_STATUS atcab_is_config_locked(bool* is_locked) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_is_locked_ext(_gDevice, LOCK_ZONE_CONFIG, is_locked); @@ -2232,7 +2295,7 @@ ATCA_STATUS atcab_is_data_locked(bool* is_locked) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_is_locked_ext(_gDevice, LOCK_ZONE_DATA, is_locked); @@ -2262,7 +2325,7 @@ ATCA_STATUS atcab_is_slot_locked(uint16_t slot, bool* is_locked) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_is_slot_locked(_gDevice, slot, is_locked); @@ -2298,7 +2361,7 @@ ATCA_STATUS atcab_is_private_ext(ATCADevice device, uint16_t slot, bool* is_priv ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_is_private(_gDevice, slot, is_private); @@ -2330,7 +2393,7 @@ ATCA_STATUS atcab_read_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_read_bytes_zone_ext(device, zone, slot, offset, data, length); @@ -2381,7 +2444,7 @@ ATCA_STATUS atcab_read_serial_number(uint8_t* serial_number) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_read_serial_number_ext(_gDevice, serial_number); @@ -2422,7 +2485,7 @@ ATCA_STATUS atcab_read_pubkey_ext(ATCADevice device, uint16_t slot, uint8_t* pub ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_read_pubkey(_gDevice, slot, public_key); @@ -2510,7 +2573,7 @@ ATCA_STATUS atcab_read_config_zone(uint8_t* config_data) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_read_config_zone(_gDevice, config_data); @@ -2548,7 +2611,7 @@ ATCA_STATUS atcab_cmp_config_zone(uint8_t* config_data, bool* same_config) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_cmp_config_zone(_gDevice, config_data, same_config); @@ -2714,9 +2777,9 @@ ATCA_STATUS atcab_selftest(uint8_t mode, uint16_t param2, uint8_t* result) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { -#ifdef ATCA_ATECC608_SUPPORT +#if defined(ATCA_ATECC608_SUPPORT) || ATCA_CA2_SUPPORT status = calib_selftest(_gDevice, mode, param2, result); #endif } @@ -2762,7 +2825,7 @@ ATCA_STATUS atcab_sha_base(uint8_t mode, uint16_t length, const uint8_t* data_in ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha_base(_gDevice, mode, length, data_in, data_out, data_out_size); @@ -2789,7 +2852,7 @@ ATCA_STATUS atcab_sha_start(void) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha_start(_gDevice); @@ -2820,7 +2883,7 @@ ATCA_STATUS atcab_sha_update(const uint8_t* message) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha_update(_gDevice, message); @@ -2854,7 +2917,7 @@ ATCA_STATUS atcab_sha_end(uint8_t* digest, uint16_t length, const uint8_t* messa ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha_end(_gDevice, digest, length, message); @@ -2956,7 +3019,7 @@ ATCA_STATUS atcab_sha(uint16_t length, const uint8_t* message, uint8_t* digest) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha(_gDevice, length, message, digest); @@ -2988,7 +3051,7 @@ ATCA_STATUS atcab_hw_sha2_256(const uint8_t* data, size_t data_size, uint8_t* di ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_hw_sha2_256(_gDevice, data, data_size, digest); @@ -3019,7 +3082,7 @@ ATCA_STATUS atcab_hw_sha2_256_init(atca_sha256_ctx_t* ctx) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_hw_sha2_256_init(_gDevice, ctx); @@ -3050,7 +3113,7 @@ ATCA_STATUS atcab_hw_sha2_256_update(atca_sha256_ctx_t* ctx, const uint8_t* data ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_hw_sha2_256_update(_gDevice, ctx, data, data_size); @@ -3080,7 +3143,7 @@ ATCA_STATUS atcab_hw_sha2_256_finish(atca_sha256_ctx_t* ctx, uint8_t* digest) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_hw_sha2_256_finish(_gDevice, ctx, digest); @@ -3111,7 +3174,7 @@ ATCA_STATUS atcab_sha_hmac_init(atca_hmac_sha256_ctx_t* ctx, uint16_t key_slot) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha_hmac_init(_gDevice, ctx, key_slot); @@ -3142,7 +3205,7 @@ ATCA_STATUS atcab_sha_hmac_update(atca_hmac_sha256_ctx_t* ctx, const uint8_t* da ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha_hmac_update(_gDevice, ctx, data, data_size); @@ -3176,7 +3239,7 @@ ATCA_STATUS atcab_sha_hmac_finish(atca_hmac_sha256_ctx_t* ctx, uint8_t* digest, ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha_hmac_finish(_gDevice, ctx, digest, target); @@ -3213,7 +3276,7 @@ ATCA_STATUS atcab_sha_hmac_ext(ATCADevice device, const uint8_t* data, size_t da ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_sha_hmac(device, data, data_size, key_slot, digest, target); @@ -3270,7 +3333,7 @@ ATCA_STATUS atcab_sign_base(uint8_t mode, uint16_t key_id, uint8_t* signature) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #ifdef ATCA_ECC_SUPPORT status = calib_sign_base(_gDevice, mode, key_id, signature); @@ -3308,9 +3371,9 @@ ATCA_STATUS atcab_sign_ext(ATCADevice device, uint16_t key_id, const uint8_t* ms ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { -#if ATCA_ECC_SUPPORT +#if ATCA_ECC_SUPPORT || defined(ATCA_ECC204_SUPPORT) || defined(ATCA_TA010_SUPPORT) status = calib_sign_ext(device, key_id, msg, signature); #endif } @@ -3846,7 +3909,7 @@ ATCA_STATUS atcab_write(uint8_t zone, uint16_t address, const uint8_t* value, co ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_write_ext(_gDevice, zone, address, value, mac); @@ -3882,7 +3945,7 @@ ATCA_STATUS atcab_write_zone(uint8_t zone, uint16_t slot, uint8_t block, uint8_t ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_write_zone_ext(_gDevice, zone, slot, block, offset, data, len); @@ -3906,7 +3969,7 @@ ATCA_STATUS atcab_write_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type_ext(device); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_write_bytes_zone_ext(device, zone, slot, offset_bytes, data, length); @@ -3966,7 +4029,7 @@ ATCA_STATUS atcab_write_pubkey(uint16_t slot, const uint8_t* public_key) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_write_pubkey(_gDevice, slot, public_key); @@ -4005,7 +4068,7 @@ ATCA_STATUS atcab_write_config_zone(const uint8_t* config_data) ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_write_config_zone_ext(_gDevice, config_data); @@ -4091,7 +4154,7 @@ ATCA_STATUS atcab_write_config_counter(uint16_t counter_id, uint32_t counter_val ATCA_STATUS status = ATCA_UNIMPLEMENTED; ATCADeviceType dev_type = atcab_get_device_type(); - if (atcab_is_ca_device(dev_type)) + if (atcab_is_ca_device(dev_type) || atcab_is_ca2_device(dev_type)) { #if ATCA_CA_SUPPORT status = calib_write_config_counter_ext(_gDevice, counter_id, counter_value); diff --git a/lib/atca_basic.h b/lib/atca_basic.h index 9472434f0..18e2d16d4 100644 --- a/lib/atca_basic.h +++ b/lib/atca_basic.h @@ -60,6 +60,7 @@ ATCADeviceType atcab_get_device_type(void); uint8_t atcab_get_device_address(ATCADevice device); bool atcab_is_ca_device(ATCADeviceType dev_type); +bool atcab_is_ca2_device(ATCADeviceType dev_type); bool atcab_is_ta_device(ATCADeviceType dev_type); #define atcab_get_addr(...) calib_get_addr(__VA_ARGS__) @@ -141,6 +142,8 @@ ATCA_STATUS atcab_hmac(uint8_t mode, uint16_t key_id, uint8_t* digest); // Info command functions ATCA_STATUS atcab_info_base(uint8_t mode, uint16_t param2, uint8_t* out_data); ATCA_STATUS atcab_info(uint8_t* revision); +ATCA_STATUS atcab_info_lock_status(uint16_t param2, uint8_t *is_locked); +ATCA_STATUS atcab_info_chip_status(uint8_t* chip_status); ATCA_STATUS atcab_info_set_latch(bool state); ATCA_STATUS atcab_info_get_latch(bool* state); @@ -165,6 +168,7 @@ ATCA_STATUS atcab_nonce_load(uint8_t target, const uint8_t* num_in, uint16_t num ATCA_STATUS atcab_nonce_rand(const uint8_t* num_in, uint8_t* rand_out); ATCA_STATUS atcab_challenge(const uint8_t* num_in); ATCA_STATUS atcab_challenge_seed_update(const uint8_t* num_in, uint8_t* rand_out); +ATCA_STATUS atcab_nonce_gen_session_key(uint16_t param2, const uint8_t* num_in, uint8_t* rand_out); // PrivWrite command functions #if defined(ATCA_USE_CONSTANT_HOST_NONCE) diff --git a/lib/atca_cfgs.c b/lib/atca_cfgs.c index a3b92cfb1..079573e55 100644 --- a/lib/atca_cfgs.c +++ b/lib/atca_cfgs.c @@ -163,18 +163,18 @@ ATCAIfaceCfg cfg_atsha20xa_kithid_default = { .iface_type = ATCA_HID_IFACE, .devtype = ATSHA204A, { - .atcahid.dev_interface = ATCA_KIT_AUTO_IFACE, - .atcahid.dev_identity = 0, - .atcahid.idx = 0, - .atcahid.vid = 0x03EB, - .atcahid.pid = 0x2312, - .atcahid.packetsize = 64, + .atcahid.dev_interface = ATCA_KIT_AUTO_IFACE, + .atcahid.dev_identity = 0, + .atcahid.idx = 0, + .atcahid.vid = 0x03EB, + .atcahid.pid = 0x2312, + .atcahid.packetsize = 64, }, .rx_retries = 1 }; #endif -#if defined(ATCA_ECC_SUPPORT) && defined(ATCA_HAL_I2C) +#if defined(ATCA_ECC204_SUPPORT) && defined(ATCA_HAL_I2C) /** \brief default configuration for an ECC204 device on the first logical I2C bus */ ATCAIfaceCfg cfg_ecc204_i2c_default = { .iface_type = ATCA_I2C_IFACE, @@ -197,10 +197,10 @@ ATCAIfaceCfg cfg_ecc204_i2c_default = { }; #endif -#if defined(ATCA_ECC_SUPPORT) && defined(ATCA_HAL_SWI) +#if defined(ATCA_ECC204_SUPPORT) && defined(ATCA_HAL_SWI) /** \brief default configuration for an ECC204 device on the logical SWI over GPIO*/ ATCAIfaceCfg cfg_ecc204_swi_default = { - .iface_type = ATCA_SWI_IFACE, + .iface_type = ATCA_SWI_GPIO_IFACE, .devtype = ECC204, { .atcaswi.bus = 4, @@ -210,7 +210,7 @@ ATCAIfaceCfg cfg_ecc204_swi_default = { }; #endif -#if defined(ATCA_ECC_SUPPORT) && defined(ATCA_HAL_KIT_HID) +#if defined(ATCA_ECC204_SUPPORT) && defined(ATCA_HAL_KIT_HID) /** \brief default configuration for Kit protocol over the device's async interface */ ATCAIfaceCfg cfg_ecc204_kithid_default = { .iface_type = ATCA_HID_IFACE, @@ -226,4 +226,55 @@ ATCAIfaceCfg cfg_ecc204_kithid_default = { }; #endif +#if defined(ATCA_TA010_SUPPORT) && defined(ATCA_HAL_I2C) +/** \brief default configuration for an ECC204 device on the first logical I2C bus */ +ATCAIfaceCfg cfg_ta010_i2c_default = { + .iface_type = ATCA_I2C_IFACE, + .devtype = TA010, + { +#ifdef ATCA_ENABLE_DEPRECATED + .atcai2c.slave_address = 0x33, +#else + .atcai2c.address = 0x33, +#endif + .atcai2c.bus = 2, +#ifdef __linux__ + .atcai2c.baud = 100000, +#else + .atcai2c.baud = 400000, +#endif + }, + .wake_delay = 1500, + .rx_retries = 20 +}; +#endif + +#if defined(ATCA_TA010_SUPPORT) && defined(ATCA_HAL_SWI) +/** \brief default configuration for an ECC204 device on the logical SWI over GPIO*/ +ATCAIfaceCfg cfg_ta010_swi_default = { + .iface_type = ATCA_SWI_GPIO_IFACE, + .devtype = TA010, + { + .atcaswi.bus = 4, + }, + .wake_delay = 1500, + .rx_retries = 10 +}; +#endif + +#if defined(ATCA_TA010_SUPPORT) && defined(ATCA_HAL_KIT_HID) +/** \brief default configuration for Kit protocol over the device's async interface */ +ATCAIfaceCfg cfg_ta010_kithid_default = { + .iface_type = ATCA_HID_IFACE, + .devtype = TA010, + { + .atcahid.dev_interface = ATCA_KIT_AUTO_IFACE, + .atcahid.dev_identity = 0, + .atcahid.idx = 0, + .atcahid.vid = 0x03EB, + .atcahid.pid = 0x2312, + .atcahid.packetsize = 64, + } +}; +#endif /** @} */ diff --git a/lib/atca_cfgs.h b/lib/atca_cfgs.h index 72f0f4a31..cb27de714 100644 --- a/lib/atca_cfgs.h +++ b/lib/atca_cfgs.h @@ -61,17 +61,6 @@ extern ATCAIfaceCfg cfg_atsha20xa_kitcdc_default; /** \brief default configuration for Kit protocol over a HID interface for SHA204 */ extern ATCAIfaceCfg cfg_atsha20xa_kithid_default; - -/** \brief default configuration for an ECC204 device on the first logical I2C bus */ -extern ATCAIfaceCfg cfg_ecc204_i2c_default; - -/** \brief default configuration for an ECC204 device on the logical SWI over GPIO*/ -extern ATCAIfaceCfg cfg_ecc204_swi_default; - -/** \brief default configuration for Kit protocol over the device's async interface */ -extern ATCAIfaceCfg cfg_ecc204_kithid_default; - - #ifdef __cplusplus } #endif diff --git a/lib/atca_config.h.in b/lib/atca_config.h.in index 1c9fa9d0a..b14534c51 100644 --- a/lib/atca_config.h.in +++ b/lib/atca_config.h.in @@ -20,6 +20,7 @@ #cmakedefine ATCA_ATECC608_SUPPORT #cmakedefine ATCA_TA100_SUPPORT #cmakedefine ATCA_ECC204_SUPPORT +#cmakedefine ATCA_TA010_SUPPORT /** Device Override - Library Assumes ATECC608B support in checks */ #cmakedefine ATCA_ATECC608A_SUPPORT @@ -88,6 +89,8 @@ selected plus however additional slots one would like */ /** Enable Strict ISO/C99 compliance */ #cmakedefine ATCA_STRICT_C99 +/******************** Device Configuration Section *************************/ + /** TA100 Specific - Enable auth sessions that require AES (CMAC/GCM) from an external library */ #cmakedefine ATCA_TA100_AES_AUTH_SUPPORT @@ -95,6 +98,10 @@ selected plus however additional slots one would like */ /** TA100 Specific - Enable support for the FCE APIs for the TA100 */ #cmakedefine ATCA_TA100_FCE_SUPPORT +/** Enable the delete command */ +#cmakedefine01 CALIB_DELETE_EN + + /******************** Platform Configuration Section ***********************/ /** Define if the library is not to use malloc/free */ diff --git a/lib/atca_config_check.h b/lib/atca_config_check.h index 58a1dc9ff..668bf32a0 100644 --- a/lib/atca_config_check.h +++ b/lib/atca_config_check.h @@ -54,8 +54,15 @@ #define ATCA_ECC_SUPPORT DEFAULT_ENABLED #endif +/* Support for a second generation of cryptoauth parts */ +#if defined(ATCA_ECC204_SUPPORT) || defined(ATCA_TA010_SUPPORT) +#define ATCA_CA2_SUPPORT DEFAULT_ENABLED +#else +#define ATCA_CA2_SUPPORT DEFAULT_DISABLED +#endif + /* Classic Cryptoauth Devices */ -#if defined(ATCA_SHA_SUPPORT) || defined(ATCA_ECC_SUPPORT) || defined(ATCA_ECC204_SUPPORT) +#if defined(ATCA_SHA_SUPPORT) || defined(ATCA_ECC_SUPPORT) || ATCA_CA2_SUPPORT #define ATCA_CA_SUPPORT DEFAULT_ENABLED #else #define ATCA_CA_SUPPORT DEFAULT_DISABLED diff --git a/lib/atca_devtypes.h b/lib/atca_devtypes.h index 9dd490c6f..2e1091089 100644 --- a/lib/atca_devtypes.h +++ b/lib/atca_devtypes.h @@ -36,21 +36,26 @@ extern "C" { #endif - /** \brief The supported Device type in Cryptoauthlib library */ typedef enum { - ATSHA204A = 0, - ATECC108A = 1, - ATECC508A = 2, - ATECC608A = 3, - ATECC608B = 3, - ATECC608 = 3, - ATSHA206A = 4, - ECC204 = 5, - TA010 = 7, - TA100 = 0x10, - ATCA_DEV_UNKNOWN = 0x20 + ATSHA204A = 0, + ATECC108A = 1, + ATECC508A = 2, + ATECC608A = 3, + ATECC608B = 3, + ATECC608 = 3, + ATSHA206A = 4, + TA100 = 0x10, + ECC204 = 0x20, + TA010 = 0x21, + ECC206 = 0x22, + RNG90 = 0x23, + SHA104 = 0x24, + SHA105 = 0x25, + SHA106 = 0x26, + ATCA_DEV_UNKNOWN = 0x7E, + ATCA_DEV_INVALID = 0x7F, } ATCADeviceType; #ifdef __cplusplus diff --git a/lib/atca_iface.c b/lib/atca_iface.c index 00aac2aaa..2e2d18e50 100644 --- a/lib/atca_iface.c +++ b/lib/atca_iface.c @@ -600,6 +600,9 @@ static const devtype_names_t devtype_names[] = { #ifdef ATCA_ECC204_SUPPORT { ECC204, "ecc204" }, #endif +#ifdef ATCA_TA010_SUPPORT + { TA010, "ta010" }, +#endif #ifdef ATCA_TA100_SUPPORT { TA100, "ta100" }, #endif diff --git a/lib/atca_version.h b/lib/atca_version.h index 981c51099..40c44ce3b 100644 --- a/lib/atca_version.h +++ b/lib/atca_version.h @@ -30,9 +30,9 @@ #define _ATCA_VERSION_H // Version format yyyymmdd -#define ATCA_LIBRARY_VERSION_DATE "20221111" +#define ATCA_LIBRARY_VERSION_DATE "20230314" #define ATCA_LIBRARY_VERSION_MAJOR 3 -#define ATCA_LIBRARY_VERSION_MINOR 4 -#define ATCA_LIBRARY_VERSION_BUILD 1 +#define ATCA_LIBRARY_VERSION_MINOR 5 +#define ATCA_LIBRARY_VERSION_BUILD 0 #endif /* _ATCA_VERSION_H */ diff --git a/lib/calib/calib_basic.c b/lib/calib/calib_basic.c index 693e03181..cad242536 100644 --- a/lib/calib/calib_basic.c +++ b/lib/calib/calib_basic.c @@ -65,8 +65,10 @@ ATCA_STATUS calib_wakeup_i2c(ATCADevice device) status = ATCA_SUCCESS; } - #ifdef ATCA_ECC204_SUPPORT - if (ECC204 == atcab_get_device_type_ext(device)) + #if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + + if (atcab_is_ca2_device(device_type)) { (void)atsend(iface, address, NULL, 0); } @@ -141,6 +143,7 @@ ATCA_STATUS calib_wakeup(ATCADevice device) ATCA_STATUS calib_idle(ATCADevice device) { ATCA_STATUS status = ATCA_BAD_PARAM; + ATCADeviceType device_type = atcab_get_device_type_ext(device); #ifdef ATCA_HAL_LEGACY_API status = atidle(&device->mIface); @@ -151,7 +154,7 @@ ATCA_STATUS calib_idle(ATCADevice device) } else { - if (ECC204 != atcab_get_device_type_ext(device)) + if (!atcab_is_ca2_device(device_type)) { uint8_t command = 0x02; status = atsend(&device->mIface, atcab_get_device_address(device), &command, 1); @@ -244,8 +247,8 @@ ATCA_STATUS calib_get_addr(uint8_t zone, uint16_t slot, uint8_t block, uint8_t o return status; } -#ifdef ATCA_ECC204_SUPPORT -/** \brief Compute the address given the zone, slot, block, and offset for ECC204 device +#if ATCA_CA2_SUPPORT +/** \brief Compute the address given the zone, slot, block, and offset for the device * \param[in] zone Zone to get address from. Config(1) or * Data(0) which requires a slot. * \param[in] slot Slot Id number for data zone and zero for other zones. @@ -255,7 +258,7 @@ ATCA_STATUS calib_get_addr(uint8_t zone, uint16_t slot, uint8_t block, uint8_t o * * \return ATCA_SUCCESS on success, otherwise an error code. */ -ATCA_STATUS calib_ecc204_get_addr(uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, uint16_t* addr) +ATCA_STATUS calib_ca2_get_addr(uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, uint16_t* addr) { ATCA_STATUS status = ATCA_SUCCESS; @@ -319,8 +322,8 @@ ATCA_STATUS calib_get_zone_size(ATCADevice device, uint8_t zone, uint16_t slot, } } #endif -#ifdef ATCA_ECC204_SUPPORT - else if (ECC204 == device->mIface.mIfaceCFG->devtype) +#if ATCA_CA2_SUPPORT + else if (atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype)) { switch (zone) { diff --git a/lib/calib/calib_basic.h b/lib/calib/calib_basic.h index f40138d3e..1d06fccb7 100644 --- a/lib/calib/calib_basic.h +++ b/lib/calib/calib_basic.h @@ -24,18 +24,25 @@ ATCA_STATUS calib_sleep(ATCADevice device); ATCA_STATUS _calib_exit(ATCADevice device); ATCA_STATUS calib_get_addr(uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, uint16_t* addr); ATCA_STATUS calib_get_zone_size(ATCADevice device, uint8_t zone, uint16_t slot, size_t* size); -ATCA_STATUS calib_ecc204_get_addr(uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, uint16_t* addr); +ATCA_STATUS calib_ca2_get_addr(uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, uint16_t* addr); /* Helper Functions */ ATCA_STATUS calib_is_locked(ATCADevice device, uint8_t zone, bool* is_locked); -ATCA_STATUS calib_is_locked_ext(ATCADevice device, uint8_t zone, bool* is_locked); ATCA_STATUS calib_is_slot_locked(ATCADevice device, uint16_t slot, bool* is_locked); -ATCA_STATUS calib_is_private(ATCADevice device, uint16_t slot, bool* is_private); -ATCA_STATUS calib_ecc204_is_locked(ATCADevice device, uint8_t zone, bool* is_locked); -ATCA_STATUS calib_ecc204_is_data_locked(ATCADevice device, bool* is_locked); -ATCA_STATUS calib_ecc204_is_config_locked(ATCADevice device, bool* is_locked); +ATCA_STATUS calib_ca2_is_locked(ATCADevice device, uint8_t zone, bool* is_locked); +ATCA_STATUS calib_ca2_is_data_locked(ATCADevice device, bool* is_locked); +ATCA_STATUS calib_ca2_is_config_locked(ATCADevice device, bool* is_locked); ATCADeviceType calib_get_devicetype(uint8_t revision[4]); +#if CALIB_READ_EN || CALIB_READ_CA2_EN +ATCA_STATUS calib_is_locked_ext(ATCADevice device, uint8_t zone, bool* is_locked); +ATCA_STATUS calib_is_private(ATCADevice device, uint16_t slot, bool* is_private); +#endif + +#if ATCA_CA2_SUPPORT +ATCADeviceType calib_get_devicetype_with_device_id(uint8_t device_id,uint8_t device_revision); +#endif + //AES command functions #if CALIB_AES_EN ATCA_STATUS calib_aes(ATCADevice device, uint8_t mode, uint16_t key_id, const uint8_t* aes_in, uint8_t* aes_out); @@ -58,6 +65,12 @@ ATCA_STATUS calib_counter_increment(ATCADevice device, uint16_t counter_id, uint ATCA_STATUS calib_counter_read(ATCADevice device, uint16_t counter_id, uint32_t* counter_value); #endif +// Delete command functions +#if CALIB_DELETE_EN +ATCA_STATUS calib_delete_base(ATCADevice device, uint8_t mode, uint16_t key_id, const uint8_t* mac); +ATCA_STATUS calib_delete(ATCADevice device, uint8_t num_in[NONCE_NUMIN_SIZE], const uint8_t *key); +#endif + // DeriveKey command functions #if CALIB_DERIVEKEY_EN ATCA_STATUS calib_derivekey(ATCADevice device, uint8_t mode, uint16_t key_id, const uint8_t* mac); @@ -104,7 +117,10 @@ ATCA_STATUS calib_hmac(ATCADevice device, uint8_t mode, uint16_t key_id, uint8_t ATCA_STATUS calib_info_base(ATCADevice device, uint8_t mode, uint16_t param2, uint8_t* out_data); ATCA_STATUS calib_info(ATCADevice device, uint8_t* revision); ATCA_STATUS calib_info_privkey_valid(ATCADevice device, uint16_t key_id, uint8_t* is_valid); +#if ATCA_CA2_SUPPORT ATCA_STATUS calib_info_lock_status(ATCADevice device, uint16_t param2, uint8_t* is_locked); +ATCA_STATUS calib_info_chip_status(ATCADevice device, uint8_t* chip_status); +#endif #if CALIB_INFO_LATCH_EN ATCA_STATUS calib_info_set_latch(ATCADevice device, bool state); ATCA_STATUS calib_info_get_latch(ATCADevice device, bool* state); @@ -116,22 +132,20 @@ ATCA_STATUS calib_kdf(ATCADevice device, uint8_t mode, uint16_t key_id, const ui #endif // Lock command functions -#if CALIB_LOCK_EN || CALIB_LOCK_ECC204_EN +#if CALIB_LOCK_EN || CALIB_LOCK_CA2_EN ATCA_STATUS calib_lock(ATCADevice device, uint8_t mode, uint16_t summary_crc); -#endif -#if CALIB_LOCK_EN ATCA_STATUS calib_lock_config_zone(ATCADevice device); ATCA_STATUS calib_lock_config_zone_crc(ATCADevice device, uint16_t summary_crc); ATCA_STATUS calib_lock_data_zone(ATCADevice device); ATCA_STATUS calib_lock_data_zone_crc(ATCADevice device, uint16_t summary_crc); ATCA_STATUS calib_lock_data_slot(ATCADevice device, uint16_t slot); #endif -// Lock ECC204 command functions -#if CALIB_LOCK_ECC204_EN -ATCA_STATUS calib_ecc204_lock_config_slot(ATCADevice device, uint16_t slot, uint16_t summary_crc); -ATCA_STATUS calib_ecc204_lock_config_zone(ATCADevice device); -ATCA_STATUS calib_ecc204_lock_data_slot(ATCADevice device, uint16_t slot); -ATCA_STATUS calib_ecc204_lock_data_zone(ATCADevice device); +// Lock CA2 command functions +#if CALIB_LOCK_CA2_EN +ATCA_STATUS calib_ca2_lock_config_slot(ATCADevice device, uint16_t slot, uint16_t summary_crc); +ATCA_STATUS calib_ca2_lock_config_zone(ATCADevice device); +ATCA_STATUS calib_ca2_lock_data_slot(ATCADevice device, uint16_t slot); +ATCA_STATUS calib_ca2_lock_data_zone(ATCADevice device); #endif // MAC command functions @@ -169,29 +183,29 @@ ATCA_STATUS calib_random(ATCADevice device, uint8_t* rand_out); #if CALIB_READ_EN ATCA_STATUS calib_read_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, uint8_t *data, uint8_t len); ATCA_STATUS calib_read_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset, uint8_t *data, size_t length); -ATCA_STATUS calib_read_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset, uint8_t *data, size_t length); ATCA_STATUS calib_read_serial_number(ATCADevice device, uint8_t* serial_number); -ATCA_STATUS calib_read_serial_number_ext(ATCADevice device, uint8_t* serial_number); bool calib_sha_compare_config(uint8_t* expected, uint8_t* other); bool calib_ecc_compare_config(uint8_t* expected, uint8_t* other); bool calib_ecc608_compare_config(uint8_t* expected, uint8_t* other); +ATCA_STATUS calib_read_sig(ATCADevice device, uint16_t slot, uint8_t *sig); #endif -// ECC204 Read command functions -#if CALIB_READ_ECC204_EN -ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, size_t offset, +// CA2 Read command functions +#if CALIB_READ_CA2_EN +ATCA_STATUS calib_ca2_read_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, size_t offset, uint8_t* data, uint8_t len); -ATCA_STATUS calib_ecc204_read_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, +ATCA_STATUS calib_ca2_read_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, size_t block, uint8_t* data, size_t length); -ATCA_STATUS calib_ecc204_read_serial_number(ATCADevice device, uint8_t* serial_number); -ATCA_STATUS calib_ecc204_read_config_zone(ATCADevice device, uint8_t* config_data); -bool calib_ecc204_compare_config(uint8_t* expected, uint8_t* other); +ATCA_STATUS calib_ca2_read_serial_number(ATCADevice device, uint8_t* serial_number); +ATCA_STATUS calib_ca2_read_config_zone(ATCADevice device, uint8_t* config_data); +bool calib_ca2_compare_config(uint8_t* expected, uint8_t* other); #endif -#if CALIB_READ_EN || CALIB_READ_ECC204_EN +#if CALIB_READ_EN || CALIB_READ_CA2_EN ATCA_STATUS calib_read_config_zone(ATCADevice device, uint8_t* config_data); ATCA_STATUS calib_cmp_config_zone(ATCADevice device, uint8_t* config_data, bool* same_config); ATCA_STATUS calib_read_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, uint8_t *data, uint8_t len); +ATCA_STATUS calib_read_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset, uint8_t *data, size_t length); ATCA_STATUS calib_read_pubkey(ATCADevice device, uint16_t slot, uint8_t *public_key); -ATCA_STATUS calib_read_sig(ATCADevice device, uint16_t slot, uint8_t *sig); +ATCA_STATUS calib_read_serial_number_ext(ATCADevice device, uint8_t* serial_number); #endif @@ -250,14 +264,16 @@ ATCA_STATUS calib_sha_hmac(ATCADevice device, const uint8_t * data, size_t data_ #if CALIB_SIGN_EN ATCA_STATUS calib_sign_base(ATCADevice device, uint8_t mode, uint16_t key_id, uint8_t *signature); ATCA_STATUS calib_sign(ATCADevice device, uint16_t key_id, const uint8_t *msg, uint8_t *signature); +#endif +#if CALIB_SIGN_EN || CALIB_SIGN_CA2_EN ATCA_STATUS calib_sign_ext(ATCADevice device, uint16_t key_id, const uint8_t *msg, uint8_t *signature); #endif #if CALIB_SIGN_INTERNAL_EN ATCA_STATUS calib_sign_internal(ATCADevice device, uint16_t key_id, bool is_invalidate, bool is_full_sn, uint8_t *signature); #endif -// ECC204 Sign command functions -#if CALIB_SIGN_ECC204_EN -ATCA_STATUS calib_ecc204_sign(ATCADevice device, uint16_t key_id, const uint8_t* msg, uint8_t* signature); +// CA2 Sign command functions +#if CALIB_SIGN_CA2_EN +ATCA_STATUS calib_ca2_sign(ATCADevice device, uint16_t key_id, const uint8_t* msg, uint8_t* signature); #endif // UpdateExtra command functions @@ -293,16 +309,16 @@ ATCA_STATUS calib_verify_invalidate(ATCADevice device, uint16_t key_id, const ui // Write command functions #if CALIB_WRITE_EN ATCA_STATUS calib_write(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, const uint8_t *mac); -ATCA_STATUS calib_write_ext(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, const uint8_t *mac); ATCA_STATUS calib_write_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, const uint8_t *data, uint8_t len); ATCA_STATUS calib_write_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset_bytes, const uint8_t *data, size_t length); -ATCA_STATUS calib_write_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset_bytes, const uint8_t *data, size_t length); ATCA_STATUS calib_write_config_zone(ATCADevice device, const uint8_t* config_data); -ATCA_STATUS calib_write_config_zone_ext(ATCADevice device, const uint8_t* config_data); ATCA_STATUS calib_write_config_counter(ATCADevice device, uint16_t counter_id, uint32_t counter_value); #endif -#if CALIB_WRITE_EN || CALIB_WRITE_ECC204_EN +#if CALIB_WRITE_EN || CALIB_WRITE_CA2_EN +ATCA_STATUS calib_write_ext(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, const uint8_t *mac); ATCA_STATUS calib_write_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, const uint8_t *data, uint8_t len); +ATCA_STATUS calib_write_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset_bytes, const uint8_t *data, size_t length); +ATCA_STATUS calib_write_config_zone_ext(ATCADevice device, const uint8_t* config_data); ATCA_STATUS calib_write_config_counter_ext(ATCADevice device, uint16_t counter_id, uint32_t counter_value); ATCA_STATUS calib_write_pubkey(ATCADevice device, uint16_t slot, const uint8_t *public_key); #endif @@ -315,21 +331,66 @@ ATCA_STATUS calib_write_enc(ATCADevice device, uint16_t key_id, uint8_t block, c #endif #endif /* CALIB_WRITE_ENC_EN */ -// ECC204 Write command functions -#if CALIB_WRITE_ECC204_EN -ATCA_STATUS calib_ecc204_write(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, +// CA2 Write command functions +#if CALIB_WRITE_CA2_EN +ATCA_STATUS calib_ca2_write(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, const uint8_t *mac); -ATCA_STATUS calib_ecc204_write_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, +ATCA_STATUS calib_ca2_write_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, const uint8_t *data, uint8_t len); -ATCA_STATUS calib_ecc204_write_config_zone(ATCADevice device, const uint8_t* config_data); -ATCA_STATUS calib_ecc204_write_config_counter(ATCADevice device, uint8_t counter_id, uint16_t counter_value); -ATCA_STATUS calib_ecc204_write_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, size_t block, +ATCA_STATUS calib_ca2_write_config_zone(ATCADevice device, const uint8_t* config_data); +ATCA_STATUS calib_ca2_write_config_counter(ATCADevice device, uint8_t counter_id, uint16_t counter_value); +ATCA_STATUS calib_ca2_write_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, size_t block, const uint8_t *data, size_t length); -#endif /* CALIB_WRITE_ECC204_EN */ -#if CALIB_WRITE_ENC_ECC204_EN -ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* data, uint8_t* transport_key, +#endif /* CALIB_WRITE_CA2_EN */ +#if CALIB_WRITE_ENC_CA2_EN +ATCA_STATUS calib_ca2_write_enc(ATCADevice device, uint16_t slot, uint8_t* data, uint8_t* transport_key, uint8_t key_id, uint8_t num_in[NONCE_NUMIN_SIZE]); -#endif /* CALIB_WRITE_ENC_ECC204_EN */ +#endif /* CALIB_WRITE_ENC_CA2_EN */ + +// Lock command functions +#if ATCAB_LOCK_EN + +#if CALIB_TA010_EN +#define calib_ta010_lock_config_zone(...) calib_ca2_lock_config_zone(__VA_ARGS__) +#define calib_ta010_lock_data_zone(...) calib_ca2_lock_data_zone(__VA_ARGS__) +#define calib_ta010_lock_data_slot(...) calib_ca2_lock_data_slot(__VA_ARGS__) +#endif + +#endif + +// Read command functions +#if ATCAB_READ_EN + +#if CALIB_TA010_EN +#define calib_ta010_read_zone(...) calib_ca2_read_zone(__VA_ARGS__) +#define calib_ta010_is_locked(...) calib_ca2_is_locked(__VA_ARGS__) +#define calib_ta010_is_config_locked(...) calib_ca2_is_config_locked(__VA_ARGS__) +#define calib_ta010_is_data_locked(...) calib_ca2_is_data_locked(__VA_ARGS__) +#define calib_ta010_read_bytes_zone(...) calib_ca2_read_bytes_zone(__VA_ARGS__) +#define calib_ta010_read_serial_number(...) calib_ca2_read_serial_number(__VA_ARGS__) +#define calib_ta010_read_config_zone(...) calib_ca2_read_config_zone(__VA_ARGS__) +#define calib_ta010_compare_config(...) calib_ca2_compare_config(__VA_ARGS__) +#endif + +#endif + +// Write command functions +#if ATCAB_WRITE_EN + +#if CALIB_TA010_EN +#define calib_ta010_write(...) calib_ca2_write(__VA_ARGS__) +#define calib_ta010_write_zone(...) calib_ca2_write_zone(__VA_ARGS__) +#define calib_ta010_write_bytes_zone(...) calib_ca2_write_bytes_zone(__VA_ARGS__) +#define calib_ta010_write_config_zone(...) calib_ca2_write_config_zone(__VA_ARGS__) +#define calib_ta010_write_config_counter(...) calib_ca2_write_config_counter(__VA_ARGS__) +#endif + +#endif + +// Sign command functions +#if ATCAB_SIGN_EN && CALIB_TA010_EN +#define calib_ta010_sign(...) calib_ca2_sign(__VA_ARGS__) +#endif /* Map calib functions to atcab names for api compatibility without abstraction overhead */ #if !ATCA_TA_SUPPORT && !defined(ATCA_USE_ATCAB_FUNCTIONS) @@ -393,18 +454,20 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da #define atcab_info(...) calib_info(_gDevice, __VA_ARGS__) #define atcab_info_get_latch(...) calib_info_get_latch(_gDevice, __VA_ARGS__) #define atcab_info_set_latch(...) calib_info_set_latch(_gDevice, __VA_ARGS__) +#define atcab_info_lock_status(...) calib_info_lock_status(_gDevice, __VA_ARGS__) +#define atcab_info_chip_status(...) calib_info_chip_status(_gDevice, __VA_ARGS__) // KDF command functions #define atcab_kdf(...) calib_kdf(_gDevice, __VA_ARGS__) // Lock command functions -#if CALIB_ECC204_ONLY +#if ATCA_CA2_SUPPORT && !ATCA_CA_SUPPORT #define atcab_lock(...) (ATCA_UNIMPLEMENTED) -#define atcab_lock_config_zone() calib_ecc204_lock_config_zone(_gDevice) +#define atcab_lock_config_zone() calib_ca2_lock_config_zone(_gDevice) #define atcab_lock_config_zone_crc(...) (ATCA_UNIMPLEMENTED) -#define atcab_lock_data_zone() calib_ecc204_lock_data_zone(_gDevice) +#define atcab_lock_data_zone() calib_ca2_lock_data_zone(_gDevice) #define atcab_lock_data_zone_crc(...) (ATCA_UNIMPLEMENTED) -#define atcab_lock_data_slot(...) calib_ecc204_lock_data_slot(_gDevice, __VA_ARGS__) +#define atcab_lock_data_slot(...) calib_ca2_lock_data_slot(_gDevice, __VA_ARGS__) #else #define atcab_lock(...) calib_lock(_gDevice, __VA_ARGS__) #define atcab_lock_config_zone() calib_lock_config_zone(_gDevice) @@ -437,15 +500,16 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da #define atcab_is_slot_locked(...) calib_is_slot_locked(_gDevice, __VA_ARGS__) #define atcab_is_private(...) calib_is_private(_gDevice, __VA_ARGS__) #define atcab_is_private_ext calib_is_private -#if CALIB_ECC204_ONLY -#define atcab_read_zone(...) calib_ecc204_read_zone(_gDevice, __VA_ARGS__) -#define atcab_is_locked(...) calib_ecc204_is_locked(_gDevice, __VA_ARGS__) -#define atcab_is_config_locked(...) calib_ecc204_is_locked(_gDevice, ATCA_ZONE_CONFIG, __VA_ARGS__) -#define atcab_is_data_locked(...) calib_ecc204_is_locked(_gDevice, ATCA_ZONE_DATA, __VA_ARGS__) -#define atcab_read_bytes_zone(...) calib_ecc204_read_bytes_zone(_gDevice, __VA_ARGS__) -#define atcab_read_bytes_zone_ext calib_ecc204_read_bytes_zone -#define atcab_read_serial_number(...) calib_ecc204_read_serial_number(_gDevice, __VA_ARGS__) -#define atcab_read_config_zone(...) calib_ecc204_read_config_zone(_gDevice, __VA_ARGS__) + +#if ATCA_CA2_SUPPORT && !ATCA_CA_SUPPORT +#define atcab_read_zone(...) calib_ca2_read_zone(_gDevice, __VA_ARGS__) +#define atcab_is_locked(...) calib_ca2_is_locked(_gDevice, __VA_ARGS__) +#define atcab_is_config_locked(...) calib_ca2_is_locked(_gDevice, ATCA_ZONE_CONFIG, __VA_ARGS__) +#define atcab_is_data_locked(...) calib_ca2_is_locked(_gDevice, ATCA_ZONE_DATA, __VA_ARGS__) +#define atcab_read_bytes_zone(...) calib_ca2_read_bytes_zone(_gDevice, __VA_ARGS__) +#define atcab_read_bytes_zone_ext calib_ca2_read_bytes_zone +#define atcab_read_serial_number(...) calib_ca2_read_serial_number(_gDevice, __VA_ARGS__) +#define atcab_read_config_zone(...) calib_ca2_read_config_zone(_gDevice, __VA_ARGS__) #else #define atcab_read_zone(...) calib_read_zone_ext(_gDevice, __VA_ARGS__) #define atcab_is_locked(...) calib_is_locked_ext(_gDevice, __VA_ARGS__) @@ -491,9 +555,9 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da // Sign command functions #define atcab_sign_base(...) calib_sign_base(_gDevice, __VA_ARGS__) -#if CALIB_ECC204_ONLY -#define atcab_sign(...) calib_ecc204_sign(_gDevice, __VA_ARGS__) -#define atcab_sign_ext calib_ecc204_sign +#if ATCA_CA2_SUPPORT && !ATCA_CA_SUPPORT +#define atcab_sign(...) calib_ca2_sign(_gDevice, __VA_ARGS__) +#define atcab_sign_ext calib_ca2_sign #else #define atcab_sign(...) calib_sign_ext(_gDevice, __VA_ARGS__) #define atcab_sign_ext calib_sign_ext @@ -517,13 +581,13 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da #define atcab_verify_invalidate(...) calib_verify_invalidate(_gDevice, __VA_ARGS__) // Write command functions -#if CALIB_ECC204_ONLY -#define atcab_write(...) calib_ecc204_write(_gDevice, __VA_ARGS__) -#define atcab_write_zone(...) calib_ecc204_write_zone(_gDevice, __VA_ARGS__) -#define atcab_write_bytes_zone(...) calib_ecc204_write_bytes_zone(_gDevice, __VA_ARGS__) -#define atcab_write_bytes_zone_ext calib_ecc204_write_bytes_zone -#define atcab_write_config_zone(...) calib_ecc204_write_config_zone(_gDevice, __VA_ARGS__) -#define atcab_write_config_counter(...) calib_ecc204_write_config_counter(_gDevice, __VA_ARGS__) +#if ATCA_CA2_SUPPORT && !ATCA_CA_SUPPORT +#define atcab_write(...) calib_ca2_write(_gDevice, __VA_ARGS__) +#define atcab_write_zone(...) calib_ca2_write_zone(_gDevice, __VA_ARGS__) +#define atcab_write_bytes_zone(...) calib_ca2_write_bytes_zone(_gDevice, __VA_ARGS__) +#define atcab_write_bytes_zone_ext calib_ca2_write_bytes_zone +#define atcab_write_config_zone(...) calib_ca2_write_config_zone(_gDevice, __VA_ARGS__) +#define atcab_write_config_counter(...) calib_ca2_write_config_counter(_gDevice, __VA_ARGS__) #else #define atcab_write(...) calib_write_ext(_gDevice, __VA_ARGS__) #define atcab_write_zone(...) calib_write_zone_ext(_gDevice, __VA_ARGS__) diff --git a/lib/calib/calib_command.c b/lib/calib/calib_command.c index 342e3fdbd..95444a18d 100644 --- a/lib/calib/calib_command.c +++ b/lib/calib/calib_command.c @@ -70,6 +70,24 @@ ATCA_STATUS atCounter(ATCADeviceType device_type, ATCAPacket *packet) } #endif +#if CALIB_DELETE_EN +/** \brief ATCACommand Delete method + * \param[in] ca_cmd instance + * \param[in] packet pointer to the packet containing the command being built + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS atDelete(ATCADeviceType device_type, ATCAPacket *packet) +{ + ((void)device_type); + + // Set the opcode & parameters + packet->opcode = ATCA_DELETE; + packet->txsize = DELETE_COUNT; + atCalcCrc(packet); + return ATCA_SUCCESS; +} +#endif + #if CALIB_DERIVEKEY_EN /** \brief ATCACommand DeriveKey method * \param[in] ca_cmd instance @@ -208,7 +226,7 @@ ATCA_STATUS atInfo(ATCADeviceType device_type, ATCAPacket *packet) return ATCA_SUCCESS; } -#if CALIB_LOCK_EN || CALIB_LOCK_ECC204_EN +#if CALIB_LOCK_EN || CALIB_LOCK_CA2_EN /** \brief ATCACommand Lock method * \param[in] ca_cmd instance * \param[in] packet pointer to the packet containing the command being built @@ -268,7 +286,7 @@ ATCA_STATUS atNonce(ATCADeviceType device_type, ATCAPacket *packet) packet->opcode = ATCA_NONCE; - if ((calc_mode == NONCE_MODE_SEED_UPDATE || calc_mode == NONCE_MODE_NO_SEED_UPDATE)) + if ((calc_mode == NONCE_MODE_SEED_UPDATE || calc_mode == NONCE_MODE_NO_SEED_UPDATE || calc_mode == NONCE_MODE_GEN_SESSION_KEY)) { // Calculated nonce mode, 20 byte NumInm packet->txsize = NONCE_COUNT_SHORT; @@ -348,7 +366,7 @@ ATCA_STATUS atRandom(ATCADeviceType device_type, ATCAPacket *packet) } #endif -#if CALIB_READ_EN || CALIB_READ_ECC204_EN +#if CALIB_READ_EN || CALIB_READ_CA2_EN /** \brief ATCACommand Read method * \param[in] ca_cmd instance * \param[in] packet pointer to the packet containing the command being built @@ -447,7 +465,7 @@ ATCA_STATUS atSHA(ATCADeviceType device_type, ATCAPacket *packet, uint16_t write } #endif -#if CALIB_SIGN_EN || CALIB_SIGN_ECC204_EN +#if CALIB_SIGN_EN || CALIB_SIGN_CA2_EN /** \brief ATCACommand Sign method * \param[in] ca_cmd instance * \param[in] packet pointer to the packet containing the command being built @@ -458,7 +476,7 @@ ATCA_STATUS atSign(ATCADeviceType device_type, ATCAPacket *packet) // Set the opcode & parameters packet->opcode = ATCA_SIGN; packet->txsize = SIGN_COUNT; - if (ECC204 == device_type) + if ((ECC204 == device_type) || (TA010 == device_type)) { packet->txsize += ATCA_SHA_DIGEST_SIZE; } @@ -527,7 +545,7 @@ ATCA_STATUS atVerify(ATCADeviceType device_type, ATCAPacket *packet) } #endif -#if CALIB_WRITE_EN || CALIB_WRITE_ECC204_EN +#if CALIB_WRITE_EN || CALIB_WRITE_CA2_EN /** \brief ATCACommand Write method * \param[in] ca_cmd instance * \param[in] packet pointer to the packet containing the command being built @@ -540,14 +558,14 @@ ATCA_STATUS atWrite(ATCADeviceType device_type, ATCAPacket *packet, bool has_mac packet->opcode = ATCA_WRITE; packet->txsize = 7; - if (ECC204 == device_type) + if (atcab_is_ca2_device(device_type)) { -#ifdef ATCA_ECC204_SUPPORT - if (ATCA_ECC204_ZONE_CONFIG == packet->param1) +#if ATCA_CA2_SUPPORT + if (ATCA_ZONE_CA2_CONFIG == packet->param1) { packet->txsize += 16; } - else if (ATCA_ECC204_ZONE_DATA == packet->param1) + else if (ATCA_ZONE_CA2_DATA == packet->param1) { packet->txsize += ATCA_BLOCK_SIZE; } @@ -757,6 +775,8 @@ bool atIsECCFamily(ATCADeviceType device_type) case ATECC608: /* fallthrough */ case ECC204: + /* fallthrough */ + case TA010: return true; break; default: diff --git a/lib/calib/calib_command.h b/lib/calib/calib_command.h index 37e8bc390..d3d57080c 100644 --- a/lib/calib/calib_command.h +++ b/lib/calib/calib_command.h @@ -105,6 +105,7 @@ typedef struct ATCA_STATUS atCheckMAC(ATCADeviceType device_type, ATCAPacket *packet); ATCA_STATUS atCounter(ATCADeviceType device_type, ATCAPacket *packet); +ATCA_STATUS atDelete(ATCADeviceType device_type, ATCAPacket *packet); ATCA_STATUS atDeriveKey(ATCADeviceType device_type, ATCAPacket *packet, bool has_mac); ATCA_STATUS atECDH(ATCADeviceType device_type, ATCAPacket *packet); ATCA_STATUS atGenDig(ATCADeviceType device_type, ATCAPacket *packet, bool is_no_mac_key); @@ -202,8 +203,8 @@ ATCA_STATUS atCheckCrc(const uint8_t *response); #define ATCA_KEY_COUNT (16) //!< number of keys #define ATCA_ECC_CONFIG_SIZE (128) //!< size of configuration zone #define ATCA_SHA_CONFIG_SIZE (88) //!< size of configuration zone -#define ATCA_ECC204_CONFIG_SIZE (64) //!< size of ECC204 configuration zone -#define ATCA_ECC204_CONFIG_SLOT_SIZE (16) //!< size of ECC204 configuration slot size +#define ATCA_CA2_CONFIG_SIZE (64) //!< size of ECC204 configuration zone +#define ATCA_CA2_CONFIG_SLOT_SIZE (16) //!< size of ECC204 configuration slot size #define ATCA_OTP_SIZE (64) //!< size of OTP zone #define ATCA_DATA_SIZE (ATCA_KEY_COUNT * ATCA_KEY_SIZE) //!< size of data zone #define ATCA_AES_GFM_SIZE ATCA_BLOCK_SIZE //!< size of GFM data @@ -327,7 +328,15 @@ ATCA_STATUS atCheckCrc(const uint8_t *response); #define COUNTER_RSP_SIZE ATCA_RSP_SIZE_4 //!< Counter command response packet size #define COUNTER_SIZE ATCA_RSP_SIZE_MIN //!< Counter size in binary -#define ECC204_COUNTER_MAX_VALUE ((uint16_t)10000) //!< Counter maximum value of the counter for ECC204 +#define COUNTER_MAX_VALUE_CA2 ((uint16_t)10000) //!< Counter maximum value of the counter for ECC204 +/** @} */ + +/** \name Definitions for the Delete command + @{ */ +#define DELETE_COUNT (39) +#define DELETE_MODE ((uint8_t)0x00) +#define DELETE_MAC_SIZE (32) +#define DELETE_NONCE_KEY_ID ((uint16_t)0x8000) /** @} */ /** \name Definitions for the DeriveKey Command @@ -419,7 +428,8 @@ ATCA_STATUS atCheckCrc(const uint8_t *response); #define INFO_MODE_REVISION ((uint8_t)0x00) //!< Info mode Revision #define INFO_MODE_KEY_VALID ((uint8_t)0x01) //!< Info mode KeyValid #define INFO_MODE_STATE ((uint8_t)0x02) //!< Info mode State -#define INFO_MODE_LOCK_STATUS ((uint8_t)0x02) //!< Info mode Lock status for ECC204 device +#define INFO_MODE_LOCK_STATUS ((uint8_t)0x02) //!< Info mode Lock status for ECC204,TA010 devices +#define INFO_MODE_CHIP_STATUS ((uint8_t)0xC5) //!< Info mode Chip status for ECC204,TA010 devices #define INFO_MODE_GPIO ((uint8_t)0x03) //!< Info mode GPIO #define INFO_MODE_VOL_KEY_PERMIT ((uint8_t)0x04) //!< Info mode GPIO #define INFO_MODE_MAX ((uint8_t)0x03) //!< Info mode maximum value @@ -492,8 +502,8 @@ ATCA_STATUS atCheckCrc(const uint8_t *response); #define LOCK_ZONE_CONFIG ((uint8_t)0x00) //!< Lock zone is Config #define LOCK_ZONE_DATA ((uint8_t)0x01) //!< Lock zone is OTP or Data #define LOCK_ZONE_DATA_SLOT ((uint8_t)0x02) //!< Lock slot of Data -#define LOCK_ECC204_ZONE_DATA ((uint8_t)0x00) //!< Lock ECC204 Data zone by slot -#define LOCK_ECC204_ZONE_CONFIG ((uint8_t)0x01) //!< Lock ECC204 configuration zone by slot +#define LOCK_ZONE_CA2_DATA ((uint8_t)0x00) //!< Lock second gen Data zone by slot +#define LOCK_ZONE_CA2_CONFIG ((uint8_t)0x01) //!< Lock second gen configuration zone by slot #define LOCK_ZONE_NO_CRC ((uint8_t)0x80) //!< Lock command: Ignore summary. #define LOCK_ZONE_MASK (0xBF) //!< Lock parameter 1 bits 6 are 0. #define ATCA_UNLOCKED (0x55) //!< Value indicating an unlocked zone @@ -630,7 +640,7 @@ ATCA_STATUS atCheckCrc(const uint8_t *response); #define SELFTEST_MODE_IDX ATCA_PARAM1_IDX //!< SelfTest command index for mode #define SELFTEST_COUNT ATCA_CMD_SIZE_MIN //!< SelfTest command packet size #define SELFTEST_MODE_RNG ((uint8_t)0x01) //!< SelfTest mode RNG DRBG function -#define SELFTEST_MODE_ECDSA_SIGN_VERIFY ((uint8_t)0x02) //!< SelfTest mode ECDSA verify function +#define SELFTEST_MODE_ECDSA_SIGN_VERIFY ((uint8_t)0x04) //!< SelfTest mode ECDSA verify function #define SELFTEST_MODE_ECDH ((uint8_t)0x08) //!< SelfTest mode ECDH function #define SELFTEST_MODE_AES ((uint8_t)0x10) //!< SelfTest mode AES encrypt function #define SELFTEST_MODE_SHA ((uint8_t)0x20) //!< SelfTest mode SHA function diff --git a/lib/calib/calib_config_check.h b/lib/calib/calib_config_check.h index 25fb698cb..32239b46f 100644 --- a/lib/calib/calib_config_check.h +++ b/lib/calib/calib_config_check.h @@ -55,11 +55,17 @@ #define CALIB_ECC204_EN DEFAULT_ENABLED #endif +#ifdef ATCA_TA010_SUPPORT +#define CALIB_TA010_EN DEFAULT_ENABLED +#endif + /* Helper macros */ #define CALIB_FULL_FEATURE (CALIB_SHA204_EN || CALIB_ECC108_EN || CALIB_ECC508_EN || CALIB_ECC608_EN) -#define CALIB_ECC_SUPPORT (CALIB_ECC108_EN || CALIB_ECC508_EN || CALIB_ECC608_EN || CALIB_ECC204_EN) +#define CALIB_ECC_SUPPORT (CALIB_ECC108_EN || CALIB_ECC508_EN || CALIB_ECC608_EN || CALIB_ECC204_EN || CALIB_TA010_EN) +#define CALIB_CA2_SUPPORT (CALIB_ECC204_EN || CALIB_TA010_EN) #define CALIB_ECC204_ONLY (CALIB_ECC204_EN && !(CALIB_FULL_FEATURE || CALIB_SHA206_EN)) -#define CALIB_SHA206_ONLY (CALIB_SHA206_EN && !(CALIB_FULL_FEATURE || CALIB_ECC204_EN)) +#define CALIB_TA010_ONLY (CALIB_TA010_EN && !(CALIB_FULL_FEATURE || CALIB_SHA206_EN)) +#define CALIB_SHA206_ONLY (CALIB_SHA206_EN && !(CALIB_FULL_FEATURE || ATCA_CA2_SUPPORT)) /**** AES command ****/ @@ -120,6 +126,18 @@ **/ #ifndef CALIB_COUNTER_EN #define CALIB_COUNTER_EN (ATCAB_COUNTER_EN && CALIB_ECC_SUPPORT) +#endif + + /***** DELETE command *****/ + +/** \def CALIB_DELETE + * + * Enable CALIB_DELETE to clear all of the Data zone slots and set all bytes of each slot to 0xFF + * + * Supported API's: calib_delete + **/ +#ifndef CALIB_DELETE_EN +#define CALIB_DELETE_EN (DEFAULT_DISABLED) #endif /***** DERIVEKEY command ******/ @@ -264,14 +282,14 @@ #define CALIB_LOCK_EN (ATCAB_LOCK_EN && CALIB_FULL_FEATURE) #endif -/** \def CALIB_LOCK_ECC204_EN +/** \def CALIB_LOCK_CA2_EN * - * Enable CALIB_LOCK_ECC204_EN which enables the lock command for the ecc204 device + * Enable CALIB_LOCK_CA2_EN which enables the lock command for the ecc204 and ta010 devices * * Supported API's: calib_lock **/ -#ifndef CALIB_LOCK_ECC204_EN -#define CALIB_LOCK_ECC204_EN (ATCAB_LOCK_EN && CALIB_ECC204_EN) +#ifndef CALIB_LOCK_CA2_EN +#define CALIB_LOCK_CA2_EN (ATCAB_LOCK_EN && ATCA_CA2_SUPPORT) #endif /****** MAC command ******/ @@ -299,7 +317,7 @@ * Supported API's: calib_nonce_base **/ #ifndef CALIB_NONCE_EN -#define CALIB_NONCE_EN (ATCAB_NONCE_EN && (CALIB_FULL_FEATURE || CALIB_ECC204_EN)) +#define CALIB_NONCE_EN (ATCAB_NONCE_EN && (CALIB_FULL_FEATURE || CALIB_CA2_SUPPORT)) #endif /**** PRIVWRITE COMMAND ****/ @@ -356,10 +374,10 @@ * * Supported API's: calib_read_zone * - * Supported ECC204 specific API's: calib_ecc204_read_zone + * Supported ECC204 specific API's: calib_ca2_read_zone **/ -#ifndef CALIB_READ_ECC204_EN -#define CALIB_READ_ECC204_EN (ATCAB_READ_EN && CALIB_ECC204_EN) +#ifndef CALIB_READ_CA2_EN +#define CALIB_READ_CA2_EN (ATCAB_READ_EN && CALIB_CA2_SUPPORT) #endif /** \def CALIB_READ_ENC @@ -426,7 +444,7 @@ * Supported API's: calib_selftest **/ #ifndef CALIB_SELFTEST_EN -#define CALIB_SELFTEST_EN (ATCAB_SELFTEST_EN && (CALIB_ECC608_EN || CALIB_ECC204_EN)) +#define CALIB_SELFTEST_EN (ATCAB_SELFTEST_EN && (CALIB_ECC608_EN || CALIB_CA2_SUPPORT)) #endif /****** SHA command ******/ @@ -439,7 +457,7 @@ * Supported API's: calib_sha_base **/ #ifndef CALIB_SHA_EN -#define CALIB_SHA_EN (ATCAB_SHA_EN && (CALIB_FULL_FEATURE || CALIB_ECC204_EN)) +#define CALIB_SHA_EN (ATCAB_SHA_EN && (CALIB_FULL_FEATURE || CALIB_CA2_SUPPORT)) #endif /** \def CALIB_SHA_HMAC_EN @@ -481,15 +499,15 @@ #define CALIB_SIGN_EN (ATCAB_SIGN_EN && (CALIB_ECC108_EN || CALIB_ECC508_EN || CALIB_ECC608_EN)) #endif -/** \def CALIB_SIGN_ECC204_EN +/** \def CALIB_SIGN_CA2_EN * - * Enable CALIB_SIGN_ECC204_EN to generate a signature using the ECDSA algorithm + * Enable CALIB_SIGN_CA2_EN to generate a signature using the ECDSA algorithm * * Supported API's: calib_sign_base * **/ -#ifndef CALIB_SIGN_ECC204_EN -#define CALIB_SIGN_ECC204_EN (ATCAB_SIGN_EN && CALIB_ECC204_EN) +#ifndef CALIB_SIGN_CA2_EN +#define CALIB_SIGN_CA2_EN (ATCAB_SIGN_EN && (CALIB_ECC204_EN || CALIB_TA010_EN)) #endif /** \def CALIB_SIGN_MODE_ENCODING @@ -603,7 +621,7 @@ * * Supported API's: calib_write * - * Supported ECC204 specific API's: calib_ecc204_write + * Supported ECC204 specific API's: calib_ca2_write **/ #ifndef CALIB_WRITE_EN #define CALIB_WRITE_EN (ATCAB_WRITE_EN && (CALIB_FULL_FEATURE || CALIB_SHA206_EN)) @@ -625,8 +643,6 @@ * Performs an encrypted write of a 32 byte block into given slot * * Supported API's: calib_write_enc - * - * Supported ECC204 specific API's: calib_ecc204_write_enc **/ #ifndef CALIB_WRITE_ENC_EN #define CALIB_WRITE_ENC_EN (ATCAB_WRITE_ENC_EN && CALIB_FULL_FEATURE) @@ -639,23 +655,12 @@ * * Supported API's: calib_write * - * Supported ECC204 specific API's: calib_ecc204_write + * Supported ECC204 specific API's: calib_ca2_write **/ -#ifndef CALIB_WRITE_ECC204_EN -#define CALIB_WRITE_ECC204_EN (ATCAB_WRITE_EN && CALIB_ECC204_EN) +#ifndef CALIB_WRITE_CA2_EN +#define CALIB_WRITE_CA2_EN (ATCAB_WRITE_EN && CALIB_CA2_SUPPORT) #endif -/** \def ATCAB_WRITE_EN - * - * Enable CALIB_WRITE_ENC_ECC204_EN to enable encrypted writes to the ECC204 device - only - * used for provisioning activities - * - **/ -#ifndef CALIB_WRITE_ENC_ECC204_EN -#define CALIB_WRITE_ENC_ECC204_EN (ATCAB_WRITE_ENC_EN && CALIB_WRITE_ECC204_EN && CALIB_NONCE_EN) -#endif - - /* Check host side configuration for missing components */ /* Check for any commands that require a sha implementation */ diff --git a/lib/calib/calib_counter.c b/lib/calib/calib_counter.c index 0471c789c..2353b06e8 100644 --- a/lib/calib/calib_counter.c +++ b/lib/calib/calib_counter.c @@ -75,9 +75,9 @@ ATCA_STATUS calib_counter(ATCADevice device, uint8_t mode, uint16_t counter_id, { if (packet.data[ATCA_COUNT_IDX] == 7) { - if (ECC204 == device->mIface.mIfaceCFG->devtype) + if (atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype)) { - #if defined(ATCA_ECC204_SUPPORT) + #if ATCA_CA2_SUPPORT *counter_value = ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 3] << 0) | ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 2] << 8) | ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 1] << 16) | @@ -126,4 +126,4 @@ ATCA_STATUS calib_counter_read(ATCADevice device, uint16_t counter_id, uint32_t* { return calib_counter(device, COUNTER_MODE_READ, counter_id, counter_value); } -#endif /* CALIB_COUNTER_EN */ \ No newline at end of file +#endif /* CALIB_COUNTER_EN */ diff --git a/lib/calib/calib_delete.c b/lib/calib/calib_delete.c new file mode 100644 index 000000000..ea996c8ae --- /dev/null +++ b/lib/calib/calib_delete.c @@ -0,0 +1,132 @@ +/** + * \file + * \brief CryptoAuthLib Basic API methods for Delete command. + * + * The Delete command, when executed, will clear all of the Data zone slots and set + * all bytes of each slot to 0xFF.The Configuration zone will be untouched, except for the + * value of the Primary_Deleted byte. + * + * \note List of devices that support this command - ECC204, TA010, SHA104, SHA105.Refer to device datasheets for full details. + * + * \copyright (c) 2015-2020 Microchip Technology Inc. and its subsidiaries. + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip software + * and any derivatives exclusively with Microchip products. It is your + * responsibility to comply with third party license terms applicable to your + * use of third party software (including open source software) that may + * accompany Microchip software. + * + * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED + * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A + * PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, + * SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE + * OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + * MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + * FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL + * LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED + * THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR + * THIS SOFTWARE. + */ + +#include "cryptoauthlib.h" + +#include "host/atca_host.h" + +#if CALIB_DELETE_EN +/** \brief Clears all Data zone slots and all the bytes of each slot is set to 0xFF.The + * Configuration zone will be untouched, except for the value of the Primary_Deleted byte. + * + * Note: After the Delete command is run, the device will no longer be functional. Only the + * Info command can be run successfully + * + * \param[in] device Device context pointer + * \param[in] mode Mode must be 0x00 + * \param[in] key_id Key id must be 0x0000 + * \param[in] mac MAC value + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS calib_delete_base(ATCADevice device, uint8_t mode, uint16_t key_id, const uint8_t* mac) +{ + ATCAPacket packet; + ATCA_STATUS status = ATCA_GEN_FAIL; + + // Verify the inputs + if ((device == NULL) || (mac == NULL)) + { + return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer received"); + } + + do + { + // build Delete command + packet.param1 = mode; + packet.param2 = key_id; + + memcpy(&packet.data[0], mac, DELETE_MAC_SIZE); + + (void)atDelete(atcab_get_device_type_ext(device), &packet); + + if ((status = atca_execute_command( (void*)&packet, device)) != ATCA_SUCCESS) + { + ATCA_TRACE(status, "calib_delete - execution failed"); + break; + } + } + while (0); + + return status; +} + +/** \brief Runs Nonce Command, calculates mac and performs delete operation + * + * \param[in] device Device context pointer + * \param[in] num_in Input value from the system + * \param[in] key Key input (HMAC/Secret Key) + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS calib_delete(ATCADevice device, uint8_t num_in[NONCE_NUMIN_SIZE], const uint8_t *key) +{ + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t serial_number[ATCA_SERIAL_NUM_SIZE] = { 0 }; + uint8_t rand_out[RANDOM_NUM_SIZE] = { 0 }; + atca_delete_in_out_t delete_mac_params; + uint8_t mac[DELETE_MAC_SIZE] = { 0 }; + + do + { + // Read device serial number + if (ATCA_SUCCESS != (status = atcab_read_serial_number(serial_number))) + { + ATCA_TRACE(status, "Read serial number failed"); + break; + } + + // Generate random + if (ATCA_SUCCESS != (status = calib_nonce_gen_session_key(device, DELETE_NONCE_KEY_ID, num_in, rand_out))) + { + ATCA_TRACE(status, "calib_nonce_gen_session_key - failed"); + break; + } + + // Calculate host side mac for delete operation + memset(&delete_mac_params, 0, sizeof(delete_mac_params)); + delete_mac_params.key_id = (uint16_t)0x0000; + delete_mac_params.sn = serial_number; + delete_mac_params.key = key; + delete_mac_params.nonce = rand_out; + delete_mac_params.mac = mac; + + if ((status = atcah_delete_mac(&delete_mac_params)) != ATCA_SUCCESS) + { + ATCA_TRACE(status, "Delete Mac failed"); + break; + } + } + while (0); + + return calib_delete_base(device, DELETE_MODE, (uint16_t)0x0000, mac); +} +#endif /* CALIB_DELETE */ \ No newline at end of file diff --git a/lib/calib/calib_execution.c b/lib/calib/calib_execution.c index dd2e7ccd5..3488315ab 100644 --- a/lib/calib/calib_execution.c +++ b/lib/calib/calib_execution.c @@ -265,6 +265,8 @@ ATCA_STATUS calib_get_execution_time(uint8_t opcode, ATCADevice device) break; #endif + case TA010: + /* fallthrough */ case ECC204: execution_times = device_execution_time_ecc204; no_of_commands = sizeof(device_execution_time_ecc204) / sizeof(device_execution_time_t); @@ -369,7 +371,7 @@ ATCA_STATUS calib_execute_receive(ATCADevice device, uint8_t device_address, uin } // Skip word address send for ECC204 device - if (ECC204 != device->mIface.mIfaceCFG->devtype) + if (!atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype)) { if (ATCA_SUCCESS != (status = atsend(&device->mIface, device_address, &word_address, sizeof(word_address)))) { @@ -456,9 +458,8 @@ ATCA_STATUS calib_execute_command(ATCAPacket* packet, ATCADevice device) execution_or_wait_time = ATCA_POLLING_INIT_TIME_MSEC; max_delay_count = ATCA_POLLING_MAX_TIME_MSEC / ATCA_POLLING_FREQUENCY_TIME_MSEC; - #if defined(ATCA_ECC204_SUPPORT) || defined(ATCA_TA010_SUPPORT) - if ((ATCA_SWI_GPIO_IFACE == device->mIface.mIfaceCFG->iface_type) && ((ECC204 == device->mIface.mIfaceCFG->devtype) || - (TA010 == device->mIface.mIfaceCFG->devtype))) + #if ATCA_CA2_SUPPORT + if ((ATCA_SWI_GPIO_IFACE == device->mIface.mIfaceCFG->iface_type) && (atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype))) { if ((status = calib_get_execution_time(packet->opcode, device)) != ATCA_SUCCESS) { @@ -489,10 +490,12 @@ ATCA_STATUS calib_execute_command(ATCAPacket* packet, ATCADevice device) { packet->_reserved = CALIB_SWI_FLAG_CMD; } - else if ((ATCA_SWI_GPIO_IFACE == device->mIface.mIfaceCFG->iface_type) && (ECC204 == device->mIface.mIfaceCFG->devtype)) + #if ATCA_CA2_SUPPORT + else if ((ATCA_SWI_GPIO_IFACE == device->mIface.mIfaceCFG->iface_type) && (atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype))) { packet->_reserved = 0x03; } + #endif if (ATCA_RX_NO_RESPONSE == (status = calib_execute_send(device, device_address, (uint8_t*)packet, packet->txsize + 1))) { device->device_state = ATCA_DEVICE_STATE_UNKNOWN; @@ -567,7 +570,7 @@ ATCA_STATUS calib_execute_command(ATCAPacket* packet, ATCADevice device) while (0); // Skip Idle for ECC204 device - if (ECC204 != device->mIface.mIfaceCFG->devtype) + if (!atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype)) { (void)calib_idle(device); device->device_state = ATCA_DEVICE_STATE_IDLE; diff --git a/lib/calib/calib_helpers.c b/lib/calib/calib_helpers.c index db644675f..7cd6f33bd 100644 --- a/lib/calib/calib_helpers.c +++ b/lib/calib/calib_helpers.c @@ -107,28 +107,9 @@ ATCA_STATUS calib_is_locked(ATCADevice device, uint8_t zone, bool* is_locked) return status; } - -ATCA_STATUS calib_is_locked_ext(ATCADevice device, uint8_t zone, bool* is_locked) -{ -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) - { - if (LOCK_ZONE_DATA == zone) - { - zone = ATCA_ZONE_DATA; - } - return calib_ecc204_is_locked(device, zone, is_locked); - } - else -#endif - { - return calib_is_locked(device, zone, is_locked); - } -} - #endif /* CALIB_READ_EN */ -#if defined(ATCA_ECC204_SUPPORT) +#if ATCA_CA2_SUPPORT /** \brief Use Info command to check ECC204 Config zone lock status * * \param[in] device Device context pointer @@ -136,7 +117,7 @@ ATCA_STATUS calib_is_locked_ext(ATCADevice device, uint8_t zone, bool* is_locked * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_is_config_locked(ATCADevice device, bool* is_locked) +ATCA_STATUS calib_ca2_is_config_locked(ATCADevice device, bool* is_locked) { ATCA_STATUS status = ATCA_SUCCESS; uint16_t param2; @@ -149,7 +130,7 @@ ATCA_STATUS calib_ecc204_is_config_locked(ATCADevice device, bool* is_locked) while (slot <= 3) { - param2 = ATCA_ECC204_ZONE_CONFIG | (slot << 1); + param2 = ATCA_ZONE_CA2_CONFIG | (slot << 1); if (ATCA_SUCCESS != (status = calib_info_lock_status(device, param2, (uint8_t*)is_locked))) { *is_locked = false; @@ -176,7 +157,7 @@ ATCA_STATUS calib_ecc204_is_config_locked(ATCADevice device, bool* is_locked) * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_is_data_locked(ATCADevice device, bool* is_locked) +ATCA_STATUS calib_ca2_is_data_locked(ATCADevice device, bool* is_locked) { ATCA_STATUS status = ATCA_SUCCESS; uint16_t param2; @@ -189,7 +170,7 @@ ATCA_STATUS calib_ecc204_is_data_locked(ATCADevice device, bool* is_locked) while (slot <= 3) { - param2 = ATCA_ECC204_ZONE_DATA | (slot << 1); + param2 = ATCA_ZONE_CA2_DATA | (slot << 1); if (ATCA_SUCCESS != (status = calib_info_lock_status(device, param2, (uint8_t*)is_locked))) { *is_locked = false; @@ -217,17 +198,17 @@ ATCA_STATUS calib_ecc204_is_data_locked(ATCADevice device, bool* is_locked) * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_is_locked(ATCADevice device, uint8_t zone, bool* is_locked) +ATCA_STATUS calib_ca2_is_locked(ATCADevice device, uint8_t zone, bool* is_locked) { ATCA_STATUS status = ATCA_SUCCESS; if (ATCA_ZONE_CONFIG == zone) { - status = calib_ecc204_is_config_locked(device, is_locked); + status = calib_ca2_is_config_locked(device, is_locked); } else if (ATCA_ZONE_DATA == zone) { - status = calib_ecc204_is_data_locked(device, is_locked); + status = calib_ca2_is_data_locked(device, is_locked); } else { @@ -239,6 +220,34 @@ ATCA_STATUS calib_ecc204_is_locked(ATCADevice device, uint8_t zone, bool* is_loc #endif +#if CALIB_READ_EN || CALIB_READ_CA2_EN + +ATCA_STATUS calib_is_locked_ext(ATCADevice device, uint8_t zone, bool* is_locked) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + + if (atcab_is_ca2_device(device_type)) + { + if (LOCK_ZONE_DATA == zone) + { + zone = ATCA_ZONE_DATA; + } + status = calib_ca2_is_locked(device, zone, is_locked); + } + else +#endif + { +#if CALIB_READ_EN + status = calib_is_locked(device, zone, is_locked); +#endif + } + + return status; +} + /** \brief Check if a slot is a private key * * \param[in] device Device context pointer @@ -271,8 +280,10 @@ ATCA_STATUS calib_is_private(ATCADevice device, uint16_t slot, bool* is_private) break; } #endif -#ifdef ATCA_ECC204_SUPPORT +#if ATCA_CA2_SUPPORT case ECC204: + /* fallthrough */ + case TA010: *is_private = (0 == slot) ? true : false; break; #endif @@ -285,6 +296,8 @@ ATCA_STATUS calib_is_private(ATCADevice device, uint16_t slot, bool* is_private) return status; } +#endif + /** \brief Parse the revision field to get the device type */ ATCADeviceType calib_get_devicetype(uint8_t revision[4]) { @@ -306,7 +319,9 @@ ATCADeviceType calib_get_devicetype(uint8_t revision[4]) ret = ATECC608; break; case 0x20: - ret = ECC204; + #if ATCA_CA2_SUPPORT + ret = calib_get_devicetype_with_device_id(revision[1], revision[3]); + #endif break; case 0x40: ret = ATSHA206A; @@ -316,3 +331,32 @@ ATCADeviceType calib_get_devicetype(uint8_t revision[4]) } return ret; } + +#if ATCA_CA2_SUPPORT +ATCADeviceType calib_get_devicetype_with_device_id(uint8_t device_id,uint8_t device_revision) +{ + ATCADeviceType device_type; + + if (device_revision == 0x00) + { + device_type = ECC204; + } + else + { + switch(device_id) + { + case ATCA_ECC204_DEVICE_ID: + device_type = ECC204; + break; + case ATCA_TA010_DEVICE_ID: + device_type = TA010; + break; + default: + device_type = ATCA_DEV_UNKNOWN; + break; + } + } + + return device_type; +} +#endif diff --git a/lib/calib/calib_info.c b/lib/calib/calib_info.c index 180717c16..bf28b1a1b 100644 --- a/lib/calib/calib_info.c +++ b/lib/calib/calib_info.c @@ -72,10 +72,10 @@ ATCA_STATUS calib_info_base(ATCADevice device, uint8_t mode, uint16_t param2, ui if ((status = atca_execute_command(&packet, device)) != ATCA_SUCCESS) { - // For ECC204, Lock status and Key valid modes return their status in first byte. + // For ECC204,TA010 Lock status and Key valid modes return their status in first byte. // So, need to consider 01 as valid response as it presents lock/keyvalid status. if (((INFO_MODE_LOCK_STATUS == mode) || (INFO_MODE_KEY_VALID == mode)) - && (ECC204 == device->mIface.mIfaceCFG->devtype)) + && (atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype))) { if (status == ATCA_CHECKMAC_VERIFY_FAILED) { @@ -94,7 +94,7 @@ ATCA_STATUS calib_info_base(ATCADevice device, uint8_t mode, uint16_t param2, ui if (response && out_data) { if (((INFO_MODE_LOCK_STATUS == mode) || (INFO_MODE_KEY_VALID == mode)) - && (ECC204 == device->mIface.mIfaceCFG->devtype)) + && (atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype))) { memcpy(out_data, &packet.data[ATCA_RSP_DATA_IDX], 1); } @@ -180,7 +180,7 @@ ATCA_STATUS calib_info_set_latch(ATCADevice device, bool state) * * \param[in] device Device context pointer * \param[in] key_id ECC private key slot id - * For ECC204, key_id is 0x00 + * For ECC204,TA010 key_id is 0x00 * \param[out] is_valid return private key is valid or invalid * * \return ATCA_SUCCESS on success, otherwise an error code. @@ -190,8 +190,8 @@ ATCA_STATUS calib_info_privkey_valid(ATCADevice device, uint16_t key_id, uint8_t return calib_info_base(device, INFO_MODE_KEY_VALID, key_id, is_valid); } -#ifdef ATCA_ECC204_SUPPORT -/** \brief Use Info command to ECC204 config/data zone lock status +#if ATCA_CA2_SUPPORT +/** \brief Use Info command to ECC204,TA010 config/data zone lock status * * \param[in] device Device context pointer * \param[in] param2 selects the zone and slot @@ -203,4 +203,16 @@ ATCA_STATUS calib_info_lock_status(ATCADevice device, uint16_t param2, uint8_t* { return calib_info_base(device, INFO_MODE_LOCK_STATUS, param2, is_locked); } -#endif /* ATCA_ECC204_SUPPORT */ + +/** \brief Use Info command to get ECC204,TA010 chip status + * + * \param[in] device Device context pointer + * \param[out] chip_status return chip status here + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS calib_info_chip_status(ATCADevice device, uint8_t* chip_status) +{ + return calib_info_base(device, INFO_MODE_CHIP_STATUS, (uint16_t)0x00, chip_status); +} +#endif diff --git a/lib/calib/calib_lock.c b/lib/calib/calib_lock.c index 04f27b9c2..cce9bdd45 100644 --- a/lib/calib/calib_lock.c +++ b/lib/calib/calib_lock.c @@ -35,7 +35,7 @@ #include "cryptoauthlib.h" -#if CALIB_LOCK_EN || CALIB_LOCK_ECC204_EN +#if CALIB_LOCK_EN || CALIB_LOCK_CA2_EN /** \brief The Lock command prevents future modifications of the Configuration * and/or Data and OTP zones. If the device is so configured, then * this command can be used to lock individual data slots. This @@ -82,9 +82,7 @@ ATCA_STATUS calib_lock(ATCADevice device, uint8_t mode, uint16_t summary_crc) return status; } -#endif -#if CALIB_LOCK_EN /** \brief Unconditionally (no CRC required) lock the config zone. * * \param[in] device Device context pointer @@ -92,17 +90,23 @@ ATCA_STATUS calib_lock(ATCADevice device, uint8_t mode, uint16_t summary_crc) */ ATCA_STATUS calib_lock_config_zone(ATCADevice device) { -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) { - return calib_ecc204_lock_config_zone(device); + status = calib_ca2_lock_config_zone(device); } else #endif { - return calib_lock(device, LOCK_ZONE_NO_CRC | LOCK_ZONE_CONFIG, 0); +#if CALIB_LOCK_EN + status = calib_lock(device, LOCK_ZONE_NO_CRC | LOCK_ZONE_CONFIG, 0); +#endif } + return status; } /** \brief Lock the config zone with summary CRC. @@ -118,8 +122,10 @@ ATCA_STATUS calib_lock_config_zone(ATCADevice device) */ ATCA_STATUS calib_lock_config_zone_crc(ATCADevice device, uint16_t summary_crc) { -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + + if(atcab_is_ca2_device(device_type)) { return ATCA_UNIMPLEMENTED; } @@ -139,16 +145,23 @@ ATCA_STATUS calib_lock_config_zone_crc(ATCADevice device, uint16_t summary_crc) */ ATCA_STATUS calib_lock_data_zone(ATCADevice device) { -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) { - return calib_ecc204_lock_data_zone(device); + status = calib_ca2_lock_data_zone(device); } else #endif { - return calib_lock(device, LOCK_ZONE_NO_CRC | LOCK_ZONE_DATA, 0); +#if CALIB_LOCK_EN + status = calib_lock(device, LOCK_ZONE_NO_CRC | LOCK_ZONE_DATA, 0); +#endif } + + return status; } /** \brief Lock the data zone (slots and OTP) with summary CRC. @@ -164,8 +177,10 @@ ATCA_STATUS calib_lock_data_zone(ATCADevice device) */ ATCA_STATUS calib_lock_data_zone_crc(ATCADevice device, uint16_t summary_crc) { -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + + if (atcab_is_ca2_device(device_type)) { return ATCA_UNIMPLEMENTED; } @@ -187,20 +202,26 @@ ATCA_STATUS calib_lock_data_zone_crc(ATCADevice device, uint16_t summary_crc) */ ATCA_STATUS calib_lock_data_slot(ATCADevice device, uint16_t slot) { -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + if (atcab_is_ca2_device(atcab_get_device_type_ext(device))) { - return calib_ecc204_lock_data_slot(device, slot); + status = calib_ca2_lock_data_slot(device, slot); } else #endif { - return calib_lock(device, ((uint8_t)slot << 2) | LOCK_ZONE_DATA_SLOT, 0); +#if CALIB_LOCK_EN + status = calib_lock(device, ((uint8_t)slot << 2) | LOCK_ZONE_DATA_SLOT, 0); +#endif } + + return status; } #endif -#if CALIB_LOCK_ECC204_EN +#if CALIB_LOCK_CA2_EN /** \brief Use Lock command to lock individual configuration zone slots * * \param[in] device Device context pointer @@ -210,9 +231,9 @@ ATCA_STATUS calib_lock_data_slot(ATCADevice device, uint16_t slot) * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_lock_config_slot(ATCADevice device, uint16_t slot, uint16_t summary_crc) +ATCA_STATUS calib_ca2_lock_config_slot(ATCADevice device, uint16_t slot, uint16_t summary_crc) { - uint8_t mode = (uint8_t)(LOCK_ECC204_ZONE_CONFIG | (slot << 1)); + uint8_t mode = (uint8_t)(LOCK_ZONE_CA2_CONFIG | (slot << 1)); if (!summary_crc) { @@ -228,7 +249,7 @@ ATCA_STATUS calib_ecc204_lock_config_slot(ATCADevice device, uint16_t slot, uint * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_lock_config_zone(ATCADevice device) +ATCA_STATUS calib_ca2_lock_config_zone(ATCADevice device) { ATCA_STATUS status = ATCA_GEN_FAIL; uint8_t slot = 0; @@ -236,11 +257,11 @@ ATCA_STATUS calib_ecc204_lock_config_zone(ATCADevice device) while (slot <= 3) { - mode = (uint8_t)(LOCK_ZONE_NO_CRC | LOCK_ECC204_ZONE_CONFIG | (slot << 1)); + mode = (uint8_t)(LOCK_ZONE_NO_CRC | LOCK_ZONE_CA2_CONFIG | (slot << 1)); if (ATCA_SUCCESS != (status = calib_lock(device, mode, 0))) { - // ECC204 returns execution error if slot is already locked. + // ECC204,TA010 returns execution error if slot is already locked. // Consider already locked status as valid while locking the config zone. if (status == ATCA_EXECUTION_ERROR) { @@ -248,7 +269,7 @@ ATCA_STATUS calib_ecc204_lock_config_zone(ATCADevice device) } else { - ATCA_TRACE(status, "calib_ecc204_lock_config_zone - failed"); + ATCA_TRACE(status, "calib_ca2_lock_config_zone - failed"); break; } } @@ -266,9 +287,9 @@ ATCA_STATUS calib_ecc204_lock_config_zone(ATCADevice device) * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_lock_data_slot(ATCADevice device, uint16_t slot) +ATCA_STATUS calib_ca2_lock_data_slot(ATCADevice device, uint16_t slot) { - return calib_lock(device, (uint8_t)(LOCK_ECC204_ZONE_DATA | (slot << 1)), 0); + return calib_lock(device, (uint8_t)(LOCK_ZONE_CA2_DATA | (slot << 1)), 0); } /** \brief Use lock command to lock complete Data zone @@ -277,7 +298,7 @@ ATCA_STATUS calib_ecc204_lock_data_slot(ATCADevice device, uint16_t slot) * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_lock_data_zone(ATCADevice device) +ATCA_STATUS calib_ca2_lock_data_zone(ATCADevice device) { ATCA_STATUS status = ATCA_GEN_FAIL; uint8_t slot = 0; @@ -285,11 +306,11 @@ ATCA_STATUS calib_ecc204_lock_data_zone(ATCADevice device) while (slot <= 3) { - mode = LOCK_ZONE_NO_CRC | LOCK_ECC204_ZONE_DATA | (slot << 1); + mode = LOCK_ZONE_NO_CRC | LOCK_ZONE_CA2_DATA | (slot << 1); if (ATCA_SUCCESS != (status = calib_lock(device, mode, 0))) { - // ECC204 returns execution error if slot is already locked. + // ECC204,TA010 returns execution error if slot is already locked. // Consider already locked status as valid while locking the config zone. if (status == ATCA_EXECUTION_ERROR) { @@ -297,7 +318,7 @@ ATCA_STATUS calib_ecc204_lock_data_zone(ATCADevice device) } else { - ATCA_TRACE(status, "calib_ecc204_lock_data_zone - failed"); + ATCA_TRACE(status, "calib_ca2_lock_data_zone - failed"); break; } } diff --git a/lib/calib/calib_nonce.c b/lib/calib/calib_nonce.c index c704a7b68..303ff5563 100644 --- a/lib/calib/calib_nonce.c +++ b/lib/calib/calib_nonce.c @@ -44,7 +44,7 @@ * write. * \param[in] param2 Param2, normally 0, but can be used to indicate a * nonce calculation mode (bit 15). - * For ECC204, represent tarnsport key id greater than + * For ECC204,TA010, represent tarnsport key id greater than * or equal to 0x8000 * \param[in] num_in Input value to either be included in the nonce * calculation in random modes (20 bytes) or to be @@ -219,7 +219,7 @@ ATCA_STATUS calib_challenge_seed_update(ATCADevice device, const uint8_t *num_in } /** \brief Use Nonce command to generate session key for use by a subsequent write command - * This Mode only supports in ECC204 device. + * This Mode only supports in ECC204,TA010 devices. * \param[in] device Device context pointer * \param[in] param2 Key id points to transport key * \param[in] num_in Input value from host system diff --git a/lib/calib/calib_read.c b/lib/calib/calib_read.c index a7c2d13af..e61babe66 100644 --- a/lib/calib/calib_read.c +++ b/lib/calib/calib_read.c @@ -138,28 +138,6 @@ ATCA_STATUS calib_read_serial_number(ATCADevice device, uint8_t* serial_number) return status; } - -/** \brief Executes Read command, which reads the 9 byte serial number of the - * device from the config zone. - * - * \param[in] device Device context pointer - * \param[out] serial_number 9 byte serial number is returned here. - * - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS calib_read_serial_number_ext(ATCADevice device, uint8_t* serial_number) -{ -#if CALIB_ECC204_EN - if (ECC204 == atcab_get_device_type_ext(device)) - { - return calib_ecc204_read_serial_number(device, serial_number); - } - else -#endif - { - return calib_read_serial_number(device, serial_number); - } -} #endif #if CALIB_READ_ENC_EN @@ -398,37 +376,6 @@ ATCA_STATUS calib_read_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot return status; } -/** \brief Used to read an arbitrary number of bytes from any zone configured - * for clear reads. - * - * This function will issue the Read command as many times as is required to - * read the requested data. - * - * \param[in] device Device context pointer - * \param[in] zone Zone to read data from. Option are ATCA_ZONE_CONFIG(0), - * ATCA_ZONE_OTP(1), or ATCA_ZONE_DATA(2). - * \param[in] slot Slot number to read from if zone is ATCA_ZONE_DATA(2). - * Ignored for all other zones. - * \param[in] offset Byte offset within the zone to read from. - * \param[out] data Read data is returned here. - * \param[in] length Number of bytes to read starting from the offset. - * - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS calib_read_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset, uint8_t *data, size_t length) -{ -#if CALIB_ECC204_EN - if (ECC204 == atcab_get_device_type_ext(device)) - { - return calib_ecc204_read_bytes_zone(device, zone, slot, offset, data, length); - } - else -#endif - { - return calib_read_bytes_zone(device, zone, slot, offset, data, length); - } -} - /** \brief Compares a specified configuration zone with the configuration zone * currently on the SHA device. * @@ -514,9 +461,58 @@ bool calib_ecc608_compare_config( return same; } +/** \brief Executes Read command to read a 64 byte ECDSA P256 signature from a + * slot configured for clear reads. + * + * \param[in] device Device context pointer + * \param[in] slot Slot number to read from. Only slots 8 to 15 are large + * enough for a signature. + * \param[out] sig Signature will be returned here (64 bytes). Format will be + * the 32 byte R and S big-endian integers concatenated. + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS calib_read_sig(ATCADevice device, uint16_t slot, uint8_t* sig) +{ + ATCA_STATUS status = ATCA_GEN_FAIL; + + do + { + // Check the value of the slot + if (sig == NULL) + { + status = ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer received"); + break; + } + + if (slot < 8 || slot > 15) + { + status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid slot received"); + break; + } + + // Read the first block + if ((status = calib_read_zone_ext(device, ATCA_ZONE_DATA, slot, 0, 0, &sig[0], ATCA_BLOCK_SIZE)) != ATCA_SUCCESS) + { + ATCA_TRACE(status, "calib_read_zone - failed"); + break; + } + + // Read the second block + if ((status = calib_read_zone_ext(device, ATCA_ZONE_DATA, slot, 1, 0, &sig[ATCA_BLOCK_SIZE], ATCA_BLOCK_SIZE)) != ATCA_SUCCESS) + { + ATCA_TRACE(status, "calib_read_zone - failed"); + break; + } + } + while (0); + + return status; +} + #endif /* CALIB_READ_EN */ -#if CALIB_READ_ECC204_EN +#if CALIB_READ_CA2_EN /** \brief Use Read command to reads words 16 bytes from one of the slots in the EEPROM Configuration * zone or 32 bytes in Data zone. * @@ -531,7 +527,7 @@ bool calib_ecc608_compare_config( * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, size_t offset, +ATCA_STATUS calib_ca2_read_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, size_t offset, uint8_t* data, uint8_t len) { ATCA_STATUS status = ATCA_SUCCESS; @@ -541,14 +537,14 @@ ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint16_t slo (void)offset; - read_zone = (zone == ATCA_ZONE_CONFIG) ? ATCA_ECC204_ZONE_CONFIG : ATCA_ECC204_ZONE_DATA; + read_zone = (zone == ATCA_ZONE_CONFIG) ? ATCA_ZONE_CA2_CONFIG : ATCA_ZONE_CA2_DATA; if ((NULL == device) || (NULL == data)) { status = ATCA_TRACE(ATCA_BAD_PARAM, "Encountered Null pointer"); } - else if (ATCA_ECC204_ZONE_DATA == read_zone) + else if (ATCA_ZONE_CA2_DATA == read_zone) { if (32 != len) { @@ -559,7 +555,7 @@ ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint16_t slo status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid slot number received"); } } - else if (ATCA_ECC204_ZONE_CONFIG == read_zone) + else if (ATCA_ZONE_CA2_CONFIG == read_zone) { if (16 != len) { @@ -569,7 +565,7 @@ ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint16_t slo if (ATCA_SUCCESS == status) { - if (ATCA_SUCCESS != (status = calib_ecc204_get_addr(read_zone, slot, block, 0, &addr))) + if (ATCA_SUCCESS != (status = calib_ca2_get_addr(read_zone, slot, block, 0, &addr))) { ATCA_TRACE(status, "Address Encoding failed"); } @@ -605,19 +601,19 @@ ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint16_t slo * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_read_config_zone(ATCADevice device, uint8_t* config_data) +ATCA_STATUS calib_ca2_read_config_zone(ATCADevice device, uint8_t* config_data) { ATCA_STATUS status = ATCA_GEN_FAIL; uint8_t slot = 0; while (slot <= 3) { - if (ATCA_SUCCESS != (status = calib_ecc204_read_zone(device, ATCA_ZONE_CONFIG, + if (ATCA_SUCCESS != (status = calib_ca2_read_zone(device, ATCA_ZONE_CONFIG, slot, 0, 0, - &config_data[ATCA_ECC204_CONFIG_SLOT_SIZE * slot], - ATCA_ECC204_CONFIG_SLOT_SIZE))) + &config_data[ATCA_CA2_CONFIG_SLOT_SIZE * slot], + ATCA_CA2_CONFIG_SLOT_SIZE))) { - ATCA_TRACE(status, "calib_ecc204_read_zone - failed"); + ATCA_TRACE(status, "calib_ca2_read_zone - failed"); break; } slot += 1; // Increment slot to read next slot @@ -633,14 +629,14 @@ ATCA_STATUS calib_ecc204_read_config_zone(ATCADevice device, uint8_t* config_dat * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_read_serial_number(ATCADevice device, uint8_t* serial_number) +ATCA_STATUS calib_ca2_read_serial_number(ATCADevice device, uint8_t* serial_number) { ATCA_STATUS status = ATCA_GEN_FAIL; - uint8_t read_buf[ATCA_ECC204_CONFIG_SLOT_SIZE]; + uint8_t read_buf[ATCA_CA2_CONFIG_SLOT_SIZE]; - status = calib_ecc204_read_zone(device, ATCA_ZONE_CONFIG, 0, 0, 0, read_buf, - ATCA_ECC204_CONFIG_SLOT_SIZE); + status = calib_ca2_read_zone(device, ATCA_ZONE_CONFIG, 0, 0, 0, read_buf, + ATCA_CA2_CONFIG_SLOT_SIZE); if (ATCA_SUCCESS == status) { @@ -667,48 +663,76 @@ ATCA_STATUS calib_ecc204_read_serial_number(ATCADevice device, uint8_t* serial_n * * \return ATCA_SUCCESS on success, otherwise an error code. */ -ATCA_STATUS calib_ecc204_read_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, +ATCA_STATUS calib_ca2_read_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset, uint8_t* data, size_t length) { ATCA_STATUS status = ATCA_GEN_FAIL; - uint8_t block_size = (zone == ATCA_ZONE_CONFIG) ? ATCA_ECC204_CONFIG_SLOT_SIZE : ATCA_BLOCK_SIZE; - uint8_t no_of_blocks; - uint8_t data_idx = 0; + uint8_t data_set_size = (ATCA_ZONE_DATA == zone) ? ATCA_BLOCK_SIZE : ATCA_CA2_CONFIG_SLOT_SIZE; size_t cur_block = 0; + size_t data_idx = 0; + uint8_t read_buf[ATCA_BLOCK_SIZE]; + size_t read_buf_idx = 0, copy_length = 0, read_offset = 0; - if ((NULL == device) || (NULL == data)) + if (0 == length) + { + return ATCA_SUCCESS; + } + else if ((NULL == device) || (NULL == data)) { return ATCA_TRACE(ATCA_BAD_PARAM, "Encountered NULL pointer"); } - else if ((ATCA_ZONE_DATA == zone) && (((length > 64) && (2 == slot)) || - ((length > 320) && (1 == slot)) || (3 == slot) || (0 == slot))) + else if ((ATCA_ZONE_DATA != zone) && (ATCA_ZONE_CONFIG != zone)) { - return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); + return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid zone parameter received"); } - else if (ATCA_ZONE_CONFIG == zone) + else if (ATCA_ZONE_DATA == zone) { - return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); + if ((3 == slot) || (0 == slot) || (slot > 3)) + { + return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid slot received"); } - else if (0 == length) + else if (((slot == 1) && ((length + offset) > 320)) || ((slot == 2) && ((length + offset) > 64))) { - return ATCA_SUCCESS; + return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid length received"); + } + } + else + { + /* Is config zone */ + if ((slot > 3) || (offset > 15) || ((length + offset) > 16)) + { + return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid slot/length received"); + } } - cur_block = offset / block_size; - no_of_blocks = (uint8_t)(length / block_size); - while (no_of_blocks--) + cur_block = (ATCA_ZONE_DATA == zone) ? (offset / data_set_size) : 0; + + do { - if (ATCA_SUCCESS != (status = calib_ecc204_read_zone(device, zone, slot, cur_block, 0, - &data[block_size * data_idx], - block_size))) + if (ATCA_SUCCESS != (status = calib_ca2_read_zone(device, zone, slot, cur_block, 0, + read_buf, + data_set_size))) { - ATCA_TRACE(status, "calib_ecc204_read_zone failed"); + ATCA_TRACE(status, "calib_ca2_read_zone failed"); break; } - cur_block += 1; - data_idx += 1; // increment data index - } + // Calculate where in the read buffer we need data from + read_offset = (ATCA_ZONE_DATA == zone) ? (cur_block * data_set_size) : 0; + + // 0nly 0th block may contain offset + read_buf_idx = (data_idx == 0) ? (offset - read_offset) : 0; + + // Calculate number of bytes to be copied + copy_length = (data_idx + data_set_size) <= length ? (data_set_size - read_buf_idx) : (length - data_idx); + + // Check whether the copy_length exceeds data_set_size + copy_length = (read_buf_idx + copy_length) > data_set_size ? data_set_size - read_buf_idx : copy_length; + + memcpy(&data[data_idx], &read_buf[read_buf_idx], copy_length); + cur_block = (ATCA_ZONE_DATA == zone) ? (cur_block + 1) : cur_block; // increment block number for DATA zone + data_idx += copy_length; // increment data index + } while (data_idx < length); return status; } @@ -722,7 +746,7 @@ ATCA_STATUS calib_ecc204_read_bytes_zone(ATCADevice device, uint8_t zone, uint16 * \return TRUE if the zones pass the comparison test otherwise FALSE */ -bool calib_ecc204_compare_config( +bool calib_ca2_compare_config( uint8_t* expected, /**< [in] Expected configuration zone */ uint8_t* other /**< [in] Read or Other buffer to compare */ ) @@ -732,8 +756,8 @@ bool calib_ecc204_compare_config( if (expected && other) { // compare slot 1 and slot 3 data && skip first 16 bytes and counter value - if (!((memcmp(&expected[16], &other[16], ATCA_ECC204_CONFIG_SLOT_SIZE)) || - (memcmp(&expected[48], &other[48], ATCA_ECC204_CONFIG_SLOT_SIZE)))) + if (!((memcmp(&expected[16], &other[16], ATCA_CA2_CONFIG_SLOT_SIZE)) || + (memcmp(&expected[48], &other[48], ATCA_CA2_CONFIG_SLOT_SIZE)))) { same = true; } @@ -742,7 +766,7 @@ bool calib_ecc204_compare_config( } #endif /* CALIB_READ_EN */ -#if CALIB_READ_EN || CALIB_READ_ECC204_EN +#if CALIB_READ_EN || CALIB_READ_CA2_EN /** \brief Checks the device type and maps to the correct read operation * \return ATCA_SUCCESS on success, otherwise an error code. */ @@ -758,13 +782,13 @@ ATCA_STATUS calib_read_zone_ext( uint8_t len /**< [in] Length of the data to be read. Must be either 4 or 32. */ ) { -#if CALIB_ECC204_EN +#if ATCA_CA2_SUPPORT ATCADeviceType devtype = atcab_get_device_type_ext(device); ATCA_STATUS status = ATCA_BAD_PARAM; - if (ECC204 == devtype) + if (atcab_is_ca2_device(devtype)) { - status = calib_ecc204_read_zone(device, zone, slot, block, offset, data, len); + status = calib_ca2_read_zone(device, zone, slot, block, offset, data, len); } #if CALIB_READ_EN else if (atcab_is_ca_device(devtype)) @@ -772,6 +796,10 @@ ATCA_STATUS calib_read_zone_ext( status = calib_read_zone(device, zone, slot, block, offset, data, len); } #endif /* CALIB_READ_EN */ + else + { + status = ATCA_UNIMPLEMENTED; + } return status; #else return calib_read_zone(device, zone, slot, block, offset, data, len); @@ -803,9 +831,11 @@ ATCA_STATUS calib_read_config_zone(ATCADevice device, uint8_t* config_data) status = calib_read_bytes_zone(device, ATCA_ZONE_CONFIG, 0, 0x00, config_data, ATCA_SHA_CONFIG_SIZE); break; #endif -#if CALIB_ECC204_EN +#if ATCA_CA2_SUPPORT case ECC204: - status = calib_ecc204_read_config_zone(device, config_data); + /* fallthrough */ + case TA010: + status = calib_ca2_read_config_zone(device, config_data); break; #endif default: @@ -872,9 +902,11 @@ ATCA_STATUS calib_cmp_config_zone(ATCADevice device, uint8_t* config_data, bool* *same_config = calib_ecc608_compare_config(config_data, device_config_data); break; #endif -#if CALIB_ECC204_EN +#if ATCA_CA2_SUPPORT case ECC204: - *same_config = calib_ecc204_compare_config(config_data, device_config_data); + /* fallthrough */ + case TA010: + *same_config = calib_ca2_compare_config(config_data, device_config_data); break; #endif default: @@ -889,55 +921,6 @@ ATCA_STATUS calib_cmp_config_zone(ATCADevice device, uint8_t* config_data, bool* return status; } -/** \brief Executes Read command to read a 64 byte ECDSA P256 signature from a - * slot configured for clear reads. - * - * \param[in] device Device context pointer - * \param[in] slot Slot number to read from. Only slots 8 to 15 are large - * enough for a signature. - * \param[out] sig Signature will be returned here (64 bytes). Format will be - * the 32 byte R and S big-endian integers concatenated. - * - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS calib_read_sig(ATCADevice device, uint16_t slot, uint8_t* sig) -{ - ATCA_STATUS status = ATCA_GEN_FAIL; - - do - { - // Check the value of the slot - if (sig == NULL) - { - status = ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer received"); - break; - } - - if (slot < 8 || slot > 15) - { - status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid slot received"); - break; - } - - // Read the first block - if ((status = calib_read_zone_ext(device, ATCA_ZONE_DATA, slot, 0, 0, &sig[0], ATCA_BLOCK_SIZE)) != ATCA_SUCCESS) - { - ATCA_TRACE(status, "calib_read_zone - failed"); - break; - } - - // Read the second block - if ((status = calib_read_zone_ext(device, ATCA_ZONE_DATA, slot, 1, 0, &sig[ATCA_BLOCK_SIZE], ATCA_BLOCK_SIZE)) != ATCA_SUCCESS) - { - ATCA_TRACE(status, "calib_read_zone - failed"); - break; - } - } - while (0); - - return status; -} - /** \brief Executes Read command to read an ECC P256 public key from a slot * configured for clear reads. * @@ -1031,4 +1014,72 @@ ATCA_STATUS calib_read_pubkey(ATCADevice device, uint16_t slot, uint8_t *public_ return status; } + +/** \brief Executes Read command, which reads the 9 byte serial number of the + * device from the config zone. + * + * \param[in] device Device context pointer + * \param[out] serial_number 9 byte serial number is returned here. + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS calib_read_serial_number_ext(ATCADevice device, uint8_t* serial_number) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) + { + status = calib_ca2_read_serial_number(device, serial_number); + } + else +#endif + { +#if CALIB_READ_EN + status = calib_read_serial_number(device, serial_number); +#endif + } + + return status; +} + +/** \brief Used to read an arbitrary number of bytes from any zone configured + * for clear reads. + * + * This function will issue the Read command as many times as is required to + * read the requested data. + * + * \param[in] device Device context pointer + * \param[in] zone Zone to read data from. Option are ATCA_ZONE_CONFIG(0), + * ATCA_ZONE_OTP(1), or ATCA_ZONE_DATA(2). + * \param[in] slot Slot number to read from if zone is ATCA_ZONE_DATA(2). + * Ignored for all other zones. + * \param[in] offset Byte offset within the zone to read from. + * \param[out] data Read data is returned here. + * \param[in] length Number of bytes to read starting from the offset. + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS calib_read_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset, uint8_t *data, size_t length) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) + { + status = calib_ca2_read_bytes_zone(device, zone, slot, offset, data, length); + } + else +#endif + { +#if CALIB_READ_EN + status = calib_read_bytes_zone(device, zone, slot, offset, data, length); +#endif + } + + return status; +} + #endif diff --git a/lib/calib/calib_sha.c b/lib/calib/calib_sha.c index 1774de1ee..21558053b 100644 --- a/lib/calib/calib_sha.c +++ b/lib/calib/calib_sha.c @@ -406,7 +406,7 @@ ATCA_STATUS calib_sha_hmac_init(ATCADevice device, atca_hmac_sha256_ctx_t* ctx, memset(ctx, 0, sizeof(*ctx)); - if (ECC204 == device->mIface.mIfaceCFG->devtype) + if (atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype)) { mode = SHA_MODE_ECC204_HMAC_START; } @@ -477,7 +477,7 @@ ATCA_STATUS calib_sha_hmac_update(ATCADevice device, atca_hmac_sha256_ctx_t* ctx * SHA_MODE_TARGET_MSGDIGBUF, or SHA_MODE_TARGET_OUT_ONLY. * For all other devices, SHA_MODE_TARGET_TEMPKEY is the * only option. - * For ECC204, target is ignored (0x00) + * For ECC204,TA010 target is ignored (0x00) * * \return ATCA_SUCCESS on success, otherwise an error code. */ @@ -495,7 +495,7 @@ ATCA_STATUS calib_sha_hmac_finish(ATCADevice device, atca_hmac_sha256_ctx_t *ctx { mode = SHA_MODE_608_HMAC_END; } - else if (ECC204 == device->mIface.mIfaceCFG->devtype) + else if (atcab_is_ca2_device(device->mIface.mIfaceCFG->devtype)) { mode = SHA_MODE_ECC204_HMAC_END; } diff --git a/lib/calib/calib_sign.c b/lib/calib/calib_sign.c index 32b1395d6..75aa6bb73 100644 --- a/lib/calib/calib_sign.c +++ b/lib/calib/calib_sign.c @@ -151,21 +151,39 @@ ATCA_STATUS calib_sign(ATCADevice device, uint16_t key_id, const uint8_t *msg, u return status; } +#endif +#if CALIB_SIGN_EN || CALIB_SIGN_CA2_EN ATCA_STATUS calib_sign_ext(ATCADevice device, uint16_t key_id, const uint8_t *msg, uint8_t *signature) { -#if CALIB_ECC204_EN - if (ECC204 == atcab_get_device_type_ext(device)) + ATCADeviceType devtype = atcab_get_device_type_ext(device); + ATCA_STATUS status = ATCA_BAD_PARAM; + + switch(devtype) { - return calib_ecc204_sign(device, key_id, msg, signature); - } - else +#if CALIB_SIGN_EN + case ATECC108A: + /* fall-through */ + case ATECC508A: + /* fall-through */ + case ATECC608: + status = calib_sign(device, key_id, msg, signature); + break; #endif - { - return calib_sign(device, key_id, msg, signature); + +#if CALIB_SIGN_CA2_EN + case ECC204: + /* fallthrough */ + case TA010: + status = calib_ca2_sign(device, key_id, msg, signature); + break; +#endif + default: + status = ATCA_UNIMPLEMENTED; + break; } + return status; } - #endif #if CALIB_SIGN_INTERNAL_EN @@ -216,7 +234,7 @@ ATCA_STATUS calib_sign_internal(ATCADevice device, uint16_t key_id, bool is_inva } #endif /* CALIB_SIGN_MODE_ENCODING */ -#if CALIB_SIGN_ECC204_EN +#if CALIB_SIGN_CA2_EN /** \brief Execute sign command to sign the 32 bytes message digest using private key * mentioned in slot. * @@ -229,7 +247,7 @@ ATCA_STATUS calib_sign_internal(ATCADevice device, uint16_t key_id, bool is_inva * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_sign(ATCADevice device, uint16_t key_id, const uint8_t* msg, uint8_t* signature) +ATCA_STATUS calib_ca2_sign(ATCADevice device, uint16_t key_id, const uint8_t* msg, uint8_t* signature) { ATCA_STATUS status = ATCA_SUCCESS; ATCAPacket packet; @@ -251,7 +269,7 @@ ATCA_STATUS calib_ecc204_sign(ATCADevice device, uint16_t key_id, const uint8_t* if (ATCA_SUCCESS != (status = atca_execute_command(&packet, device))) { - ATCA_TRACE(status, "calib_ecc204_sign - execution failed"); + ATCA_TRACE(status, "calib_ca2_sign - execution failed"); } } diff --git a/lib/calib/calib_write.c b/lib/calib/calib_write.c index 774b65a94..59d3eaa6b 100644 --- a/lib/calib/calib_write.c +++ b/lib/calib/calib_write.c @@ -107,20 +107,6 @@ ATCA_STATUS calib_write(ATCADevice device, uint8_t zone, uint16_t address, const return status; } -ATCA_STATUS calib_write_ext(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, const uint8_t *mac) -{ -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) - { - return calib_ecc204_write(device, zone, address, value, mac); - } - else -#endif - { - return calib_write(device, zone, address, value, mac); - } -} - /** \brief Executes the Write command, which writes either 4 or 32 bytes of * data into a device zone. * @@ -382,20 +368,6 @@ ATCA_STATUS calib_write_config_zone(ATCADevice device, const uint8_t* config_dat return status; } -ATCA_STATUS calib_write_config_zone_ext(ATCADevice device, const uint8_t* config_data) -{ -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) - { - return calib_ecc204_write_config_zone(device, config_data); - } - else -#endif - { - return calib_write_config_zone(device, config_data); - } -} - /** \brief Executes the Write command, which writes data into the * configuration, otp, or data zones with a given byte offset and * length. Offset and length must be multiples of a word (4 bytes). @@ -500,20 +472,6 @@ ATCA_STATUS calib_write_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slo return status; } -ATCA_STATUS calib_write_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset_bytes, const uint8_t *data, size_t length) -{ -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) - { - return calib_ecc204_write_bytes_zone(device, zone, slot, offset_bytes, data, length); - } - else -#endif - { - return calib_write_bytes_zone(device, zone, slot, offset_bytes, data, length); - } -} - /** \brief Initialize one of the monotonic counters in device with a specific * value. * @@ -558,24 +516,10 @@ ATCA_STATUS calib_write_config_counter(ATCADevice device, uint16_t counter_id, u return status; } - -ATCA_STATUS calib_write_config_counter_ext(ATCADevice device, uint16_t counter_id, uint32_t counter_value) -{ -#if CALIB_ECC204_EN - if(ECC204 == atcab_get_device_type_ext(device)) - { - return calib_ecc204_write_config_counter(device, (uint8_t)counter_id, (uint16_t)counter_value); - } - else -#endif - { - return calib_write_config_counter(device, counter_id, counter_value); - } -} #endif /* CALIB_WRITE_EN */ /** \brief Execute write command to write either 16 byte or 32 byte to one of the EEPROM zones - * on the ECC204 device. + * on the ECC204, TA010 devices. * * \param[in] device Device context pointer * \param[in] zone Zone/Param1 for the write command. @@ -587,13 +531,13 @@ ATCA_STATUS calib_write_config_counter_ext(ATCADevice device, uint16_t counter_i * * \return ATCA_SUCCESS on success, otherwise an error code. */ -#if CALIB_WRITE_ECC204_EN -ATCA_STATUS calib_ecc204_write(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, +#if CALIB_WRITE_CA2_EN +ATCA_STATUS calib_ca2_write(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, const uint8_t *mac) { ATCA_STATUS status = ATCA_SUCCESS; ATCAPacket packet; - uint8_t write_zone = (zone == ATCA_ZONE_CONFIG) ? ATCA_ECC204_ZONE_CONFIG : ATCA_ECC204_ZONE_DATA; + uint8_t write_zone = (zone == ATCA_ZONE_CONFIG) ? ATCA_ZONE_CA2_CONFIG : ATCA_ZONE_CA2_DATA; if ((NULL == device) && (NULL == value)) { @@ -605,11 +549,11 @@ ATCA_STATUS calib_ecc204_write(ATCADevice device, uint8_t zone, uint16_t address packet.param1 = write_zone; packet.param2 = address; - if (ATCA_ECC204_ZONE_CONFIG == write_zone) + if (ATCA_ZONE_CA2_CONFIG == write_zone) { memcpy(packet.data, value, 16); } - else if (ATCA_ECC204_ZONE_DATA == write_zone) + else if (ATCA_ZONE_CA2_DATA == write_zone) { memcpy(packet.data, value, ATCA_BLOCK_SIZE); } @@ -620,12 +564,12 @@ ATCA_STATUS calib_ecc204_write(ATCADevice device, uint8_t zone, uint16_t address if (ATCA_SUCCESS == status) { - if (mac && (ATCA_ECC204_ZONE_DATA == write_zone)) + if (mac && (ATCA_ZONE_CA2_DATA == write_zone)) { memcpy(&packet.data[ATCA_BLOCK_SIZE], mac, MAC_SIZE); } - (void)atWrite(atcab_get_device_type_ext(device), &packet, mac && (ATCA_ECC204_ZONE_DATA == write_zone)); + (void)atWrite(atcab_get_device_type_ext(device), &packet, mac && (ATCA_ZONE_CA2_DATA == write_zone)); } } @@ -633,7 +577,7 @@ ATCA_STATUS calib_ecc204_write(ATCADevice device, uint8_t zone, uint16_t address { if (ATCA_SUCCESS != (status = atca_execute_command(&packet, device))) { - ATCA_TRACE(status, "calib_ecc204_write - execution failed"); + ATCA_TRACE(status, "calib_ca2_write - execution failed"); } } @@ -642,7 +586,7 @@ ATCA_STATUS calib_ecc204_write(ATCADevice device, uint8_t zone, uint16_t address } /** \brief Execute write command to write data into configuration zone or data zone - * This function only support ECC204 device + * This function only support ECC204,TA010 devices * * \param[in] device Device context pointer * \param[in] zone Device zone to write (config=1, data=0) @@ -654,7 +598,7 @@ ATCA_STATUS calib_ecc204_write(ATCADevice device, uint8_t zone, uint16_t address * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_write_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, +ATCA_STATUS calib_ca2_write_zone(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, const uint8_t *data, uint8_t len) { ATCA_STATUS status = ATCA_SUCCESS; @@ -674,28 +618,28 @@ ATCA_STATUS calib_ecc204_write_zone(ATCADevice device, uint8_t zone, uint16_t sl if (ATCA_SUCCESS == status) { - if (ATCA_SUCCESS != (status = calib_ecc204_get_addr(zone, slot, block, 0, &addr))) + if (ATCA_SUCCESS != (status = calib_ca2_get_addr(zone, slot, block, 0, &addr))) { - ATCA_TRACE(status, "calib_ecc204_get_addr - failed"); + ATCA_TRACE(status, "calib_ca2_get_addr - failed"); } if (ATCA_SUCCESS == status) { - status = calib_ecc204_write(device, zone, addr, data, NULL); + status = calib_ca2_write(device, zone, addr, data, NULL); } } return status; } -/** \brief Use write command to write configuration data into ECC204 config zone +/** \brief Use write command to write configuration data into ECC204,TA010 config zone * * \param[in] device Device context pointer * \param[in] config_data configuration data * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_write_config_zone(ATCADevice device, const uint8_t* config_data) +ATCA_STATUS calib_ca2_write_config_zone(ATCADevice device, const uint8_t* config_data) { ATCA_STATUS status = ATCA_SUCCESS; uint8_t slot = 1; @@ -709,10 +653,10 @@ ATCA_STATUS calib_ecc204_write_config_zone(ATCADevice device, const uint8_t* con { while (slot <= 3) { - if (ATCA_SUCCESS != (status = calib_ecc204_write_zone(device, ATCA_ZONE_CONFIG, slot, + if (ATCA_SUCCESS != (status = calib_ca2_write_zone(device, ATCA_ZONE_CONFIG, slot, 0, 0, &config_data[16 * slot], 16))) { - ATCA_TRACE(status, "calib_ecc204_write_zone - failed"); + ATCA_TRACE(status, "calib_ca2_write_zone - failed"); } slot += 1; // Increment slot } @@ -733,14 +677,14 @@ ATCA_STATUS calib_ecc204_write_config_zone(ATCADevice device, const uint8_t* con * * \return ATCA_SUCCESS on success, otherwise an error code. */ -ATCA_STATUS calib_ecc204_write_config_counter(ATCADevice device, uint8_t counter_id, uint16_t counter_value) +ATCA_STATUS calib_ca2_write_config_counter(ATCADevice device, uint8_t counter_id, uint16_t counter_value) { uint16_t bin_a, bin_b; uint64_t lin_a, lin_b; uint8_t bytes[16]; ATCA_STATUS status = ATCA_GEN_FAIL; - if (counter_id != 0 || counter_value > ECC204_COUNTER_MAX_VALUE) + if (counter_id != 0 || counter_value > COUNTER_MAX_VALUE_CA2) { return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid counter id or counter value received"); } @@ -762,13 +706,13 @@ ATCA_STATUS calib_ecc204_write_config_counter(ATCADevice device, uint8_t counter lin_b = ATCA_UINT64_HOST_TO_BE(lin_b) >> 16; memcpy(&bytes[10], &lin_b, 6); - status = calib_ecc204_write_zone(device, ATCA_ZONE_CONFIG, 2, 0, counter_id, bytes, sizeof(bytes)); + status = calib_ca2_write_zone(device, ATCA_ZONE_CONFIG, 2, 0, counter_id, bytes, sizeof(bytes)); return status; } -#endif /* CALIB_WRITE_ECC204_EN */ +#endif /* CALIB_WRITE_CA2_EN */ -#if CALIB_WRITE_ENC_EN && defined(ATCA_ECC204_SUPPORT) +#if CALIB_WRITE_ENC_ECC204_EN /** \brief Executes write command, performs an encrypted write of a 32 byte block into given slot. * * \param[in] device Device context pointer @@ -780,7 +724,7 @@ ATCA_STATUS calib_ecc204_write_config_counter(ATCADevice device, uint8_t counter * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* data, uint8_t* transport_key, +ATCA_STATUS calib_ca2_write_enc(ATCADevice device, uint16_t slot, uint8_t* data, uint8_t* transport_key, uint8_t transport_key_id, uint8_t num_in[NONCE_NUMIN_SIZE]) { ATCA_STATUS status = ATCA_SUCCESS; @@ -803,7 +747,7 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da do { // Read device serial number - if (ATCA_SUCCESS != (status = calib_ecc204_read_serial_number(device, serial_number))) + if (ATCA_SUCCESS != (status = calib_ca2_read_serial_number(device, serial_number))) { ATCA_TRACE(status, "Read serial number failed"); break; @@ -847,7 +791,7 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da break; } - if (ATCA_SUCCESS != (status = calib_ecc204_get_addr(ATCA_ZONE_DATA, slot, 0, 0, &addr))) + if (ATCA_SUCCESS != (status = calib_ca2_get_addr(ATCA_ZONE_DATA, slot, 0, 0, &addr))) { ATCA_TRACE(status, "Calculate slot address failed"); break; @@ -857,7 +801,7 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da memcpy(temp_key.value, session_key, ATCA_KEY_SIZE); // Write mac inputs - write_mac_param.zone = ATCA_ECC204_ZONE_DATA; + write_mac_param.zone = ATCA_ZONE_CA2_DATA; write_mac_param.key_id = addr; write_mac_param.sn = serial_number; write_mac_param.input_data = data; @@ -872,7 +816,7 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da break; } - status = calib_ecc204_write(device, ATCA_ZONE_DATA, write_mac_param.key_id, write_mac_param.encrypted_data, write_mac_param.auth_mac); + status = calib_ca2_write(device, ATCA_ZONE_DATA, write_mac_param.key_id, write_mac_param.encrypted_data, write_mac_param.auth_mac); } while (0); @@ -886,7 +830,7 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da * read the requested data. * * \param[in] device Device context pointer - * \param[in] zone It accepts only ATCA_ZONE_DATA for ECC204 device + * \param[in] zone It accepts only ATCA_ZONE_DATA for ECC204,TA010 devices * \param[in] slot slot number to write to. * \param[in] block offset bytes ignored * \param[in] data data to be written @@ -894,74 +838,171 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* da * * \return ATCA_SUCCESS on success, otheriwse an error code */ -#if CALIB_WRITE_ECC204_EN -ATCA_STATUS calib_ecc204_write_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, size_t block, +#if CALIB_WRITE_CA2_EN +ATCA_STATUS calib_ca2_write_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, size_t block, const uint8_t *data, size_t length) { ATCA_STATUS status = ATCA_SUCCESS; - uint8_t block_size = ATCA_BLOCK_SIZE; - uint8_t no_of_blocks; uint8_t data_idx = 0; + uint8_t data_set_size; + int8_t no_of_sets; if ((NULL == device) || (NULL == data)) { return ATCA_TRACE(ATCA_BAD_PARAM, "Encountered NULL pointer"); } - else if (ATCA_ZONE_DATA == zone) + else if ((ATCA_ZONE_DATA != zone) && (ATCA_ZONE_CONFIG != zone)) { - if (((length > 64) && (2 == slot)) || ((length > 320) && (1 == slot)) || (0 == slot)) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); - } + return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid zone parameter received"); + } + else if ((ATCA_ZONE_DATA == zone) && ( + // Only Slot 1-3 are valid for data zone write + (slot == 0) || (slot > 3) || + // Slot1 is of 10 blocks with each block_size is 32... Cannot exceed 10 block boundary + ((slot == 1) && ((block > 9) || (length > (ATCA_BLOCK_SIZE * (10-block))) || ((length % ATCA_BLOCK_SIZE) != 0))) || + // Slot2 is of 2 blocks with each block_size is 32... Cannot exceed 2 block boundary + ((slot == 2) && ((block > 1) || (length > (ATCA_BLOCK_SIZE * (2-block))) || ((length % ATCA_BLOCK_SIZE) != 0))) || + // Slot3 is of 1 block with block_size is 32... Cannot exceed block boundary + ((slot == 3) && ((block > 0) || (length > (ATCA_BLOCK_SIZE * (1-block))) || ((length % ATCA_BLOCK_SIZE) != 0))))) + { + return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid slot/block/length received"); } - else if (ATCA_ZONE_CONFIG == zone) + else if ((ATCA_ZONE_CONFIG == zone) && ( + (slot > 3) || + (block != 0) || ((length > 16 * (4-slot)) || ((length % 16) != 0)))) { - return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); + return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid block/length received"); } else if (0 == length) { return ATCA_SUCCESS; } - no_of_blocks = (uint8_t)(length / block_size); - while (no_of_blocks--) + data_set_size = (ATCA_ZONE_DATA == zone) ? ATCA_BLOCK_SIZE : 16; + no_of_sets = (uint8_t)(length / data_set_size); + + while(--no_of_sets >= 0) { - if (ATCA_SUCCESS != (status = calib_ecc204_write_zone(device, zone, slot, (uint8_t)block, 0, - &data[block_size * data_idx], - block_size))) + if (ATCA_SUCCESS != (status = calib_ca2_write_zone(device, zone, slot, (uint8_t)block, 0, + &data[data_set_size * data_idx], data_set_size))) { - ATCA_TRACE(status, "calib_ecc204_write_zone failed"); + ATCA_TRACE(status, "calib_ca2_write_zone failed"); break; } - block += 1; // Read next block - data_idx += 1; // increment data index + data_idx++; // increment data index + block = (ATCA_ZONE_DATA == zone) ? (block + 1) : block; // increment block number for DATA zone + slot = (ATCA_ZONE_CONFIG == zone) ? (slot + 1) : slot; // increment slot number for CONFIG zone } return status; } -#endif /* CALIB_WRITE_ECC204_EN */ +#endif /* CALIB_WRITE_CA2_EN */ -#if CALIB_WRITE_EN || CALIB_WRITE_ECC204_EN +#if CALIB_WRITE_EN || CALIB_WRITE_CA2_EN ATCA_STATUS calib_write_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, uint8_t block, uint8_t offset, const uint8_t *data, uint8_t len) { -#if CALIB_ECC204_EN - ATCADeviceType devtype = atcab_get_device_type_ext(device); ATCA_STATUS status = ATCA_BAD_PARAM; - if(ECC204 == devtype) + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) { - status = calib_ecc204_write_zone(device, zone, slot, block, offset, data, len); + status = calib_ca2_write_zone(device, zone, slot, block, offset, data, len); } -#if CALIB_WRITE_EN - else if (atcab_is_ca_device(devtype)) + else +#endif { +#if CALIB_WRITE_EN status = calib_write_zone(device, zone, slot, block, offset, data, len); +#endif } -#endif /* CALIB_WRITE_EN */ + + return status; +} + +ATCA_STATUS calib_write_ext(ATCADevice device, uint8_t zone, uint16_t address, const uint8_t *value, const uint8_t *mac) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) + { + status = calib_ca2_write(device, zone, address, value, mac); + } + else +#endif + { +#if CALIB_WRITE_EN + status = calib_write(device, zone, address, value, mac); +#endif + } + + return status; +} + +ATCA_STATUS calib_write_config_zone_ext(ATCADevice device, const uint8_t* config_data) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) + { + status = calib_ca2_write_config_zone(device, config_data); + } + else +#endif + { +#if CALIB_WRITE_EN + status = calib_write_config_zone(device, config_data); +#endif + } + + return status; +} + +ATCA_STATUS calib_write_config_counter_ext(ATCADevice device, uint16_t counter_id, uint32_t counter_value) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) + { + status = calib_ca2_write_config_counter(device, (uint8_t)counter_id, (uint16_t)counter_value); + } + else +#endif + { +#if CALIB_WRITE_EN + status = calib_write_config_counter(device, counter_id, counter_value); +#endif + } + + return status; +} + +ATCA_STATUS calib_write_bytes_zone_ext(ATCADevice device, uint8_t zone, uint16_t slot, size_t offset_bytes, const uint8_t *data, size_t length) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + +#if ATCA_CA2_SUPPORT + ATCADeviceType device_type = atcab_get_device_type_ext(device); + if (atcab_is_ca2_device(device_type)) + { + status = calib_ca2_write_bytes_zone(device, zone, slot, offset_bytes, data, length); + } + else +#endif + { +#if CALIB_WRITE_EN + status = calib_write_bytes_zone(device, zone, slot, offset_bytes, data, length); +#endif + } + return status; -#else - return calib_write_zone(device, zone, slot, block, offset, data, len); -#endif /* CALIB_ECC204_EN */ } /** \brief Uses the write command to write a public key to a slot in the diff --git a/lib/cmake/pkcs11.cmake b/lib/cmake/pkcs11.cmake index dd3304e19..3147567a4 100644 --- a/lib/cmake/pkcs11.cmake +++ b/lib/cmake/pkcs11.cmake @@ -12,6 +12,7 @@ option(PKCS11_LOCK_PIN_SLOT "Define to lock the PIN slot after writi option(PKCS11_TOKEN_INIT_SUPPORT "Enable device initialization using pkcs11 token initialization - UNSAFE" OFF) option(PKCS11_MONOTONIC_ENABLE "Map device counters to the pkcs11 montotonic counter class" OFF) option(PKCS11_AUTO_ID_ENABLE "Generate CKA_ID values based on standards" ON) +option(PKCS11_AUTH_TERMINATE_BEFORE_LOGIN "Enable auth terminate before c_login" OFF) set(PKCS11_MAX_SLOTS_ALLOWED 1 CACHE STRING "Maximum number of slots allowed in the system") set(PKCS11_MAX_SESSIONS_ALLOWED 10 CACHE STRING "Maximum number of total sessions allowed in the system") diff --git a/lib/crypto/atca_crypto_hw_aes_cbc.c b/lib/crypto/atca_crypto_hw_aes_cbc.c index c91cfca1b..700ec1484 100644 --- a/lib/crypto/atca_crypto_hw_aes_cbc.c +++ b/lib/crypto/atca_crypto_hw_aes_cbc.c @@ -257,10 +257,17 @@ ATCA_STATUS atcab_aes_cbc_encrypt_finish(atca_aes_cbc_ctx_t* ctx, uint8_t* ciphe if (ATCA_SUCCESS == status && ctx->block_size) { + if (*ciphertext_len >= ATCA_AES128_BLOCK_SIZE) + { status = atcab_aes_cbc_encrypt_block(ctx, ctx->block, ciphertext); *ciphertext_len = ATCA_AES128_BLOCK_SIZE; } else + { + status = ATCA_SMALL_BUFFER; + } + } + else { *ciphertext_len = 0; } @@ -310,7 +317,7 @@ ATCA_STATUS atcab_aes_cbc_decrypt_update(atca_aes_cbc_ctx_t* ctx, const uint8_t* plaintext += ATCA_AES128_BLOCK_SIZE; *plaintext_len += ATCA_AES128_BLOCK_SIZE; } - if (ATCA_AES128_BLOCK_SIZE <= ciphertext_len) + if (ATCA_AES128_BLOCK_SIZE < ciphertext_len) { if (ATCA_SUCCESS != (status = atcab_aes_cbc_decrypt_block(ctx, ciphertext, plaintext))) { @@ -321,8 +328,10 @@ ATCA_STATUS atcab_aes_cbc_decrypt_update(atca_aes_cbc_ctx_t* ctx, const uint8_t* ciphertext_len -= ATCA_AES128_BLOCK_SIZE; *plaintext_len += ATCA_AES128_BLOCK_SIZE; } - if (ciphertext_len && (ATCA_AES128_BLOCK_SIZE > ciphertext_len)) + + if (ciphertext_len && (ATCA_AES128_BLOCK_SIZE >= ciphertext_len)) { + /* Saves the remainder which may be partial or a full block of data */ memcpy(ctx->block, ciphertext, ciphertext_len); ctx->block_size = ciphertext_len; ciphertext_len -= ciphertext_len; @@ -343,6 +352,8 @@ ATCA_STATUS atcab_aes_cbc_decrypt_finish(atca_aes_cbc_ctx_t* ctx, uint8_t* plain if (ATCA_AES128_BLOCK_SIZE == ctx->block_size) { + if (*plaintext_len >= ATCA_AES128_BLOCK_SIZE) + { status = atcab_aes_cbc_decrypt_block(ctx, ctx->block, plaintext); *plaintext_len = ATCA_AES128_BLOCK_SIZE; @@ -350,10 +361,15 @@ ATCA_STATUS atcab_aes_cbc_decrypt_finish(atca_aes_cbc_ctx_t* ctx, uint8_t* plain { status = atcac_pkcs7_unpad(plaintext, plaintext_len, ATCA_AES128_BLOCK_SIZE); } + } + else + { + status = ATCA_SMALL_BUFFER; + } } else if (ctx->block_size) { - return ATCA_TRACE(ATCA_GEN_FAIL, "Remaining ciphertext does not match the block size"); + status = ATCA_TRACE(ATCA_GEN_FAIL, "Provided ciphertext is incomplete - the total length needs to be multiple of 16 bytes"); } memset(ctx, 0, sizeof(atca_aes_cbc_ctx_t)); diff --git a/lib/cryptoauthlib.h b/lib/cryptoauthlib.h index 3cbff72f9..5c933d84b 100644 --- a/lib/cryptoauthlib.h +++ b/lib/cryptoauthlib.h @@ -62,9 +62,11 @@ #define ATCA_ZONE_OTP ((uint8_t)0x01) #define ATCA_ZONE_DATA ((uint8_t)0x02) -#if defined(ATCA_ECC204_SUPPORT) -#define ATCA_ECC204_ZONE_DATA ((uint8_t)0x00) -#define ATCA_ECC204_ZONE_CONFIG ((uint8_t)0x01) +#if ATCA_CA2_SUPPORT +#define ATCA_ZONE_CA2_DATA ((uint8_t)0x00) +#define ATCA_ZONE_CA2_CONFIG ((uint8_t)0x01) +#define ATCA_ECC204_DEVICE_ID ((uint8_t)0x5A) +#define ATCA_TA010_DEVICE_ID ((uint8_t)0x6A) #endif /** Place resulting digest both in Output buffer and TempKey */ diff --git a/lib/hal/hal_swi_gpio.c b/lib/hal/hal_swi_gpio.c index e87533c68..e99d2c46a 100644 --- a/lib/hal/hal_swi_gpio.c +++ b/lib/hal/hal_swi_gpio.c @@ -32,7 +32,7 @@ #define ATCA_HAL_SWI #endif -#if defined(ATCA_ECC204_SUPPORT) && (defined(ATCA_HAL_SWI_GPIO) || defined(ATCA_HAL_SWI_BB)) +#if (defined(ATCA_ECC204_SUPPORT) || defined(ATCA_TA010_SUPPORT)) && (defined(ATCA_HAL_SWI_GPIO) || defined(ATCA_HAL_SWI_BB)) #define ATCA_HAL_1WIRE #endif @@ -80,7 +80,7 @@ static ATCA_STATUS send_logic_bit( if (bit_value == ATCA_GPIO_LOGIC_BIT1) { - timings = (cfg->devtype == ECC204) ? logic1_1wire_timings : logic1_swi_timings; + timings = (atcab_is_ca2_device(cfg->devtype)) ? logic1_1wire_timings : logic1_swi_timings; (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); atca_delay_us(*timings++); @@ -89,7 +89,7 @@ static ATCA_STATUS send_logic_bit( } else { - timings = (cfg->devtype == ECC204) ? logic0_1wire_timings : logic0_swi_timings; + timings = (atcab_is_ca2_device(cfg->devtype)) ? logic0_1wire_timings : logic0_swi_timings; (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); atca_delay_us(*timings++); @@ -97,7 +97,7 @@ static ATCA_STATUS send_logic_bit( atca_delay_us(*timings++); #ifdef ATCA_HAL_SWI - if (cfg->devtype != ECC204) + if (!atcab_is_ca2_device(cfg->devtype)) { (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); atca_delay_us(*timings++); @@ -175,7 +175,7 @@ static ATCA_STATUS gpio_send_bytes( uint8_t bit_mask; uint8_t count; - protocol_type proto_type = (cfg->devtype == ECC204) ? ATCA_PROTOCOL_1WIRE : ATCA_PROTOCOL_SWI; + protocol_type proto_type = (atcab_is_ca2_device(cfg->devtype)) ? ATCA_PROTOCOL_1WIRE : ATCA_PROTOCOL_SWI; if (txdata == NULL) { @@ -186,7 +186,7 @@ static ATCA_STATUS gpio_send_bytes( __disable_irq(); for (count = 0; count < txlength; count++) { - bit_mask = (cfg->devtype == ECC204) ? ATCA_1WIRE_BIT_MASK : ATCA_SWI_BIT_MASK; + bit_mask = (atcab_is_ca2_device(cfg->devtype)) ? ATCA_1WIRE_BIT_MASK : ATCA_SWI_BIT_MASK; while (bit_mask > 0) { /* if the next bit transmitted is a logic '1' */ @@ -324,12 +324,12 @@ static ATCA_STATUS gpio_receive_bytes( return ATCA_BAD_PARAM; } - proto_type = (cfg->devtype == ECC204) ? ATCA_PROTOCOL_1WIRE : ATCA_PROTOCOL_SWI; + proto_type = (atcab_is_ca2_device(cfg->devtype)) ? ATCA_PROTOCOL_1WIRE : ATCA_PROTOCOL_SWI; __disable_irq(); for (count = 0; count < rxlength; count++) { - bit_mask = (cfg->devtype == ECC204) ? ATCA_1WIRE_BIT_MASK : ATCA_SWI_BIT_MASK; + bit_mask = (atcab_is_ca2_device(cfg->devtype)) ? ATCA_1WIRE_BIT_MASK : ATCA_SWI_BIT_MASK; while (bit_mask >= 1) { #ifdef ATCA_HAL_1WIRE @@ -507,7 +507,7 @@ ATCA_STATUS hal_swi_gpio_send(ATCAIface iface, uint8_t word_address, uint8_t *tx return status; } - if (cfg->devtype == ECC204) + if (atcab_is_ca2_device(cfg->devtype)) { #ifdef ATCA_HAL_1WIRE if (ATCA_SUCCESS == (status = start_stop_cond_1wire(iface))) @@ -553,7 +553,7 @@ ATCA_STATUS hal_swi_gpio_receive(ATCAIface iface, uint8_t word_address, uint8_t return ATCA_BAD_PARAM; } - if (cfg->devtype == ECC204) + if (atcab_is_ca2_device(cfg->devtype)) { #ifdef ATCA_HAL_1WIRE word_address = get_slave_addr_1wire(cfg->atcaswi.address, ATCA_GPIO_READ); @@ -580,7 +580,7 @@ ATCA_STATUS hal_swi_gpio_receive(ATCAIface iface, uint8_t word_address, uint8_t while ((retries-- > 0) && (status == ATCA_COMM_FAIL)); #ifdef ATCA_HAL_1WIRE - if ((cfg->devtype == ECC204) && (*rxlength != ATCA_1WIRE_RESPONSE_LENGTH_SIZE)) + if ((atcab_is_ca2_device(cfg->devtype)) && (*rxlength != ATCA_1WIRE_RESPONSE_LENGTH_SIZE)) { (void)send_NACK_1wire(iface); } @@ -600,7 +600,7 @@ static ATCA_STATUS hal_swi_gpio_idle(ATCAIface iface) if (cfg) { - if (cfg->devtype == ECC204) + if (atcab_is_ca2_device(cfg->devtype)) { return ATCA_SUCCESS; } @@ -624,7 +624,7 @@ static ATCA_STATUS hal_swi_gpio_sleep(ATCAIface iface) if (cfg) { - word_address = (cfg->devtype == ECC204) ? ATCA_1WIRE_SLEEP_WORD_ADDR : \ + word_address = (atcab_is_ca2_device(cfg->devtype)) ? ATCA_1WIRE_SLEEP_WORD_ADDR : \ ATCA_SWI_SLEEP_WORD_ADDR; return hal_swi_gpio_send(iface, word_address, NULL, 0); @@ -672,7 +672,7 @@ static ATCA_STATUS hal_swi_gpio_wake(ATCAIface iface) return ATCA_BAD_PARAM; } - if (cfg->devtype == ECC204) + if (atcab_is_ca2_device(cfg->devtype)) { #ifdef ATCA_HAL_1WIRE status = check_wake_1wire(iface); diff --git a/lib/hal/kit_protocol.c b/lib/hal/kit_protocol.c index 2d159f532..4ead7bd09 100644 --- a/lib/hal/kit_protocol.c +++ b/lib/hal/kit_protocol.c @@ -80,8 +80,18 @@ const char * kit_id_from_devtype(ATCADeviceType devtype) return "TA100"; case ECC204: return "ECC204"; + case ECC206: + return "ECC206"; case TA010: return "TA010"; + case SHA104: + return "SHA104"; + case SHA105: + return "SHA105"; + case SHA106: + return "SHA106"; + case RNG90: + return "RNG90"; default: return "unknown"; } diff --git a/lib/host/atca_host.c b/lib/host/atca_host.c index 6e40a2a45..addf88bab 100644 --- a/lib/host/atca_host.c +++ b/lib/host/atca_host.c @@ -1735,3 +1735,55 @@ ATCA_STATUS atcah_gen_session_key(struct atca_session_key_in_out *param) #endif /* ATCAH_GEN_SESSION_KEY */ #endif + +/** \brief This function calculates host side mac with the parameters passed. + * \param[in,out] param pointer to parameter structure + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +#if ATCAH_DELETE_MAC +ATCA_STATUS atcah_delete_mac(struct atca_delete_in_out *param) +{ + uint8_t temporary[ATCA_MSG_SIZE_DELETE_MAC]; + uint8_t *p_temp; + + if ((NULL == param->key) || (NULL == param->nonce) || (NULL == param->mac)) + { + return ATCA_BAD_PARAM; + } + + p_temp = temporary; + + // (1) 32 bytes of key + memcpy(p_temp, param->key, ATCA_KEY_SIZE); + p_temp += ATCA_KEY_SIZE; + + // (2) 0x13 + *p_temp++ = ATCA_DELETE; + + // (3) 0x00 + *p_temp++ = 0x00; + + // (4) 0x0000 + *p_temp++ = param->key_id & 0xFF; + *p_temp++ = (param->key_id >> 8) & 0xFF; + + // (5) 1 byte SN[8] + *p_temp++ = param->sn[8]; + + // (6) 2 bytes SN[0:1] + *p_temp++ = param->sn[0]; + *p_temp++ = param->sn[1]; + + // (7) 25 zeros + memset(p_temp, 0, ATCA_DELETE_MAC_ZEROS_SIZE); + p_temp += ATCA_DELETE_MAC_ZEROS_SIZE; + + // (8) 32 bytes nonce + memcpy(p_temp, param->nonce, 32); + + // Calculate SHA256 to get MAC + atcac_sw_sha2_256(temporary, ATCA_MSG_SIZE_DELETE_MAC, param->mac); + + return ATCA_SUCCESS; +} +#endif /* ATCAH_DELETE_MAC */ diff --git a/lib/host/atca_host.h b/lib/host/atca_host.h index 4860f8fd5..9ca1dd4c7 100644 --- a/lib/host/atca_host.h +++ b/lib/host/atca_host.h @@ -81,12 +81,16 @@ //! TransportKey{32} || 0x15{1} || 0x00{1} || KeyId{2} || SN8{1} || SN0_1{2} || 0{25} || Nonce{32} #define ATCA_MSG_SIZE_SESSION_KEY (96) +//! HmacKey{32} || 0x13{1} || 0x00{1} || 0x0000{2} || SN8{1} || SN0_1{2} || 0{25} || Nonce{32} +#define ATCA_MSG_SIZE_DELETE_MAC (96) + //! KeyId{32} || OpCode{1} || Param1{1} || Param2{2}|| SN8{1} || SN0_1{2} || 0{21} || PlainText{36} #define ATCA_MSG_SIZE_PRIVWRITE_MAC (96) #define ATCA_COMMAND_HEADER_SIZE ( 4) #define ATCA_GENDIG_ZEROS_SIZE (25) #define ATCA_WRITE_MAC_ZEROS_SIZE (25) +#define ATCA_DELETE_MAC_ZEROS_SIZE (25) #define ATCA_PRIVWRITE_MAC_ZEROS_SIZE (21) #define ATCA_PRIVWRITE_PLAIN_TEXT_SIZE (36) #define ATCA_DERIVE_KEY_ZEROS_SIZE (25) @@ -431,6 +435,17 @@ typedef struct atca_session_key_in_out uint8_t* session_key; }atca_session_key_in_out_t; +/** \brief Input/Output paramters for calculating the mac.Used with Delete command. + */ +typedef struct atca_delete_in_out +{ + uint16_t key_id; + const uint8_t* sn; + uint8_t* nonce; + const uint8_t* key; + uint8_t* mac; +}atca_delete_in_out_t; + #ifdef __cplusplus extern "C" { #endif @@ -458,6 +473,7 @@ ATCA_STATUS atcah_encode_counter_match(uint32_t counter, uint8_t * counter_match ATCA_STATUS atcah_io_decrypt(struct atca_io_decrypt_in_out *param); ATCA_STATUS atcah_ecc204_write_auth_mac(struct atca_write_mac_in_out *param); ATCA_STATUS atcah_gen_session_key(atca_session_key_in_out_t *param); +ATCA_STATUS atcah_delete_mac(struct atca_delete_in_out *param); #ifdef __cplusplus } #endif diff --git a/lib/host/atca_host_config_check.h b/lib/host/atca_host_config_check.h index 0dc797130..d7f28d9d9 100644 --- a/lib/host/atca_host_config_check.h +++ b/lib/host/atca_host_config_check.h @@ -315,6 +315,19 @@ #define ATCAH_GEN_SESSION_KEY (DEFAULT_ENABLED) #endif +/** \def ATCAH_DELETE_MAC + * + * Requires: ATCAH_DELETE_MAC + * ATCAC_SW_SHA2_256 + * + * Supported API's: atcah_delete_mac + * + * Enable ATCAH_DELETE_MAC to calculate the mac + **/ +#ifndef ATCAH_DELETE_MAC +#define ATCAH_DELETE_MAC (CALIB_DELETE_EN) +#endif + /* ATCA CRYPTO REQUIREMENTS */ #ifndef ATCAC_SW_SHA2_256 diff --git a/lib/pkcs11/pkcs11_config.h.in b/lib/pkcs11/pkcs11_config.h.in index b215a35fc..7ebdad624 100644 --- a/lib/pkcs11/pkcs11_config.h.in +++ b/lib/pkcs11/pkcs11_config.h.in @@ -43,6 +43,11 @@ #cmakedefine01 PKCS11_DEBUG_ENABLE #endif +/** Enable PKCS#11 AUTH session terminate work around */ +#ifndef PKCS11_AUTH_TERMINATE_BEFORE_LOGIN +#cmakedefine01 PKCS11_AUTH_TERMINATE_BEFORE_LOGIN +#endif + /** Use Static or Dynamic Allocation */ #ifndef PKCS11_USE_STATIC_MEMORY #cmakedefine01 PKCS11_USE_STATIC_MEMORY diff --git a/lib/pkcs11/pkcs11_digest.c b/lib/pkcs11/pkcs11_digest.c index 56bef914a..6b7af4adb 100644 --- a/lib/pkcs11/pkcs11_digest.c +++ b/lib/pkcs11/pkcs11_digest.c @@ -26,6 +26,12 @@ CK_RV pkcs11_digest_init(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism return CKR_ARGUMENTS_BAD; } + rv = pkcs11_session_check(&pSession, hSession); + if (rv) + { + return rv; + } + if (CKM_SHA256 != pMechanism->mechanism) { return CKR_MECHANISM_INVALID; @@ -35,11 +41,6 @@ CK_RV pkcs11_digest_init(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism return CKR_OPERATION_ACTIVE; } - rv = pkcs11_session_check(&pSession, hSession); - if (rv) - { - return rv; - } #if PKCS11_HARDWARE_SHA256 return CKR_FUNCTION_NOT_SUPPORTED; #else diff --git a/lib/pkcs11/pkcs11_encrypt.c b/lib/pkcs11/pkcs11_encrypt.c index 6e7954ed9..b20cedf24 100644 --- a/lib/pkcs11/pkcs11_encrypt.c +++ b/lib/pkcs11/pkcs11_encrypt.c @@ -212,13 +212,14 @@ CK_RV pkcs11_encrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulD case CKM_AES_CBC: { size_t length = *pulEncryptedDataLen; + size_t final = 0; if (ATCA_SUCCESS == (status = atcab_aes_cbc_encrypt_update(&pSession->active_mech_data.cbc, pData, ulDataLen, pEncryptedData, &length))) { pEncryptedData += length; - length = *pulEncryptedDataLen - length; - status = atcab_aes_cbc_encrypt_finish(&pSession->active_mech_data.cbc, pEncryptedData, &length, padding); + final = *pulEncryptedDataLen - length; + status = atcab_aes_cbc_encrypt_finish(&pSession->active_mech_data.cbc, pEncryptedData, &final, padding); } - *pulEncryptedDataLen = length; + *pulEncryptedDataLen = length + final; } break; case CKM_AES_GCM: @@ -623,13 +624,14 @@ CK_RV pkcs11_decrypt case CKM_AES_CBC: { size_t length = *pulDataLen; + size_t final = 0; if (ATCA_SUCCESS == (status = atcab_aes_cbc_decrypt_update(&pSession->active_mech_data.cbc, pEncryptedData, ulEncryptedDataLen, pData, &length))) { pData += length; - length = *pulDataLen - length; - status = atcab_aes_cbc_decrypt_finish(&pSession->active_mech_data.cbc, pData, &length, padding); + final = *pulDataLen - length; + status = atcab_aes_cbc_decrypt_finish(&pSession->active_mech_data.cbc, pData, &final, padding); } - *pulDataLen = length; + *pulDataLen = length + final; } break; case CKM_AES_GCM: diff --git a/lib/pkcs11/pkcs11_init.c b/lib/pkcs11/pkcs11_init.c index 9b35c8226..f5b6030dd 100644 --- a/lib/pkcs11/pkcs11_init.c +++ b/lib/pkcs11/pkcs11_init.c @@ -385,7 +385,7 @@ CK_RV pkcs11_deinit(CK_VOID_PTR pReserved) } /* Lock the library */ - if (CKR_OK == (rv == pkcs11_lock_context(lib_ctx))) + if (CKR_OK == (rv = pkcs11_lock_context(lib_ctx))) { if (CKR_OK == pkcs11_lock_device(lib_ctx)) { @@ -430,8 +430,10 @@ CK_RV pkcs11_deinit(CK_VOID_PTR pReserved) /* the library is now closing */ (void)pkcs11_unlock_context(lib_ctx); + if (lib_ctx->lib_lock) + { /* Clean up the library lock */ - if (lib_ctx->destroy_mutex(lib_ctx->lib_lock)) + if(lib_ctx->destroy_mutex) { (void)lib_ctx->destroy_mutex(lib_ctx->lib_lock); } @@ -440,6 +442,7 @@ CK_RV pkcs11_deinit(CK_VOID_PTR pReserved) (void)pkcs11_os_destroy_mutex(lib_ctx->lib_lock); } lib_ctx->lib_lock = NULL; + } pkcs11_context.initialized = FALSE; } diff --git a/lib/pkcs11/pkcs11_key.c b/lib/pkcs11/pkcs11_key.c index 80f4a8414..7a0be75aa 100644 --- a/lib/pkcs11/pkcs11_key.c +++ b/lib/pkcs11/pkcs11_key.c @@ -38,6 +38,7 @@ #include "pkcs11_util.h" #include "pkcs11_os.h" + /** * \defgroup pkcs11 Key (pkcs11_key_) @{ */ @@ -50,24 +51,24 @@ static CK_RV pkcs11_key_get_derivekey_flag(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR { if (atcab_is_ca_device(atcab_get_device_type())) { -#if ATCA_CA_SUPPORT - atecc508a_config_t * pConfig = (atecc508a_config_t*)obj_ptr->config; + #if ATCA_CA_SUPPORT + atecc508a_config_t * pConfig = (atecc508a_config_t*)obj_ptr->config; - if (!pConfig) - { - return CKR_GENERAL_ERROR; - } + if (!pConfig) + { + return CKR_GENERAL_ERROR; + } - if (ATCA_SLOT_CONFIG_ECDH_MASK & pConfig->SlotConfig[obj_ptr->slot]) - { - return pkcs11_attrib_true(NULL, pAttribute); - } - else - { - return pkcs11_attrib_false(NULL, pAttribute); + if (ATCA_SLOT_CONFIG_ECDH_MASK & pConfig->SlotConfig[obj_ptr->slot]) + { + return pkcs11_attrib_true(NULL, pAttribute); + } + else + { + return pkcs11_attrib_false(NULL, pAttribute); + } + #endif } -#endif - } else { return pkcs11_attrib_false(NULL, pAttribute); @@ -77,6 +78,48 @@ static CK_RV pkcs11_key_get_derivekey_flag(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR return CKR_ARGUMENTS_BAD; } +#if ATCA_TA_SUPPORT +static ATCA_STATUS pkcs11_ta_get_pubkey(CK_VOID_PTR pObject,uint8_t* buffer) +{ + pkcs11_object_ptr obj_ptr = (pkcs11_object_ptr)pObject; + uint16_t publickey_slot = 0; + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t pubkey_field_handle_info[TA_HANDLE_INFO_SIZE]; + + ATCADevice device = atcab_get_device(); + + /* Get the pubkey slot value from property of handleinfo*/ + publickey_slot = TA_PUB_KIEY_FIELD_HANDLE_MSB | (obj_ptr->handle_info.property & TA_PROPERTY_ATTRIBUTE_MASK); + + /*If the Pub_Key field of the handleinfo references + a valid public key or extracted cert + read the public key from the referenced handle*/ + if((ATCA_SUCCESS == (status = talib_info_get_handle_info(device,publickey_slot, pubkey_field_handle_info)))&&(((pubkey_field_handle_info[0] & TA_CLASS_MASK) == TA_CLASS_PUBLIC_KEY) ||((pubkey_field_handle_info[0] & TA_CLASS_MASK) == TA_CLASS_EXTRACTED_CERT))) + { + status = atcab_read_pubkey(publickey_slot,buffer); + PKCS11_DEBUG("atcab_read_pubkey: %x\r\n", status); + } + else if((obj_ptr->handle_info.permission & TA_PERM_USAGE_MASK) == TA_PERM_AUTH) + { + uint8_t isvalid = 0; + if(device->session_state != TA_AUTH_STATE_IDLE) + { + uint8_t auth_session_id = (device->session_key_id == TA_HANDLE_AUTH_SESSION) ? 0:1; + if( ATCA_SUCCESS == talib_is_auth_session_valid(device,auth_session_id,&isvalid)) + { + if(isvalid == 1) + { + status = atcab_get_pubkey(obj_ptr->slot, buffer); + PKCS11_DEBUG("atcab_get_pubkey: %x\r\n", status); + } + } + } + } + + return status; +} +#endif + static CK_RV pkcs11_key_get_local_flag(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAttribute) { pkcs11_object_ptr obj_ptr = (pkcs11_object_ptr)pObject; @@ -85,24 +128,24 @@ static CK_RV pkcs11_key_get_local_flag(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAt { if (atcab_is_ca_device(atcab_get_device_type())) { -#if ATCA_CA_SUPPORT - atecc508a_config_t * pConfig = (atecc508a_config_t*)obj_ptr->config; + #if ATCA_CA_SUPPORT + atecc508a_config_t * pConfig = (atecc508a_config_t*)obj_ptr->config; - if (!pConfig) - { - return CKR_GENERAL_ERROR; - } + if (!pConfig) + { + return CKR_GENERAL_ERROR; + } - if (ATCA_SLOT_CONFIG_WRITE_CONFIG(2) == (ATCA_SLOT_CONFIG_WRITE_CONFIG_MASK & pConfig->SlotConfig[obj_ptr->slot])) - { - return pkcs11_attrib_true(NULL, pAttribute); - } - else - { - return pkcs11_attrib_false(NULL, pAttribute); + if (ATCA_SLOT_CONFIG_WRITE_CONFIG(2) == (ATCA_SLOT_CONFIG_WRITE_CONFIG_MASK & pConfig->SlotConfig[obj_ptr->slot])) + { + return pkcs11_attrib_true(NULL, pAttribute); + } + else + { + return pkcs11_attrib_false(NULL, pAttribute); + } + #endif } -#endif - } else { return pkcs11_attrib_false(NULL, pAttribute); @@ -161,46 +204,46 @@ static CK_RV pkcs11_key_get_allowed_mechanisms(CK_VOID_PTR pObject, CK_ATTRIBUTE { if (atcab_is_ca_device(atcab_get_device_type())) { -#if ATCA_CA_SUPPORT - atecc508a_config_t * pConfig = (atecc508a_config_t*)obj_ptr->config; - - if (!pConfig) - { - return CKR_GENERAL_ERROR; - } + #if ATCA_CA_SUPPORT + atecc508a_config_t * pConfig = (atecc508a_config_t*)obj_ptr->config; - if (ATCA_KEY_CONFIG_KEY_TYPE(4) == (ATCA_KEY_CONFIG_KEY_TYPE_MASK & pConfig->KeyConfig[obj_ptr->slot])) - { - if (ATCA_KEY_CONFIG_PRIVATE_MASK & pConfig->KeyConfig[obj_ptr->slot]) + if (!pConfig) { - return pkcs11_attrib_fill(pAttribute, (CK_VOID_PTR)pkcs11_key_508_private_mech, - sizeof(pkcs11_key_508_private_mech)); + return CKR_GENERAL_ERROR; } - else + + if (ATCA_KEY_CONFIG_KEY_TYPE(4) == (ATCA_KEY_CONFIG_KEY_TYPE_MASK & pConfig->KeyConfig[obj_ptr->slot])) { - return pkcs11_attrib_fill(pAttribute, (CK_VOID_PTR)pkcs11_key_508_public_mech, - sizeof(pkcs11_key_508_public_mech)); + if (ATCA_KEY_CONFIG_PRIVATE_MASK & pConfig->KeyConfig[obj_ptr->slot]) + { + return pkcs11_attrib_fill(pAttribute, (CK_VOID_PTR)pkcs11_key_508_private_mech, + sizeof(pkcs11_key_508_private_mech)); + } + else + { + return pkcs11_attrib_fill(pAttribute, (CK_VOID_PTR)pkcs11_key_508_public_mech, + sizeof(pkcs11_key_508_public_mech)); + } } - } - else - { - switch (((uint8_t*)&pConfig->RevNum)[2]) + else { - case 0x60: - return pkcs11_attrib_fill(pAttribute, (CK_VOID_PTR)pkcs11_key_608_secret_mech, - sizeof(pkcs11_key_608_secret_mech)); - break; - case 0x50: - return pkcs11_attrib_fill(pAttribute, (CK_VOID_PTR)pkcs11_key_508_secret_mech, - sizeof(pkcs11_key_508_secret_mech)); - break; - default: - break; - } + switch (((uint8_t*)&pConfig->RevNum)[2]) + { + case 0x60: + return pkcs11_attrib_fill(pAttribute, (CK_VOID_PTR)pkcs11_key_608_secret_mech, + sizeof(pkcs11_key_608_secret_mech)); + break; + case 0x50: + return pkcs11_attrib_fill(pAttribute, (CK_VOID_PTR)pkcs11_key_508_secret_mech, + sizeof(pkcs11_key_508_secret_mech)); + break; + default: + break; + } + } + #endif } -#endif - } else { if(CKO_PRIVATE_KEY == obj_ptr->class_id) @@ -250,30 +293,50 @@ static CK_RV pkcs11_key_get_public_key(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAt CK_BBOOL is_private = false; if (CKR_OK == (rv = pkcs11_object_is_private(obj_ptr, &is_private))) - { - CK_UTF8CHAR ec_asn1_key[sizeof(ec_pubkey_asn1_header) + ATCA_ECCP256_PUBKEY_SIZE]; - ATCA_STATUS status; + { + CK_UTF8CHAR ec_asn1_key[sizeof(ec_pubkey_asn1_header) + ATCA_ECCP256_PUBKEY_SIZE]; + ATCA_STATUS status = ATCA_GEN_FAIL; - memcpy(ec_asn1_key, ec_pubkey_asn1_header, sizeof(ec_pubkey_asn1_header)); + memcpy(ec_asn1_key, ec_pubkey_asn1_header, sizeof(ec_pubkey_asn1_header)); - if (is_private) - { - status = atcab_get_pubkey(obj_ptr->slot, &ec_asn1_key[sizeof(ec_pubkey_asn1_header)]); - } - else - { - status = atcab_read_pubkey(obj_ptr->slot, &ec_asn1_key[sizeof(ec_pubkey_asn1_header)]); - } - if (ATCA_SUCCESS == status) - { - rv = pkcs11_attrib_fill(pAttribute, ec_asn1_key, sizeof(ec_asn1_key)); - } - else - { - rv = CKR_FUNCTION_FAILED; - } - } + if (is_private) + { + ATCADeviceType dev_type = atcab_get_device_type(); + + if (atcab_is_ca_device(dev_type)) + { +#if ATCA_CA_SUPPORT + status = atcab_get_pubkey(obj_ptr->slot,&ec_asn1_key[sizeof(ec_pubkey_asn1_header)]); + PKCS11_DEBUG("atcab_get_pubkey: %x\r\n", status); +#endif + } + else if (atcab_is_ta_device(dev_type)) + { +#if ATCA_TA_SUPPORT + status = pkcs11_ta_get_pubkey(pObject,&ec_asn1_key[sizeof(ec_pubkey_asn1_header)]); +#endif + } + } + else + { + status = atcab_read_pubkey(obj_ptr->slot, &ec_asn1_key[sizeof(ec_pubkey_asn1_header)]); + PKCS11_DEBUG("atcab_read_pubkey: %x\r\n", status); + + } + + if (ATCA_SUCCESS == status) + { + rv = pkcs11_attrib_fill(pAttribute, ec_asn1_key, sizeof(ec_asn1_key)); + } + else + { + pkcs11_attrib_empty(pObject,pAttribute); + PKCS11_DEBUG("Couldnt generate public key\r\n", status); + rv = CKR_OK; + + } + } } return rv; @@ -302,18 +365,32 @@ static CK_RV pkcs11_key_get_ec_point(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAttr CK_BBOOL is_private; if (CKR_OK == (rv = pkcs11_object_is_private(obj_ptr, &is_private))) - { - if (is_private) - { - status = atcab_get_pubkey(obj_ptr->slot, &ec_asn1_key[3]); - PKCS11_DEBUG("atcab_get_pubkey: %x\r\n", status); - } - else - { - status = atcab_read_pubkey(obj_ptr->slot, &ec_asn1_key[3]); - PKCS11_DEBUG("atcab_read_pubkey: %x\r\n", status); - } - } + { + if (is_private) + { + ATCADeviceType dev_type = atcab_get_device_type(); + + if (atcab_is_ca_device(dev_type)) + { +#if ATCA_CA_SUPPORT + status = atcab_get_pubkey(obj_ptr->slot, &ec_asn1_key[3]); + PKCS11_DEBUG("atcab_get_pubkey: %x\r\n", status); +#endif + } + else if (atcab_is_ta_device(dev_type)) + { +#if ATCA_TA_SUPPORT + status = pkcs11_ta_get_pubkey(pObject,&ec_asn1_key[3]); +#endif + } + } + else + { + status = atcab_read_pubkey(obj_ptr->slot, &ec_asn1_key[3]); + PKCS11_DEBUG("atcab_read_pubkey: %x\r\n", status); + + } + } } if (ATCA_SUCCESS == status) @@ -322,7 +399,9 @@ static CK_RV pkcs11_key_get_ec_point(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAttr } else { - rv = CKR_FUNCTION_FAILED; + pkcs11_attrib_empty(pObject,pAttribute); + PKCS11_DEBUG("Couldnt generate public key\r\n", status); + rv = CKR_OK; } } @@ -430,35 +509,49 @@ static CK_RV pkcs11_key_get_id(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAttribute) CK_BBOOL is_private; if (CKR_OK == (rv = pkcs11_object_is_private(obj_ptr, &is_private))) - { - ATCA_STATUS status; - uint8_t buffer[1 + ATCA_ECCP256_PUBKEY_SIZE] = {0x04}; - - if (is_private) - { - status = atcab_get_pubkey(obj_ptr->slot, &buffer[1]); - PKCS11_DEBUG("atcab_get_pubkey: %x\r\n", status); - } - else - { - status = atcab_read_pubkey(obj_ptr->slot, &buffer[1]); - PKCS11_DEBUG("atcab_read_pubkey: %x\r\n", status); - } - - if (ATCA_SUCCESS == status) - { - status = atcac_sw_sha1(buffer, sizeof(buffer), buffer); - } - - if (ATCA_SUCCESS == status) - { - rv = pkcs11_attrib_fill(pAttribute, buffer, ATCA_SHA1_DIGEST_SIZE); - } - else - { - rv = pkcs11_util_convert_rv(status); - } - } + { + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t buffer[1 + ATCA_ECCP256_PUBKEY_SIZE] = {0x04}; + + if (is_private) + { + ATCADeviceType dev_type = atcab_get_device_type(); + if (atcab_is_ca_device(dev_type)) + { +#if ATCA_CA_SUPPORT + status = atcab_get_pubkey(obj_ptr->slot, &buffer[1]); + PKCS11_DEBUG("atcab_get_pubkey: %x\r\n", status); +#endif + } + else if (atcab_is_ta_device(dev_type)) + { +#if ATCA_TA_SUPPORT + status = pkcs11_ta_get_pubkey(pObject,&buffer[1]); +#endif + } + } + else + { + status = atcab_read_pubkey(obj_ptr->slot, &buffer[1]); + PKCS11_DEBUG("atcab_read_pubkey: %x\r\n", status); + } + + if (ATCA_SUCCESS == status) + { + status = atcac_sw_sha1(buffer, sizeof(buffer), buffer); + } + + if (ATCA_SUCCESS == status) + { + rv = pkcs11_attrib_fill(pAttribute, buffer, ATCA_SHA1_DIGEST_SIZE); + } + else + { + pkcs11_attrib_empty(pObject,pAttribute); + PKCS11_DEBUG("Couldnt generate public key\r\n", status); + rv = CKR_OK; + } + } } else { @@ -477,73 +570,73 @@ static CK_RV pkcs11_key_get_id(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAttribute) */ const pkcs11_attrib_model pkcs11_key_public_attributes[] = { /** Object Class - CK_OBJECT_CLASS */ - { CKA_CLASS, pkcs11_object_get_class }, + { CKA_CLASS, pkcs11_object_get_class }, /** CK_TRUE if object is a token object; CK_FALSE if object is a session object. Default is CK_FALSE. */ - { CKA_TOKEN, pkcs11_attrib_true }, + { CKA_TOKEN, pkcs11_attrib_true }, /** CK_TRUE if object is a private object; CK_FALSE if object is a public object. */ - { CKA_PRIVATE, pkcs11_attrib_false }, + { CKA_PRIVATE, pkcs11_attrib_false }, /** CK_TRUE if object can be modified. Default is CK_TRUE. */ - { CKA_MODIFIABLE, pkcs11_token_get_writable }, + { CKA_MODIFIABLE, pkcs11_token_get_writable }, /** Description of the object(default empty). */ - { CKA_LABEL, pkcs11_object_get_name }, + { CKA_LABEL, pkcs11_object_get_name }, /** CK_TRUE if object can be copied using C_CopyObject.Defaults to CK_TRUE. */ - { CKA_COPYABLE, pkcs11_attrib_false }, + { CKA_COPYABLE, pkcs11_attrib_false }, /** CK_TRUE if the object can be destroyed using C_DestroyObject. Default is CK_TRUE. */ - { CKA_DESTROYABLE, pkcs11_object_get_destroyable }, + { CKA_DESTROYABLE, pkcs11_object_get_destroyable }, /** Type of key */ - { CKA_KEY_TYPE, pkcs11_object_get_type }, + { CKA_KEY_TYPE, pkcs11_object_get_type }, /** Key identifier for key (default empty) */ { CKA_ID, pkcs11_key_get_id }, /** Start date for the key (default empty) */ - { CKA_START_DATE, pkcs11_attrib_empty }, + { CKA_START_DATE, pkcs11_attrib_empty }, /** End date for the key (default empty) */ - { CKA_END_DATE, pkcs11_attrib_empty }, + { CKA_END_DATE, pkcs11_attrib_empty }, /** CK_TRUE if key supports key derivation (i.e., if other keys can be derived from this one (default CK_FALSE) */ - { CKA_DERIVE, pkcs11_key_get_derivekey_flag }, + { CKA_DERIVE, pkcs11_key_get_derivekey_flag }, /** CK_TRUE only if key was either generated locally (i.e., on the token) with a C_GenerateKey or C_GenerateKeyPair call created with a C_CopyObject call as a copy of a key which had its CKA_LOCAL attribute set to CK_TRUE */ - { CKA_LOCAL, pkcs11_attrib_true }, + { CKA_LOCAL, pkcs11_attrib_true }, /** Identifier of the mechanism used to generate the key material. */ - { CKA_KEY_GEN_MECHANISM, NULL_PTR }, + { CKA_KEY_GEN_MECHANISM, NULL_PTR }, /** A list of mechanisms allowed to be used with this key. The number of mechanisms in the array is the ulValueLen component of the attribute divided by the size of CK_MECHANISM_TYPE. */ - { CKA_ALLOWED_MECHANISMS, pkcs11_key_get_allowed_mechanisms }, + { CKA_ALLOWED_MECHANISMS, pkcs11_key_get_allowed_mechanisms }, /** DER-encoding of the key subject name (default empty) */ - { CKA_SUBJECT, pkcs11_attrib_empty }, + { CKA_SUBJECT, pkcs11_attrib_empty }, /** CK_TRUE if key supports encryption */ - { CKA_ENCRYPT, NULL_PTR }, + { CKA_ENCRYPT, NULL_PTR }, /** CK_TRUE if key supports verification where the signature is an appendix to the data */ - { CKA_VERIFY, pkcs11_attrib_true }, + { CKA_VERIFY, pkcs11_attrib_true }, /** CK_TRUE if key supports verification where the data is recovered from the signature */ - { CKA_VERIFY_RECOVER, NULL_PTR }, + { CKA_VERIFY_RECOVER, NULL_PTR }, /** CK_TRUE if key supports wrapping (i.e., can be used to wrap other keys) */ - { CKA_WRAP, NULL_PTR }, + { CKA_WRAP, NULL_PTR }, /** The key can be trusted for the application that it was created. The wrapping key can be used to wrap keys with CKA_WRAP_WITH_TRUSTED set to CK_TRUE. */ - { CKA_TRUSTED, NULL_PTR }, + { CKA_TRUSTED, NULL_PTR }, /** For wrapping keys. The attribute template to match against any keys wrapped using this wrapping key. Keys that do not match cannot be wrapped. The number of attributes in the array is the ulValueLen component of the attribute divided by the size of CK_ATTRIBUTE. */ - { CKA_WRAP_TEMPLATE, NULL_PTR }, + { CKA_WRAP_TEMPLATE, NULL_PTR }, /** DER-encoding of the SubjectPublicKeyInfo for this public key. (MAY be empty, DEFAULT derived from the underlying public key data) SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT_STRING } */ - { CKA_PUBLIC_KEY_INFO, pkcs11_key_get_public_key }, + { CKA_PUBLIC_KEY_INFO, pkcs11_key_get_public_key }, /** DER - encoding of an ANSI X9.62 Parameters value Parameters ::= CHOICE { ecParameters ECParameters, namedCurve CURVES.&id({CurveNames}), implicitlyCA NULL } */ - { CKA_EC_PARAMS, pkcs11_key_get_ec_params }, + { CKA_EC_PARAMS, pkcs11_key_get_ec_params }, /** DER - encoding of ANSI X9.62 ECPoint value Q */ - { CKA_EC_POINT, pkcs11_key_get_ec_point }, + { CKA_EC_POINT, pkcs11_key_get_ec_point }, }; const CK_ULONG pkcs11_key_public_attributes_count = PKCS11_UTIL_ARRAY_SIZE(pkcs11_key_public_attributes); @@ -557,9 +650,9 @@ const pkcs11_attrib_model pkcs11_key_ec_public_attributes[] = { ecParameters ECParameters, namedCurve CURVES.&id({CurveNames}), implicitlyCA NULL } */ - { CKA_EC_PARAMS, pkcs11_key_get_ec_params }, + { CKA_EC_PARAMS, pkcs11_key_get_ec_params }, /** DER - encoding of ANSI X9.62 ECPoint value Q */ - { CKA_EC_POINT, pkcs11_key_get_ec_point }, + { CKA_EC_POINT, pkcs11_key_get_ec_point }, }; /** @@ -567,81 +660,81 @@ const pkcs11_attrib_model pkcs11_key_ec_public_attributes[] = { */ const pkcs11_attrib_model pkcs11_key_private_attributes[] = { /** Object Class - CK_OBJECT_CLASS */ - { CKA_CLASS, pkcs11_object_get_class }, + { CKA_CLASS, pkcs11_object_get_class }, /** CK_TRUE if object is a token object; CK_FALSE if object is a session object. Default is CK_FALSE. */ - { CKA_TOKEN, pkcs11_attrib_true }, + { CKA_TOKEN, pkcs11_attrib_true }, /** CK_TRUE if object is a private object; CK_FALSE if object is a public object. */ - { CKA_PRIVATE, pkcs11_attrib_true }, + { CKA_PRIVATE, pkcs11_attrib_true }, /** CK_TRUE if object can be modified. Default is CK_TRUE. */ - { CKA_MODIFIABLE, pkcs11_token_get_writable }, + { CKA_MODIFIABLE, pkcs11_token_get_writable }, /** Description of the object(default empty). */ - { CKA_LABEL, pkcs11_object_get_name }, + { CKA_LABEL, pkcs11_object_get_name }, /** CK_TRUE if object can be copied using C_CopyObject.Defaults to CK_TRUE. */ - { CKA_COPYABLE, pkcs11_attrib_false }, + { CKA_COPYABLE, pkcs11_attrib_false }, /** CK_TRUE if the object can be destroyed using C_DestroyObject. Default is CK_TRUE. */ - { CKA_DESTROYABLE, pkcs11_object_get_destroyable }, + { CKA_DESTROYABLE, pkcs11_object_get_destroyable }, /** Type of key */ - { CKA_KEY_TYPE, pkcs11_object_get_type }, + { CKA_KEY_TYPE, pkcs11_object_get_type }, /** Key identifier for key (default empty) */ { CKA_ID, pkcs11_key_get_id }, /** Start date for the key (default empty) */ - { CKA_START_DATE, pkcs11_attrib_empty }, + { CKA_START_DATE, pkcs11_attrib_empty }, /** End date for the key (default empty) */ - { CKA_END_DATE, pkcs11_attrib_empty }, + { CKA_END_DATE, pkcs11_attrib_empty }, /** CK_TRUE if key supports key derivation (i.e., if other keys can be derived from this one (default CK_FALSE) */ - { CKA_DERIVE, pkcs11_key_get_derivekey_flag }, + { CKA_DERIVE, pkcs11_key_get_derivekey_flag }, /** CK_TRUE only if key was either generated locally (i.e., on the token) with a C_GenerateKey or C_GenerateKeyPair call created with a C_CopyObject call as a copy of a key which had its CKA_LOCAL attribute set to CK_TRUE */ - { CKA_LOCAL, pkcs11_key_get_local_flag }, + { CKA_LOCAL, pkcs11_key_get_local_flag }, /** Identifier of the mechanism used to generate the key material. */ - { CKA_KEY_GEN_MECHANISM, NULL_PTR }, + { CKA_KEY_GEN_MECHANISM, NULL_PTR }, /** A list of mechanisms allowed to be used with this key. The number of mechanisms in the array is the ulValueLen component of the attribute divided by the size of CK_MECHANISM_TYPE. */ - { CKA_ALLOWED_MECHANISMS, pkcs11_key_get_allowed_mechanisms }, + { CKA_ALLOWED_MECHANISMS, pkcs11_key_get_allowed_mechanisms }, /** DER-encoding of the key subject name (default empty) */ - { CKA_SUBJECT, pkcs11_attrib_empty }, + { CKA_SUBJECT, pkcs11_attrib_empty }, /** CK_TRUE if key is sensitive */ - { CKA_SENSITIVE, pkcs11_token_get_access_type }, + { CKA_SENSITIVE, pkcs11_token_get_access_type }, /** CK_TRUE if key supports decryption */ - { CKA_DECRYPT, NULL_PTR }, + { CKA_DECRYPT, NULL_PTR }, /** CK_TRUE if key supports signatures where the signature is an appendix to the data */ - { CKA_SIGN, pkcs11_attrib_true }, + { CKA_SIGN, pkcs11_attrib_true }, /** CK_TRUE if key supports signatures where the data can be recovered from the signature9 */ - { CKA_SIGN_RECOVER, NULL_PTR }, + { CKA_SIGN_RECOVER, NULL_PTR }, /** CK_TRUE if key supports unwrapping (i.e., can be used to unwrap other keys)9 */ { CKA_UNWRAP, NULL_PTR }, /** CK_TRUE if key is extractable and can be wrapped */ { CKA_EXTRACTABLE, pkcs11_attrib_false }, /** CK_TRUE if key has always had the CKA_SENSITIVE attribute set to CK_TRUE */ - { CKA_ALWAYS_SENSITIVE, pkcs11_token_get_access_type }, + { CKA_ALWAYS_SENSITIVE, pkcs11_token_get_access_type }, /** CK_TRUE if key has never had the CKA_EXTRACTABLE attribute set to CK_TRUE */ { CKA_NEVER_EXTRACTABLE, pkcs11_token_get_access_type }, /** CK_TRUE if the key can only be wrapped with a wrapping key that has CKA_TRUSTED set to CK_TRUE. Default is CK_FALSE. */ - { CKA_WRAP_WITH_TRUSTED, NULL_PTR }, + { CKA_WRAP_WITH_TRUSTED, NULL_PTR }, /** For wrapping keys. The attribute template to match against any keys wrapped using this wrapping key. Keys that do not match cannot be wrapped. The number of attributes in the array is the ulValueLen component of the attribute divided by the size of CK_ATTRIBUTE. */ - { CKA_UNWRAP_TEMPLATE, NULL_PTR }, + { CKA_UNWRAP_TEMPLATE, NULL_PTR }, /** If CK_TRUE, the user has to supply the PIN for each use (sign or decrypt) with the key. Default is CK_FALSE. */ - { CKA_ALWAYS_AUTHENTICATE, pkcs11_key_auth_required }, + { CKA_ALWAYS_AUTHENTICATE, pkcs11_key_auth_required }, /** DER-encoding of the SubjectPublicKeyInfo for the associated public key (MAY be empty; DEFAULT derived from the underlying private key data; MAY be manually set for specific key types; if set; MUST be consistent with the underlying private key data) */ - { CKA_PUBLIC_KEY_INFO, pkcs11_key_get_public_key }, + { CKA_PUBLIC_KEY_INFO, pkcs11_key_get_public_key }, /** DER - encoding of an ANSI X9.62 Parameters value Parameters ::= CHOICE { ecParameters ECParameters, namedCurve CURVES.&id({CurveNames}), implicitlyCA NULL } */ - { CKA_EC_PARAMS, pkcs11_key_get_ec_params }, + { CKA_EC_PARAMS, pkcs11_key_get_ec_params }, /** DER - encoding of ANSI X9.62 ECPoint value Q */ - { CKA_EC_POINT, pkcs11_key_get_ec_point }, + { CKA_EC_POINT, pkcs11_key_get_ec_point }, /** The value of the private key should remain private. A NULL function pointer is interpreted as a sensitive attribute. */ - { CKA_VALUE, NULL_PTR }, + { CKA_VALUE, NULL_PTR }, }; const CK_ULONG pkcs11_key_private_attributes_count = PKCS11_UTIL_ARRAY_SIZE(pkcs11_key_private_attributes); @@ -651,21 +744,21 @@ const CK_ULONG pkcs11_key_private_attributes_count = PKCS11_UTIL_ARRAY_SIZE(pkcs */ const pkcs11_attrib_model pkcs11_key_rsa_private_attributes[] = { /** Big integer Modulus n */ - { CKA_MODULUS, NULL_PTR }, + { CKA_MODULUS, NULL_PTR }, /** Big integer Public exponent e */ - { CKA_PUBLIC_EXPONENT, NULL_PTR }, + { CKA_PUBLIC_EXPONENT, NULL_PTR }, /** Big integer Private exponent d */ - { CKA_PRIVATE_EXPONENT, NULL_PTR }, + { CKA_PRIVATE_EXPONENT, NULL_PTR }, /** Big integer Prime p */ - { CKA_PRIME_1, NULL_PTR }, + { CKA_PRIME_1, NULL_PTR }, /** Big integer Prime q */ - { CKA_PRIME_2, NULL_PTR }, + { CKA_PRIME_2, NULL_PTR }, /** Big integer Private exponent d modulo p - 1 */ - { CKA_EXPONENT_1, NULL_PTR }, + { CKA_EXPONENT_1, NULL_PTR }, /** Big integer Private exponent d modulo q - 1 */ - { CKA_EXPONENT_2, NULL_PTR }, + { CKA_EXPONENT_2, NULL_PTR }, /** Big integer CRT coefficient q - 1 mod p */ - { CKA_COEFFICIENT, NULL_PTR }, + { CKA_COEFFICIENT, NULL_PTR }, }; /** @@ -677,9 +770,9 @@ const pkcs11_attrib_model pkcs11_key_ec_private_attributes[] = { ecParameters ECParameters, namedCurve CURVES.&id({CurveNames}), implicitlyCA NULL } */ - { CKA_EC_PARAMS, pkcs11_key_get_ec_params }, + { CKA_EC_PARAMS, pkcs11_key_get_ec_params }, /** DER - encoding of ANSI X9.62 ECPoint value Q */ - { CKA_EC_POINT, pkcs11_key_get_ec_point }, + { CKA_EC_POINT, pkcs11_key_get_ec_point }, }; @@ -688,82 +781,82 @@ const pkcs11_attrib_model pkcs11_key_ec_private_attributes[] = { */ const pkcs11_attrib_model pkcs11_key_secret_attributes[] = { /** Object Class - CK_OBJECT_CLASS */ - { CKA_CLASS, pkcs11_object_get_class }, + { CKA_CLASS, pkcs11_object_get_class }, /** CK_TRUE if object is a token object; CK_FALSE if object is a session object. Default is CK_FALSE. */ - { CKA_TOKEN, pkcs11_token_get_storage }, + { CKA_TOKEN, pkcs11_token_get_storage }, /** CK_TRUE if object is a private object; CK_FALSE if object is a public object. */ - { CKA_PRIVATE, pkcs11_token_get_access_type }, + { CKA_PRIVATE, pkcs11_token_get_access_type }, /** CK_TRUE if object can be modified. Default is CK_TRUE. */ - { CKA_MODIFIABLE, pkcs11_token_get_writable }, + { CKA_MODIFIABLE, pkcs11_token_get_writable }, /** Description of the object(default empty). */ - { CKA_LABEL, pkcs11_object_get_name }, + { CKA_LABEL, pkcs11_object_get_name }, /** CK_TRUE if object can be copied using C_CopyObject.Defaults to CK_TRUE. */ - { CKA_COPYABLE, pkcs11_attrib_false }, + { CKA_COPYABLE, pkcs11_attrib_false }, /** CK_TRUE if the object can be destroyed using C_DestroyObject. Default is CK_TRUE. */ - { CKA_DESTROYABLE, pkcs11_object_get_destroyable }, + { CKA_DESTROYABLE, pkcs11_object_get_destroyable }, /** Type of key */ - { CKA_KEY_TYPE, pkcs11_object_get_type }, + { CKA_KEY_TYPE, pkcs11_object_get_type }, /** Key identifier for key (default empty) */ - { CKA_ID, pkcs11_attrib_empty }, + { CKA_ID, pkcs11_attrib_empty }, /** Start date for the key (default empty) */ - { CKA_START_DATE, pkcs11_attrib_empty }, + { CKA_START_DATE, pkcs11_attrib_empty }, /** End date for the key (default empty) */ - { CKA_END_DATE, pkcs11_attrib_empty }, + { CKA_END_DATE, pkcs11_attrib_empty }, /** CK_TRUE if key supports key derivation (i.e., if other keys can be derived from this one (default CK_FALSE) */ - { CKA_DERIVE, pkcs11_attrib_true }, + { CKA_DERIVE, pkcs11_attrib_true }, /** CK_TRUE only if key was either generated locally (i.e., on the token) with a C_GenerateKey or C_GenerateKeyPair call created with a C_CopyObject call as a copy of a key which had its CKA_LOCAL attribute set to CK_TRUE */ - { CKA_LOCAL, pkcs11_key_get_local_flag }, + { CKA_LOCAL, pkcs11_key_get_local_flag }, /** Identifier of the mechanism used to generate the key material. */ - { CKA_KEY_GEN_MECHANISM, NULL_PTR }, + { CKA_KEY_GEN_MECHANISM, NULL_PTR }, /** A list of mechanisms allowed to be used with this key. The number of mechanisms in the array is the ulValueLen component of the attribute divided by the size of CK_MECHANISM_TYPE. */ - { CKA_ALLOWED_MECHANISMS, pkcs11_key_get_allowed_mechanisms }, + { CKA_ALLOWED_MECHANISMS, pkcs11_key_get_allowed_mechanisms }, /** CK_TRUE if key is sensitive */ - { CKA_SENSITIVE, pkcs11_token_get_access_type }, + { CKA_SENSITIVE, pkcs11_token_get_access_type }, /** CK_TRUE if key supports encryption */ - { CKA_ENCRYPT, NULL_PTR }, + { CKA_ENCRYPT, NULL_PTR }, /** CK_TRUE if key supports decryption */ - { CKA_DECRYPT, NULL_PTR }, + { CKA_DECRYPT, NULL_PTR }, /** CK_TRUE if key supports signatures (i.e., authentication codes) where the signature is an appendix to the data */ - { CKA_SIGN, NULL_PTR }, + { CKA_SIGN, NULL_PTR }, /** CK_TRUE if key supports verification (i.e., of authentication codes) where the signature is an appendix to the data */ - { CKA_VERIFY, NULL_PTR }, + { CKA_VERIFY, NULL_PTR }, /** CK_TRUE if key supports wrapping (i.e., can be used to wrap other keys) */ - { CKA_WRAP, NULL_PTR }, + { CKA_WRAP, NULL_PTR }, /** CK_TRUE if key supports unwrapping (i.e., can be used to unwrap other keys) */ - { CKA_UNWRAP, NULL_PTR }, + { CKA_UNWRAP, NULL_PTR }, /** CK_TRUE if key is extractable and can be wrapped */ { CKA_EXTRACTABLE, pkcs11_attrib_false }, /** CK_TRUE if key has always had the CKA_SENSITIVE attribute set to CK_TRUE */ - { CKA_ALWAYS_SENSITIVE, pkcs11_token_get_access_type }, + { CKA_ALWAYS_SENSITIVE, pkcs11_token_get_access_type }, /** CK_TRUE if key has never had the CKA_EXTRACTABLE attribute set to CK_TRUE */ { CKA_NEVER_EXTRACTABLE, pkcs11_token_get_access_type }, /** Key checksum */ - { CKA_CHECK_VALUE, pkcs11_key_get_check_value }, + { CKA_CHECK_VALUE, pkcs11_key_get_check_value }, /** CK_TRUE if the key can only be wrapped with a wrapping key that has CKA_TRUSTED set to CK_TRUE. Default is CK_FALSE. */ - { CKA_WRAP_WITH_TRUSTED, NULL_PTR }, + { CKA_WRAP_WITH_TRUSTED, NULL_PTR }, /** The wrapping key can be used to wrap keys with CKA_WRAP_WITH_TRUSTED set to CK_TRUE. */ - { CKA_TRUSTED, NULL_PTR }, + { CKA_TRUSTED, NULL_PTR }, /** For wrapping keys. The attribute template to match against any keys wrapped using this wrapping key. Keys that do not match cannot be wrapped. The number of attributes in the array is the ulValueLen component of the attribute divided by the size of CK_ATTRIBUTE */ - { CKA_WRAP_TEMPLATE, NULL_PTR }, + { CKA_WRAP_TEMPLATE, NULL_PTR }, /** For wrapping keys. The attribute template to apply to any keys unwrapped using this wrapping key. Any user supplied template is applied after this template as if the object has already been created. The number of attributes in the array is the ulValueLen component of the attribute divided by the size of CK_ATTRIBUTE. */ - { CKA_UNWRAP_TEMPLATE, NULL_PTR }, + { CKA_UNWRAP_TEMPLATE, NULL_PTR }, /* Key value */ - { CKA_VALUE, pkcs11_key_get_secret }, + { CKA_VALUE, pkcs11_key_get_secret }, /* Length in bytes of the key */ - { CKA_VALUE_LEN, pkcs11_key_get_secret_length }, + { CKA_VALUE_LEN, pkcs11_key_get_secret_length }, }; const CK_ULONG pkcs11_key_secret_attributes_count = PKCS11_UTIL_ARRAY_SIZE(pkcs11_key_secret_attributes); @@ -944,25 +1037,25 @@ CK_RV pkcs11_key_generate { #if ATCA_CA_SUPPORT uint8_t buf[32]; - atecc508a_config_t * pConfig = (atecc508a_config_t*)pKey->config; + atecc508a_config_t * pConfig = (atecc508a_config_t*)pKey->config; - if (pConfig->KeyConfig[pKey->slot] & 0x0018) - { - if (pConfig->SlotConfig[pKey->slot] & 0x2000) + if (pConfig->KeyConfig[pKey->slot] & 0x0018) { - if (ATCA_SUCCESS == (status = atcab_nonce_rand(buf, NULL))) + if (pConfig->SlotConfig[pKey->slot] & 0x2000) { - status = atcab_derivekey(0, pKey->slot, NULL); + if (ATCA_SUCCESS == (status = atcab_nonce_rand(buf, NULL))) + { + status = atcab_derivekey(0, pKey->slot, NULL); + } } - } - else - { - if (ATCA_SUCCESS == (status = atcab_random(buf))) + else { - status = atcab_write_bytes_zone(ATCA_ZONE_DATA, pKey->slot, 0, buf, 32); + if (ATCA_SUCCESS == (status = atcab_random(buf))) + { + status = atcab_write_bytes_zone(ATCA_ZONE_DATA, pKey->slot, 0, buf, 32); + } } } - } #endif } else @@ -1192,48 +1285,48 @@ static CK_RV pkcs11_key_derive_ca(pkcs11_session_ctx_ptr pSession, pkcs11_object if (CKR_OK == (rv = pkcs11_lock_both(pLibCtx))) { - /* Because of the number of ECDH options this function unfortunately has a complex bit of logic - to walk through to select the proper ECDH command. Normally this would be left up to the user - to chose */ + /* Because of the number of ECDH options this function unfortunately has a complex bit of logic + to walk through to select the proper ECDH command. Normally this would be left up to the user + to chose */ - if (ATCA_TEMPKEY_KEYID == pBaseKey->slot) - { - if (pSession->slot->logged_in) - { - status = atcab_ecdh_tempkey_ioenc(&pEcdhParameters->pPublicData[1], pSecretKey->data, pSession->slot->read_key); - } - else - { - status = atcab_ecdh_tempkey(&pEcdhParameters->pPublicData[1], pSecretKey->data); - } - } - else if (16 > pBaseKey->slot) - { - if (ATCA_SLOT_CONFIG_WRITE_ECDH_MASK & pSession->slot->cfg_zone.SlotConfig[pBaseKey->slot]) - { - uint8_t num_in[32] = { 0, 1, 2, 3 }; - uint16_t read_key_id = (ATCA_SLOT_CONFIG_READKEY_MASK & pSession->slot->cfg_zone.SlotConfig[pBaseKey->slot | 0x01]) - >> ATCA_SLOT_CONFIG_READKEY_SHIFT; - status = atcab_ecdh_enc(pBaseKey->slot, &pEcdhParameters->pPublicData[1], pSecretKey->data, - pSession->slot->read_key, read_key_id, num_in); - } - else if ((ATECC508A != pSession->slot->interface_config.devtype) && - (ATCA_CHIP_OPT_IO_PROT_EN_MASK & pSession->slot->cfg_zone.ChipOptions) && - pSession->slot->logged_in) - { - status = atcab_ecdh_ioenc(pBaseKey->slot, &pEcdhParameters->pPublicData[1], pSecretKey->data, pSession->slot->read_key); - } - else - { - status = atcab_ecdh(pBaseKey->slot, &pEcdhParameters->pPublicData[1], pSecretKey->data); - } - } - else - { - status = ATCA_GEN_FAIL; - } + if (ATCA_TEMPKEY_KEYID == pBaseKey->slot) + { + if (pSession->slot->logged_in) + { + status = atcab_ecdh_tempkey_ioenc(&pEcdhParameters->pPublicData[1], pSecretKey->data, pSession->slot->read_key); + } + else + { + status = atcab_ecdh_tempkey(&pEcdhParameters->pPublicData[1], pSecretKey->data); + } + } + else if (16 > pBaseKey->slot) + { + if (ATCA_SLOT_CONFIG_WRITE_ECDH_MASK & pSession->slot->cfg_zone.SlotConfig[pBaseKey->slot]) + { + uint8_t num_in[32] = { 0, 1, 2, 3 }; + uint16_t read_key_id = (ATCA_SLOT_CONFIG_READKEY_MASK & pSession->slot->cfg_zone.SlotConfig[pBaseKey->slot | 0x01]) + >> ATCA_SLOT_CONFIG_READKEY_SHIFT; + status = atcab_ecdh_enc(pBaseKey->slot, &pEcdhParameters->pPublicData[1], pSecretKey->data, + pSession->slot->read_key, read_key_id, num_in); + } + else if ((ATECC508A != pSession->slot->interface_config.devtype) && + (ATCA_CHIP_OPT_IO_PROT_EN_MASK & pSession->slot->cfg_zone.ChipOptions) && + pSession->slot->logged_in) + { + status = atcab_ecdh_ioenc(pBaseKey->slot, &pEcdhParameters->pPublicData[1], pSecretKey->data, pSession->slot->read_key); + } + else + { + status = atcab_ecdh(pBaseKey->slot, &pEcdhParameters->pPublicData[1], pSecretKey->data); + } + } + else + { + status = ATCA_GEN_FAIL; + } (void)pkcs11_unlock_both(pLibCtx); - + } #endif } diff --git a/lib/pkcs11/pkcs11_session.c b/lib/pkcs11/pkcs11_session.c index 5654bbe9c..896d75ff5 100644 --- a/lib/pkcs11/pkcs11_session.c +++ b/lib/pkcs11/pkcs11_session.c @@ -426,9 +426,14 @@ CK_RV pkcs11_session_login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType, CK uint8_t auth_i_nonce[16]; uint8_t auth_r_nonce[16]; +#if PKCS11_AUTH_TERMINATE_BEFORE_LOGIN + ATCADevice device = atcab_get_device(); + device->session_key_id = TA_HANDLE_AUTH_SESSION; + status = talib_auth_terminate(device); +#endif (void)atcac_sw_random(auth_r_nonce, sizeof(auth_r_nonce)); - status = talib_auth_generate_nonce(_gDevice, 0x4100, + status = talib_auth_generate_nonce(atcab_get_device(), TA_HANDLE_AUTH_SESSION, TA_AUTH_GENERATE_OPT_NONCE_SRC_MASK | TA_AUTH_GENERATE_OPT_RANDOM_MASK, auth_i_nonce); if (CKR_OK == (rv = pkcs11_util_convert_rv(status))) @@ -440,6 +445,7 @@ CK_RV pkcs11_session_login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType, CK if (CKR_OK != rv) { + PKCS11_DEBUG(" Login failed: Terminating auth session\r\n"); (void)talib_auth_terminate(atcab_get_device()); } } diff --git a/module.xml b/module.xml index 2d2ece637..98adece0f 100644 --- a/module.xml +++ b/module.xml @@ -1,4 +1,4 @@ - + diff --git a/python/cryptoauthlib/iface.py b/python/cryptoauthlib/iface.py index 2d5d2cc7e..455cf9f91 100644 --- a/python/cryptoauthlib/iface.py +++ b/python/cryptoauthlib/iface.py @@ -69,8 +69,16 @@ class ATCADeviceType(AtcaEnum): ATECC608B = 3 ATECC608 = 3 ATSHA206A = 4 - ECC204 = 5 - ATCA_DEV_UNKNOWN = 0x20 + TA100 = 0x10 + ECC204 = 0x20 + TA010 = 0x21 + ECC206 = 0x22 + RNG90 = 0x23 + SHA104 = 0x24 + SHA105 = 0x25 + SHA106 = 0x26 + ATCA_DEV_UNKNOWN = 0x7E + ATCA_DEV_INVALID = 0x7F # The following must match atca_iface.h exactly diff --git a/python/cryptoauthlib/library.py b/python/cryptoauthlib/library.py index 3649b20cb..6ed99c5d5 100644 --- a/python/cryptoauthlib/library.py +++ b/python/cryptoauthlib/library.py @@ -140,27 +140,48 @@ def get_device_name(revision): devices = {0x10: 'ATECC108A', 0x50: 'ATECC508A', 0x60: 'ATECC608', - 0x20: 'ECC204', + 0x20: get_device_name_with_device_id(revision), 0x00: 'ATSHA204A', 0x02: 'ATSHA204A', 0x40: 'ATSHA206A'} device_name = devices.get(revision[2], 'UNKNOWN') return device_name +def get_device_name_with_device_id(revision): + """ + Returns the device name based on the info byte array values returned by atcab_info for ECC204 family + """ + devices = {0x00: 'ECC204', + 0x5A: 'ECC204', + 0x6A: 'TA010', + 0x35: 'SHA104', + 0x3B: 'SHA105'} + + device_name = devices.get(revision[1], 'UNKNOWN') + return device_name def get_device_type_id(name): """ Returns the ATCADeviceType value based on the device name """ - devices = {'ATSHA204A': 0, + devices = { 'ATSHA204A': 0, 'ATECC108A': 1, 'ATECC508A': 2, 'ATECC608A': 3, 'ATECC608B': 3, 'ATECC608': 3, - 'ATSAH206A': 4, - 'ECC204': 5, - 'UNKNOWN': 0x20} + 'ATSHA206A': 4, + 'TA100': 0x10, + 'ECC204': 0x20, + 'TA010': 0x21, + 'ECC206': 0x22, + 'RNG90': 0x23, + 'SHA104': 0x24, + 'SHA105': 0x25, + 'SHA106': 0x26, + 'UNKNOWN': 0x7E, + 'INVALID': 0x7F, + } return devices.get(name.upper()) diff --git a/python/setup.py b/python/setup.py index 706574c16..46e2e722d 100644 --- a/python/setup.py +++ b/python/setup.py @@ -231,6 +231,6 @@ def has_ext_modules(self): setup_requires=['setuptools>=38.6.0', 'wheel'], install_requires=['enum34;python_version<"3.4"'], ext_modules=_EXTENSIONS, - python_requires='>=3.4.*', + python_requires='>=3.8.0', zip_safe=False ) diff --git a/python/tox.ini b/python/tox.ini index 5db951cb2..a2aa94f2c 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pylint,py27,py35,py36,py37 +envlist = pylint,py38,py39,py310 skipsdist = True [testenv:pylint] @@ -11,7 +11,6 @@ passenv = * deps = pytest pytest-cov cryptography - py27: enum34 pytz pyjwt commands = python setup.py bdist_wheel diff --git a/release_notes.md b/release_notes.md index 690cc25be..e8767132e 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,6 +1,54 @@ # Microchip Cryptoauthlib Release Notes +## Release v3.5.0 (03/14/2023) + +### New + - Add support for ECC204, TA010 and framework for future devices + +## Release v3.4.3 (12/23/2022) + +### New + - Add key load mode flags for FCE config command + +### Fixes + - WPC certificate reconstruction buffer length was too short + - ECC204 block Read/Write did not write remaining bytes if the provided buffer was + not padded to a 32 byte bounary + - TA100 lock CRC was being passed with the native endianness. + - ECC204 nonce command was missing the mode bit to emit a random number when called + with the intention of producing random bytes + + +## Release v3.4.2 (12/04/2022) + +### Fixes + - PKCS11: Correct init/deinit failures from initialization mutex options. These + would manifest as a segmentation fault on deinit, unterminated authorization + sessions, or library already initialized return codes based on the configuration + and inititialization data. + - PKCS11: Added configuration option to always terminate authorization sessions on + library initialization to work around applications that may fail to call C_CloseSession + or C_Finalize before exiting. + - PKCS11: Fix failures in C_DigestInit resulting from failing to check the session + state before checking the requested digest mechanism type. + - PKCS11: Modify how the library returns public key information based on access levels + of the private key (generate from the private key if allowed, read from a linked public + key, and finally return data unavailable). For the vast majority of situtations this + prevents openssl & libp11 from crashing with segmentation faults if the user fails to + provide a pkcs11 URI with pin value specified. These segmentation faults were confirmed + to also exist with other PKCS11 libraries - the fundamental problem should be taken up + with the maintainers of openssl, libp11, and pkcs11-provider (experimental OpenSSL + 3.0 PKCS11 support). + - Modified CBC update/finish APIs (added as an experimental API in v3.4.0) to match + standard expectations of how the APIs would function. Updated algorithm tests + to reflect this usage. + - PKCS11: Updated encrypt/decrypt in cbc/cbcpad modes to use the updated algorithm + implementations + - talib full element read & write functions now account for the maximum packet size + based on session state. + + ## Release v3.4.1 (11/11/2022) ### Fixes diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d13733249..688f5e7f1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.10) project (cryptoauth_test C) option (ATCA_TEST_LOCK_ENABLE "Enable device locking functions and tests" OFF) +option (ATCA_TEST_DELETE_ENABLE "Enable device wiping functions and tests" OFF) file(GLOB TEST_ATCACERT_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "atcacert/*.c") file(GLOB TEST_JWT_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "jwt/*.c") @@ -88,6 +89,10 @@ if(ATCA_TEST_LOCK_ENABLE) target_compile_definitions(cryptoauth_test PUBLIC -DATCA_TEST_LOCK_ENABLE) endif(ATCA_TEST_LOCK_ENABLE) +if(ATCA_TEST_DELETE_ENABLE) +target_compile_definitions(cryptoauth_test PUBLIC -DATCA_TEST_DELETE_ENABLE) +endif(ATCA_TEST_DELETE_ENABLE) + set_property(TARGET cryptoauth_test PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "$(OutputPath)") add_custom_command(TARGET cryptoauth_test POST_BUILD diff --git a/test/README.md b/test/README.md index e591ea511..719bf4f32 100644 --- a/test/README.md +++ b/test/README.md @@ -78,6 +78,7 @@ Commands * sha206 - Select ATSHA206A * ecc108 - Select ATECC108A * ecc204 - Select ECC204 +* ta010 - Select TA010 * ecc508 - Select ATECC508A * ecc608 - Select ATECC608A/B * ta100 - Select TA100 @@ -131,6 +132,7 @@ macro is enabled: * sha206 * ecc108 * ecc204 +* ta010 * ecc508 * ecc608 * ta100 diff --git a/test/api_atcab/atca_tests_aes.c b/test/api_atcab/atca_tests_aes.c index 432027910..3de09dead 100644 --- a/test/api_atcab/atca_tests_aes.c +++ b/test/api_atcab/atca_tests_aes.c @@ -378,18 +378,18 @@ TEST(atca_cmd_basic_test, volatile_key_permit) t_test_case_info aes_basic_test_info[] = { #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, volatile_key_permit), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gfm), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_encrypt_key_tempkey), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_decrypt_key_tempkey), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_encrypt_key_slot), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_decrypt_key_slot), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, volatile_key_permit), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gfm), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_encrypt_key_tempkey), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_decrypt_key_tempkey), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_encrypt_key_slot), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_decrypt_key_slot), atca_test_cond_ecc608 }, #endif #if TEST_ATCAB_AES_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_encrypt_key_slot_simple), DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_decrypt_key_slot_simple), DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_encrypt_key_slot_simple), atca_test_cond_ta100 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_decrypt_key_slot_simple), atca_test_cond_ta100 }, #endif /* Array Termination element*/ - { (fp_test_case)NULL, (uint8_t)0 }, + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* diff --git a/test/api_atcab/atca_tests_aes_cbc.c b/test/api_atcab/atca_tests_aes_cbc.c index 5a25ec1c0..d6d295916 100644 --- a/test/api_atcab/atca_tests_aes_cbc.c +++ b/test/api_atcab/atca_tests_aes_cbc.c @@ -270,7 +270,8 @@ TEST(atca_cmd_basic_test, aes_cbc_encrypt_update_chunks) TEST(atca_cmd_basic_test, aes_cbc_decrypt_update_simple) { uint8_t plaintext[sizeof(g_plaintext)]; - size_t length = sizeof(plaintext); + size_t length; + uint8_t * pPtr; atca_aes_cbc_ctx_t ctx; ATCA_STATUS status; uint16_t key_slot; @@ -293,11 +294,16 @@ TEST(atca_cmd_basic_test, aes_cbc_decrypt_update_simple) TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); // Encrypt the entire plaintext - status = atcab_aes_cbc_decrypt_update(&ctx, (uint8_t*)&g_ciphertext_cbc[0][0], sizeof(g_plaintext), plaintext, &length); + pPtr = plaintext; + length = sizeof(plaintext); + status = atcab_aes_cbc_decrypt_update(&ctx, (uint8_t*)&g_ciphertext_cbc[0][0], sizeof(g_plaintext), pPtr, &length); TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); + pPtr += length; + length = sizeof(plaintext) - length; + // Finalize without padding - status = atcab_aes_cbc_decrypt_finish(&ctx, plaintext, &length, 0); + status = atcab_aes_cbc_decrypt_finish(&ctx, pPtr, &length, 0); TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); TEST_ASSERT_EQUAL_MEMORY(&g_plaintext, plaintext, sizeof(plaintext)); } @@ -347,7 +353,7 @@ TEST(atca_cmd_basic_test, aes_cbc_decrypt_update_chunks) // Finalize without padding length = sizeof(plaintext) - (pPtr - plaintext); - status = atcab_aes_cbc_decrypt_finish(&ctx, plaintext, &length, 0); + status = atcab_aes_cbc_decrypt_finish(&ctx, pPtr, &length, 0); TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); TEST_ASSERT_EQUAL_MEMORY(g_plaintext, plaintext, sizeof(plaintext)); } @@ -361,20 +367,20 @@ t_test_case_info aes_cbc_basic_test_info[] = { #if TEST_ATCAB_AES_CBC_EN #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_encrypt_block), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_decrypt_block), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_encrypt_block), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_decrypt_block), atca_test_cond_ecc608 }, #endif - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_encrypt_block_simple), DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_decrypt_block_simple), DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_encrypt_block_simple), atca_test_cond_ta100 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_decrypt_block_simple), atca_test_cond_ta100 }, #ifdef TEST_ATCAB_AES_CBC_UPDATE_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_encrypt_update_simple), DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_encrypt_update_chunks), DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_decrypt_update_simple), DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_decrypt_update_chunks), DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_encrypt_update_simple), atca_test_cond_ta100 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_encrypt_update_chunks), atca_test_cond_ta100 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_decrypt_update_simple), atca_test_cond_ta100 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_decrypt_update_chunks), atca_test_cond_ta100 }, #endif /* TEST_ATCAB_AES_CBC_UPDATE_EN */ #endif /* TEST_ATCAB_AES_CBC_EN */ - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* diff --git a/test/api_atcab/atca_tests_aes_cbcmac.c b/test/api_atcab/atca_tests_aes_cbcmac.c index 8b7971e94..7f52f47e5 100644 --- a/test/api_atcab/atca_tests_aes_cbcmac.c +++ b/test/api_atcab/atca_tests_aes_cbcmac.c @@ -89,7 +89,7 @@ TEST(atca_cmd_basic_test, aes_cbc_mac) t_test_case_info aes_cbcmac_basic_test_info[] = { #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_mac), DEVICE_MASK(ATECC608A) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cbc_mac), atca_test_cond_ecc608 }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; diff --git a/test/api_atcab/atca_tests_aes_ccm.c b/test/api_atcab/atca_tests_aes_ccm.c index fa163a1ca..4009c4b63 100644 --- a/test/api_atcab/atca_tests_aes_ccm.c +++ b/test/api_atcab/atca_tests_aes_ccm.c @@ -341,10 +341,10 @@ TEST(atca_cmd_basic_test, aes_ccm_auth_decrypt_partial) t_test_case_info aes_ccm_basic_test_info[] = { #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ccm_auth_encrypt), DEVICE_MASK(ATECC608A) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ccm_auth_encrypt_partial), DEVICE_MASK(ATECC608A) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ccm_auth_decrypt), DEVICE_MASK(ATECC608A) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ccm_auth_decrypt_partial), DEVICE_MASK(ATECC608A) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ccm_auth_encrypt), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ccm_auth_encrypt_partial), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ccm_auth_decrypt), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ccm_auth_decrypt_partial), atca_test_cond_ecc608 }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; diff --git a/test/api_atcab/atca_tests_aes_cmac.c b/test/api_atcab/atca_tests_aes_cmac.c index 2242816d5..bb468e509 100644 --- a/test/api_atcab/atca_tests_aes_cmac.c +++ b/test/api_atcab/atca_tests_aes_cmac.c @@ -117,10 +117,10 @@ t_test_case_info aes_cmac_basic_test_info[] = { #if TEST_ATCAB_AES_CMAC_EN #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cmac), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cmac), atca_test_cond_ecc608 }, #endif - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cmac_simple), DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_cmac_simple), atca_test_cond_ta100 }, #endif /* TEST_ATCAB_AES_CMAC_EN */ - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* diff --git a/test/api_atcab/atca_tests_aes_ctr.c b/test/api_atcab/atca_tests_aes_ctr.c index f6cae566f..e3c48ec8f 100644 --- a/test/api_atcab/atca_tests_aes_ctr.c +++ b/test/api_atcab/atca_tests_aes_ctr.c @@ -315,15 +315,15 @@ t_test_case_info aes_ctr_basic_test_info[] = { #if TEST_ATCAB_AES_CTR_EN #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_encrypt_block), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_decrypt_block), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_increment), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_encrypt_block), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_decrypt_block), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_increment), atca_test_cond_ecc608 }, #endif - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_encrypt_block_simple), DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_decrypt_block_simple), DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_increment_simple), DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_encrypt_block_simple), atca_test_cond_ta100 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_decrypt_block_simple), atca_test_cond_ta100 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_ctr_increment_simple), atca_test_cond_ta100 }, #endif /* TEST_ATCAB_AES_CTR_EN */ - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* diff --git a/test/api_atcab/atca_tests_aes_gcm.c b/test/api_atcab/atca_tests_aes_gcm.c index 2f99d18c8..fee0ba692 100644 --- a/test/api_atcab/atca_tests_aes_gcm.c +++ b/test/api_atcab/atca_tests_aes_gcm.c @@ -658,12 +658,12 @@ TEST(atca_cmd_basic_test, aes_gcm_decrypt_cavp_vectors) // *INDENT-OFF* - Preserve formatting t_test_case_info aes_gcm_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_nist_vectors), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_encrypt_partial_blocks), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_decrypt_partial_blocks), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_encrypt_cavp_vectors), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_decrypt_cavp_vectors), DEVICE_MASK(ATECC608) }, - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_nist_vectors), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_encrypt_partial_blocks), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_decrypt_partial_blocks), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_encrypt_cavp_vectors), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, aes_gcm_decrypt_cavp_vectors), atca_test_cond_ecc608 }, + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* diff --git a/test/api_atcab/atca_tests_counter.c b/test/api_atcab/atca_tests_counter.c index bf0cc2197..54cbbfe89 100644 --- a/test/api_atcab/atca_tests_counter.c +++ b/test/api_atcab/atca_tests_counter.c @@ -27,8 +27,21 @@ #include #include "test_atcab.h" +#ifndef TEST_ATCAB_COUNTER_EN +#define TEST_ATCAB_COUNTER_EN (CALIB_COUNTER_EN || TALIB_COUNTER_EN) +#endif + +#if TEST_ATCAB_COUNTER_EN + #ifdef ATCA_ECC_SUPPORT +TEST_CONDITION(atca_cmd_basic_test, counter_test) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC508A == dev_type) || (ATECC608 == dev_type)); +} + TEST(atca_cmd_basic_test, counter_test) { ATCA_STATUS status = ATCA_SUCCESS; @@ -154,6 +167,18 @@ TEST(atca_cmd_basic_test, counter_match) status = atcab_write_bytes_zone(ATCA_ZONE_DATA, 10, 0, counter_match_slot_data, sizeof(counter_match_slot_data)); //Writing the maximum value to the slot for the remaning test cases to execute TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); } +#endif + +#if ATCA_CA_SUPPORT || ATCA_CA2_SUPPORT +TEST_CONDITION(atca_cmd_basic_test, counter_write_test) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC508A == dev_type) + || (ATECC608 == dev_type) + || (ECC204 == dev_type) + || (TA010 == dev_type)); +} /* Test the counter 1 for the different value range. @@ -170,13 +195,15 @@ TEST(atca_cmd_basic_test, counter_write_test) test_assert_config_is_unlocked(); - if (ECC204 == gCfg->devtype) +#if ATCA_CA2_SUPPORT + if (atcab_is_ca2_device(gCfg->devtype)) { counter_id = 0; - counter_value_mid = ECC204_COUNTER_MAX_VALUE / 2; - counter_value_max = ECC204_COUNTER_MAX_VALUE; + counter_value_mid = COUNTER_MAX_VALUE_CA2 / 2; + counter_value_max = COUNTER_MAX_VALUE_CA2; } else +#endif { counter_id = 1; counter_value_mid = COUNTER_MAX_VALUE / 2; @@ -208,19 +235,21 @@ TEST(atca_cmd_basic_test, counter_write_test) TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); } +#endif +#endif // *INDENT-OFF* - Preserve formatting t_test_case_info counter_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, counter_write_test), DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608) | DEVICE_MASK(ECC204) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, counter_test), DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, counter_match), DEVICE_MASK(ATECC608) }, +#if TEST_ATCAB_COUNTER_EN +#if ATCA_CA_SUPPORT || ATCA_CA2_SUPPORT + { REGISTER_TEST_CASE(atca_cmd_basic_test, counter_write_test), REGISTER_TEST_CONDITION(atca_cmd_basic_test, counter_write_test) }, +#endif +#ifdef ATCA_ECC_SUPPORT + { REGISTER_TEST_CASE(atca_cmd_basic_test, counter_test), REGISTER_TEST_CONDITION(atca_cmd_basic_test, counter_test) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, counter_match), atca_test_cond_ecc608 }, +#endif +#endif { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* -#else -t_test_case_info counter_basic_test_info[] = -{ - { (fp_test_case)NULL, (uint8_t)0 }, -}; -#endif diff --git a/test/api_atcab/atca_tests_derivekey.c b/test/api_atcab/atca_tests_derivekey.c index e20fc388f..965252b9a 100644 --- a/test/api_atcab/atca_tests_derivekey.c +++ b/test/api_atcab/atca_tests_derivekey.c @@ -32,6 +32,14 @@ #endif #if TEST_ATCAB_DERIVEKEY_EN + +TEST_CONDITION(atca_cmd_basic_test, derivekey) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return (atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)); +} + TEST(atca_cmd_basic_test, derivekey) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -233,8 +241,8 @@ TEST(atca_cmd_basic_test, derivekey_mac) t_test_case_info derivekey_basic_test_info[] = { #if TEST_ATCAB_DERIVEKEY_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, derivekey), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, derivekey_mac), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, derivekey), REGISTER_TEST_CONDITION(atca_cmd_basic_test, derivekey) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, derivekey_mac), REGISTER_TEST_CONDITION(atca_cmd_basic_test, derivekey) }, #endif { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; diff --git a/test/api_atcab/atca_tests_ecdh.c b/test/api_atcab/atca_tests_ecdh.c index 5be59a6bb..69d4ba102 100644 --- a/test/api_atcab/atca_tests_ecdh.c +++ b/test/api_atcab/atca_tests_ecdh.c @@ -32,6 +32,14 @@ #endif #if TEST_ATCAB_ECDH_EN && CALIB_ECDH_EN + +TEST_CONDITION(atca_cmd_basic_test, ecdh) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC508A == dev_type) || (ATECC608 == dev_type)); +} + TEST(atca_cmd_basic_test, ecdh) { ATCA_STATUS status; @@ -274,11 +282,11 @@ t_test_case_info ecdh_basic_test_info[] = { #if TEST_ATCAB_ECDH_EN #if CALIB_ECDH_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, ecdh), DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, ecdh), REGISTER_TEST_CONDITION(atca_cmd_basic_test, ecdh) }, #endif - { REGISTER_TEST_CASE(atca_cmd_basic_test, ecdh_simple), DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, ecdh_simple), atca_test_cond_ta100 }, #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, ecdh_protection_key), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, ecdh_protection_key), atca_test_cond_ecc608 }, #endif #endif { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ diff --git a/test/api_atcab/atca_tests_gendig.c b/test/api_atcab/atca_tests_gendig.c index 7cbf5df5c..bd8910ecb 100644 --- a/test/api_atcab/atca_tests_gendig.c +++ b/test/api_atcab/atca_tests_gendig.c @@ -29,6 +29,13 @@ #ifdef ATCA_ECC_SUPPORT +TEST_CONDITION(atca_cmd_basic_test, gendig_shared_nonce) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC508A == dev_type) || (ATECC608 == dev_type)); +} + TEST(atca_cmd_basic_test, gendig_shared_nonce) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -266,6 +273,13 @@ TEST(atca_cmd_basic_test, gendig_counter) TEST_ASSERT_EQUAL_MEMORY(host_response, client_response, sizeof(host_response)); } +TEST_CONDITION(atca_cmd_basic_test, gendig_config_otp_data) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return (atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)); +} + TEST(atca_cmd_basic_test, gendig_config_otp_data) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -359,11 +373,12 @@ TEST(atca_cmd_basic_test, gendig_config_otp_data) // *INDENT-OFF* - Preserve formatting t_test_case_info gendig_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, gendig_config_otp_data), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, gendig_counter), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, gendig_keyconfig), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, gendig_shared_nonce), DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608) }, - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { REGISTER_TEST_CASE(atca_cmd_basic_test, gendig_config_otp_data), REGISTER_TEST_CONDITION(atca_cmd_basic_test, gendig_config_otp_data) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, gendig_counter), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, gendig_keyconfig), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, gendig_shared_nonce), REGISTER_TEST_CONDITION(atca_cmd_basic_test, gendig_shared_nonce) }, + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* #else diff --git a/test/api_atcab/atca_tests_genkey.c b/test/api_atcab/atca_tests_genkey.c index 2520866d5..91b1e48b3 100644 --- a/test/api_atcab/atca_tests_genkey.c +++ b/test/api_atcab/atca_tests_genkey.c @@ -43,7 +43,7 @@ TEST(atca_cmd_basic_test, genkey) test_assert_config_is_locked(); - if (ECC204 == gCfg->devtype) + if (atcab_is_ca2_device(gCfg->devtype)) { test_assert_data_is_unlocked(); } @@ -83,9 +83,8 @@ TEST(atca_cmd_basic_test, get_pubkey) // *INDENT-OFF* - Preserve formatting t_test_case_info genkey_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, genkey), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, get_pubkey), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, genkey), atca_test_cond_p256_sign }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, get_pubkey), atca_test_cond_p256_sign }, { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_helper.c b/test/api_atcab/atca_tests_helper.c index 89f0993c3..958fa7e15 100644 --- a/test/api_atcab/atca_tests_helper.c +++ b/test/api_atcab/atca_tests_helper.c @@ -27,8 +27,6 @@ #include #include "test_atcab.h" -#define ATCA_TESTS_HELPER_DEVICES ( DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) ) - static const uint8_t atca_tests_helper_base64_vector_in0[] = "We were henceforth to be hurled along, the playthings of the fierce elements of the deep. \n"; static const char atca_tests_helper_base64_vector_out0[] = "V2Ugd2VyZSBoZW5jZWZvcnRoIHRvIGJlIGh1cmxlZCBhbG9uZywgdGhlIHBsYXl0\r\n" "aGluZ3Mgb2YgdGhlIGZpZXJjZSBlbGVtZW50cyBvZiB0aGUgZGVlcC4gICAgICAg\r\n" @@ -621,43 +619,44 @@ TEST(atca_helper, hex2bin_small_buf) // *INDENT-OFF* - Preserve formatting t_test_case_info helper_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_helper, base64_encode), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_encode_to_dirty_buffer), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_decode), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_decode_to_dirty_buffer), ATCA_TESTS_HELPER_DEVICES}, - - { REGISTER_TEST_CASE(atca_helper, base64_encode_decode), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_encode_decode_mod_3), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_encode_decode_mod_3_minus_1), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_encode_decode_mod_3_minus_2), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_encode_decode_mod_3_minus_3), ATCA_TESTS_HELPER_DEVICES}, - - { REGISTER_TEST_CASE(atca_helper, base64_encode_check_newline_32), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_encode_check_newline_64), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_encode_check_newline_96), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_encode_check_newline_128), ATCA_TESTS_HELPER_DEVICES}, - - { REGISTER_TEST_CASE(atca_helper, base64_url_encode), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, base64_url_decode), ATCA_TESTS_HELPER_DEVICES}, - - { REGISTER_TEST_CASE(atca_helper, bin2hex_simple), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, bin2hex_simple_no_null), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, bin2hex_one), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, bin2hex_all), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, bin2hex_in_place), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, bin2hex_no_pretty), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, bin2hex_small_buf), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, hex2bin), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, hex2bin_in_place), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, hex2bin_incomplete), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, hex2bin_small_buf), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, transform_bin2hex_uppercase), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, transform_bin2hex_lowercase), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, transform_bin2hex_uppercase_space), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, transform_bin2hex_lowercase_space), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, transform_hex2bin), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, transform_hex2bin_space), ATCA_TESTS_HELPER_DEVICES}, - { REGISTER_TEST_CASE(atca_helper, transform_reversal), ATCA_TESTS_HELPER_DEVICES}, - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { REGISTER_TEST_CASE(atca_helper, base64_encode), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_encode_to_dirty_buffer), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_decode), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_decode_to_dirty_buffer), NULL }, + + { REGISTER_TEST_CASE(atca_helper, base64_encode_decode), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_encode_decode_mod_3), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_encode_decode_mod_3_minus_1), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_encode_decode_mod_3_minus_2), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_encode_decode_mod_3_minus_3), NULL }, + + { REGISTER_TEST_CASE(atca_helper, base64_encode_check_newline_32), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_encode_check_newline_64), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_encode_check_newline_96), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_encode_check_newline_128), NULL }, + + { REGISTER_TEST_CASE(atca_helper, base64_url_encode), NULL }, + { REGISTER_TEST_CASE(atca_helper, base64_url_decode), NULL }, + + { REGISTER_TEST_CASE(atca_helper, bin2hex_simple), NULL }, + { REGISTER_TEST_CASE(atca_helper, bin2hex_simple_no_null), NULL }, + { REGISTER_TEST_CASE(atca_helper, bin2hex_one), NULL }, + { REGISTER_TEST_CASE(atca_helper, bin2hex_all), NULL }, + { REGISTER_TEST_CASE(atca_helper, bin2hex_in_place), NULL }, + { REGISTER_TEST_CASE(atca_helper, bin2hex_no_pretty), NULL }, + { REGISTER_TEST_CASE(atca_helper, bin2hex_small_buf), NULL }, + { REGISTER_TEST_CASE(atca_helper, hex2bin), NULL }, + { REGISTER_TEST_CASE(atca_helper, hex2bin_in_place), NULL }, + { REGISTER_TEST_CASE(atca_helper, hex2bin_incomplete), NULL }, + { REGISTER_TEST_CASE(atca_helper, hex2bin_small_buf), NULL }, + { REGISTER_TEST_CASE(atca_helper, transform_bin2hex_uppercase), NULL }, + { REGISTER_TEST_CASE(atca_helper, transform_bin2hex_lowercase), NULL }, + { REGISTER_TEST_CASE(atca_helper, transform_bin2hex_uppercase_space), NULL }, + { REGISTER_TEST_CASE(atca_helper, transform_bin2hex_lowercase_space), NULL }, + { REGISTER_TEST_CASE(atca_helper, transform_hex2bin), NULL }, + { REGISTER_TEST_CASE(atca_helper, transform_hex2bin_space), NULL }, + { REGISTER_TEST_CASE(atca_helper, transform_reversal), NULL }, + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* diff --git a/test/api_atcab/atca_tests_hmac.c b/test/api_atcab/atca_tests_hmac.c index c898bcae0..0158450ab 100644 --- a/test/api_atcab/atca_tests_hmac.c +++ b/test/api_atcab/atca_tests_hmac.c @@ -33,6 +33,15 @@ #if TEST_ATCAB_HMAC_EN +TEST_CONDITION(atca_cmd_basic_test, hmac) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATSHA204A == dev_type) + || (ATECC108A == dev_type) + || (ATECC508A == dev_type)); +} + TEST(atca_cmd_basic_test, hmac) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -116,7 +125,7 @@ TEST(atca_cmd_basic_test, hmac) t_test_case_info hmac_basic_test_info[] = { #if TEST_ATCAB_HMAC_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, hmac), DEVICE_MASK(ATSHA204A) | DEVICE_MASK(ATECC108A) | DEVICE_MASK(ATECC508A) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, hmac), REGISTER_TEST_CONDITION(atca_cmd_basic_test, hmac) }, #endif { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ }; diff --git a/test/api_atcab/atca_tests_info.c b/test/api_atcab/atca_tests_info.c index 85b5432ad..0f29a8aec 100644 --- a/test/api_atcab/atca_tests_info.c +++ b/test/api_atcab/atca_tests_info.c @@ -47,11 +47,50 @@ TEST(atca_cmd_basic_test, info) } } +#if ATCA_CA2_SUPPORT +TEST(atca_cmd_basic_test, info_lock_status) +{ + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t is_locked, slot = 1; + uint16_t param2; + + // lockstatus of Config subzone + param2 = ATCA_ZONE_CA2_CONFIG | (slot << 1); + + // is_locked = 0x00 means unlocked + // is_locked = 0x01 means locked + status = atcab_info_lock_status(param2, &is_locked); + TEST_ASSERT_SUCCESS(status); + + // lockstatus of Data zone + param2 = ATCA_ZONE_CA2_DATA | (slot << 1); + + // is_locked = 0x00 means unlocked + // is_locked = 0x01 means locked + status = atcab_info_lock_status(param2, &is_locked); + TEST_ASSERT_SUCCESS(status); +} + +TEST(atca_cmd_basic_test, info_chip_status) +{ + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t chip_status[4]; + + // chip_status[0] = 0x00 means No Deletion + // chip_status[0] = 0xFF means Deletion has completed + status = atcab_info_chip_status(chip_status); + TEST_ASSERT_SUCCESS(status); +} +#endif + // *INDENT-OFF* - Preserve formatting t_test_case_info info_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, info), DEVICE_MASK_SHA | DEVICE_MASK_ECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, info), NULL }, +#if ATCA_CA2_SUPPORT + { REGISTER_TEST_CASE(atca_cmd_basic_test, info_lock_status), atca_test_cond_ca2 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, info_chip_status), atca_test_cond_ca2 }, +#endif { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_kdf.c b/test/api_atcab/atca_tests_kdf.c index 53b582f95..85a1c2924 100644 --- a/test/api_atcab/atca_tests_kdf.c +++ b/test/api_atcab/atca_tests_kdf.c @@ -416,13 +416,14 @@ TEST(atca_cmd_basic_test, kdf_hkdf_output_encrypted) // *INDENT-OFF* - Preserve formatting t_test_case_info kdf_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_prf_output), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_prf_output_encrypted), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_aes_output), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_aes_output_encrypted), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_hkdf_output), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_hkdf_output_encrypted), DEVICE_MASK(ATECC608) }, - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_prf_output), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_prf_output_encrypted), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_aes_output), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_aes_output_encrypted), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_hkdf_output), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, kdf_hkdf_output_encrypted), atca_test_cond_ecc608 }, + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* #else diff --git a/test/api_atcab/atca_tests_lock.c b/test/api_atcab/atca_tests_lock.c index eb36ae33d..2391b477d 100644 --- a/test/api_atcab/atca_tests_lock.c +++ b/test/api_atcab/atca_tests_lock.c @@ -28,7 +28,7 @@ #include "test_atcab.h" #ifndef TEST_ATCAB_LOCK_EN -#define TEST_ATCAB_LOCK_EN CALIB_LOCK_EN || TALIB_LOCK_EN +#define TEST_ATCAB_LOCK_EN CALIB_LOCK_EN || CALIB_LOCK_CA2_EN || TALIB_LOCK_EN #endif #if TEST_ATCAB_LOCK_EN @@ -64,6 +64,7 @@ TEST(atca_cmd_basic_test, lock_data_zone) TEST_ASSERT_EQUAL(true, is_locked); } +#if CALIB_LOCK_EN TEST(atca_cmd_basic_test, lock_data_slot) { ATCA_STATUS status = ATCA_SUCCESS; @@ -91,15 +92,18 @@ TEST(atca_cmd_basic_test, lock_data_slot) } #endif +#endif + // *INDENT-OFF* - Preserve formatting t_test_case_info lock_basic_test_info[] = { #if TEST_ATCAB_LOCK_EN //{ REGISTER_TEST_CASE(atca_cmd_basic_test, lock_config_zone), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC }, //{ REGISTER_TEST_CASE(atca_cmd_basic_test, lock_data_zone), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, lock_data_slot), DEVICE_MASK_ECC }, +#if CALIB_LOCK_EN + //{ REGISTER_TEST_CASE(atca_cmd_basic_test, lock_data_slot), DEVICE_MASK(ATECC108A) | DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608) }, +#endif #endif { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_mac.c b/test/api_atcab/atca_tests_mac.c index 0c7ba2325..3a1245b7f 100644 --- a/test/api_atcab/atca_tests_mac.c +++ b/test/api_atcab/atca_tests_mac.c @@ -33,6 +33,13 @@ #if TEST_ATCAB_MAC_EN +TEST_CONDITION(atca_cmd_basic_test, mac) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return (atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)); +} + TEST(atca_cmd_basic_test, mac_key_challenge) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -336,12 +343,13 @@ TEST(atca_cmd_basic_test, checkmac) t_test_case_info mac_basic_test_info[] = { #if TEST_ATCAB_MAC_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, mac_key_challenge), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, mac_key_tempkey), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, mac_tempkey_challenge), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, mac_tempkey_tempkey), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, checkmac), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, mac_key_challenge), REGISTER_TEST_CONDITION(atca_cmd_basic_test, mac) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, mac_key_tempkey), REGISTER_TEST_CONDITION(atca_cmd_basic_test, mac) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, mac_tempkey_challenge), REGISTER_TEST_CONDITION(atca_cmd_basic_test, mac) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, mac_tempkey_tempkey), REGISTER_TEST_CONDITION(atca_cmd_basic_test, mac) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, checkmac), REGISTER_TEST_CONDITION(atca_cmd_basic_test, mac) }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* diff --git a/test/api_atcab/atca_tests_nonce.c b/test/api_atcab/atca_tests_nonce.c index 1ea0ef1a7..40decc93c 100644 --- a/test/api_atcab/atca_tests_nonce.c +++ b/test/api_atcab/atca_tests_nonce.c @@ -33,6 +33,13 @@ #if TEST_ATCAB_NONCE_EN +TEST_CONDITION(atca_cmd_basic_test, challenge) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return (atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)); +} + TEST(atca_cmd_basic_test, challenge) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -52,10 +59,9 @@ TEST(atca_cmd_basic_test, challenge) t_test_case_info nonce_basic_test_info[] = { #if TEST_ATCAB_NONCE_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, challenge), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, challenge), REGISTER_TEST_CONDITION(atca_cmd_basic_test, challenge) }, #endif { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_otpzero.c b/test/api_atcab/atca_tests_otpzero.c index 428b0a288..6e40099ba 100644 --- a/test/api_atcab/atca_tests_otpzero.c +++ b/test/api_atcab/atca_tests_otpzero.c @@ -33,6 +33,15 @@ #if TEST_ATCAB_OTP_EN +TEST_CONDITION(atca_cmd_basic_test, otp_zero) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATSHA204A == dev_type) + || (ATECC108A == dev_type) + || (ATECC508A == dev_type)); +} + TEST(atca_cmd_basic_test, otp_zero) { ATCA_STATUS status = ATCA_SUCCESS; @@ -85,9 +94,9 @@ TEST(atca_cmd_basic_test, otp_zero) t_test_case_info otpzero_basic_test_info[] = { #if TEST_ATCAB_OTP_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, otp_zero), DEVICE_MASK(ATSHA204A) | DEVICE_MASK(ATECC108A) | DEVICE_MASK(ATECC508A) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, otp_zero), REGISTER_TEST_CONDITION(atca_cmd_basic_test, otp_zero) }, #endif - { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_privwrite.c b/test/api_atcab/atca_tests_privwrite.c index afe41ead2..68ff22040 100644 --- a/test/api_atcab/atca_tests_privwrite.c +++ b/test/api_atcab/atca_tests_privwrite.c @@ -29,6 +29,15 @@ #ifdef ATCA_ECC_SUPPORT +TEST_CONDITION(atca_cmd_basic_test, priv_write) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608 == dev_type)); +} + TEST(atca_cmd_basic_test, priv_write_unencrypted) { ATCA_STATUS status = ATCA_SUCCESS; @@ -101,10 +110,10 @@ TEST(atca_cmd_basic_test, priv_write_encrypted) t_test_case_info privwrite_basic_test_info[] = { #ifdef ATCA_ECC_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, priv_write_unencrypted), DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, priv_write_encrypted), DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, priv_write_unencrypted), REGISTER_TEST_CONDITION(atca_cmd_basic_test, priv_write) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, priv_write_encrypted), REGISTER_TEST_CONDITION(atca_cmd_basic_test, priv_write) }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + /* Array Termination element*/ + { (fp_test_case)NULL, NULL}, }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_random.c b/test/api_atcab/atca_tests_random.c index d0bfa6d2d..9db56dfa0 100644 --- a/test/api_atcab/atca_tests_random.c +++ b/test/api_atcab/atca_tests_random.c @@ -32,6 +32,15 @@ #endif #if TEST_ATCAB_RANDOM_EN +TEST_CONDITION(atca_cmd_basic_test, random) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)) + || (TA100 == dev_type) + ); +} + TEST(atca_cmd_basic_test, random) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -46,9 +55,8 @@ TEST(atca_cmd_basic_test, random) t_test_case_info random_basic_test_info[] = { #if TEST_ATCAB_RANDOM_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, random), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, random), REGISTER_TEST_CONDITION(atca_cmd_basic_test, random) }, #endif { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_read.c b/test/api_atcab/atca_tests_read.c index 7ba6404b3..898a85ef8 100644 --- a/test/api_atcab/atca_tests_read.c +++ b/test/api_atcab/atca_tests_read.c @@ -28,11 +28,12 @@ #include "test_atcab.h" #ifndef TEST_ATCAB_READ_EN -#define TEST_ATCAB_READ_EN (CALIB_READ_EN || CALIB_READ_ECC204_EN || TALIB_READ_EN) +#define TEST_ATCAB_READ_EN (CALIB_READ_EN || CALIB_READ_CA2_EN || TALIB_READ_EN) #endif #if TEST_ATCAB_READ_EN + #if CALIB_READ_EN TEST(atca_cmd_basic_test, read_zone) { @@ -129,6 +130,13 @@ TEST(atca_cmd_basic_test, read_config_zone) } #if CALIB_READ_EN +TEST_CONDITION(atca_cmd_basic_test, read_otp_zone) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return (atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)); +} + TEST(atca_cmd_basic_test, read_otp_zone) { ATCA_STATUS status = ATCA_SUCCESS; @@ -159,20 +167,41 @@ TEST(atca_cmd_basic_test, read_data_zone) status = atcab_read_bytes_zone(ATCA_ZONE_DATA, slot, 0, read_data, sizeof(read_data)); TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); } + +#if CALIB_READ_CA2_EN +TEST_CONDITION(atca_cmd_basic_test, read_full_length) +{ + return atcab_is_ca2_device(atca_test_get_device_type()); +} + +TEST(atca_cmd_basic_test, read_full_length) +{ + ATCA_STATUS status = ATCA_SUCCESS; + uint8_t read_data[320]; + + test_assert_data_is_locked(); + + status = atcab_read_bytes_zone(ATCA_ZONE_DATA, 1, 0, read_data, sizeof(read_data)); + TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); +} +#endif + #endif // *INDENT-OFF* - Preserve formatting t_test_case_info read_basic_test_info[] = { #if TEST_ATCAB_READ_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, read_config_zone), DEVICE_MASK_SHA | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, read_data_zone), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, read_config_zone), NULL }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, read_data_zone), NULL }, #if CALIB_READ_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, read_zone), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, read_otp_zone), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, read_zone), REGISTER_TEST_CONDITION(atca_cmd_basic_test, read_otp_zone) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, read_otp_zone), REGISTER_TEST_CONDITION(atca_cmd_basic_test, read_otp_zone) }, +#endif +#if CALIB_READ_CA2_EN + { REGISTER_TEST_CASE(atca_cmd_basic_test, read_full_length), REGISTER_TEST_CONDITION(atca_cmd_basic_test, read_full_length) }, #endif #endif /* TEST_ATCAB_READ_EN */ { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_secureboot.c b/test/api_atcab/atca_tests_secureboot.c index 0f26b4bc4..680233eb4 100644 --- a/test/api_atcab/atca_tests_secureboot.c +++ b/test/api_atcab/atca_tests_secureboot.c @@ -178,11 +178,10 @@ TEST(atca_cmd_basic_test, sboot_digest_fullstore_encrypted) t_test_case_info sboot_basic_test_info[] = { #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, sboot_digest), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, sboot_digest_full_encrypted), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, sboot_digest_fullstore_encrypted), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sboot_digest), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sboot_digest_full_encrypted), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sboot_digest_fullstore_encrypted), atca_test_cond_ecc608 }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_selftest.c b/test/api_atcab/atca_tests_selftest.c index b942c19de..c5d42a36b 100644 --- a/test/api_atcab/atca_tests_selftest.c +++ b/test/api_atcab/atca_tests_selftest.c @@ -68,17 +68,42 @@ TEST(atca_cmd_basic_test, selftest_all) TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); TEST_ASSERT_EQUAL(0, result); } + +TEST_CONDITION(atca_cmd_basic_test, selftest_ecc204_ta010) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ECC204 == dev_type) + || (TA010 == dev_type)); +} + +TEST(atca_cmd_basic_test, selftest_ecc204_ta010) +{ + ATCA_STATUS status; + uint8_t result = 0; + + status = atcab_selftest(SELFTEST_MODE_RNG, 0, &result); + TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); + TEST_ASSERT_EQUAL(0x00, (result & 0x01)); + + status = atcab_selftest(SELFTEST_MODE_ECDSA_SIGN_VERIFY, 0, &result); + TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); + TEST_ASSERT_EQUAL(0x00, (result & 0x02)); + + status = atcab_selftest(SELFTEST_MODE_SHA, 0, &result); + TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); + TEST_ASSERT_EQUAL(0x00, (result & 0x20)); +} #endif // *INDENT-OFF* - Preserve formatting t_test_case_info selftest_basic_test_info[] = { #if TEST_ATCAB_SELFTEST_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, selftest_individual), DEVICE_MASK(ATECC608) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, selftest_all), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, selftest_individual), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, selftest_all), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, selftest_ecc204_ta010), REGISTER_TEST_CONDITION(atca_cmd_basic_test, selftest_ecc204_ta010) }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* - - diff --git a/test/api_atcab/atca_tests_sha.c b/test/api_atcab/atca_tests_sha.c index 2d0c44f56..8d77b69fd 100644 --- a/test/api_atcab/atca_tests_sha.c +++ b/test/api_atcab/atca_tests_sha.c @@ -40,6 +40,16 @@ static const uint8_t nist_hash_msg1[] = "abc"; static const uint8_t nist_hash_msg2[] = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; +TEST_CONDITION(atca_cmd_basic_test, sha) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)) + || atcab_is_ca2_device(dev_type) + || (TA100 == dev_type) + ); +} + TEST(atca_cmd_basic_test, sha) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -539,6 +549,18 @@ TEST(atca_cmd_basic_test, sha_context_simple) #endif /* TEST_ATCAB_SHA_EN */ #if TEST_ATCAB_SHA_HMAC_EN +TEST_CONDITION(atca_cmd_basic_test, sha_hmac) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608 == dev_type) + || (ECC204 == dev_type) + || (TA010 == dev_type) + || (TA100 == dev_type)); +} + TEST(atca_cmd_basic_test, sha_hmac) { ATCA_STATUS status = ATCA_GEN_FAIL; @@ -619,29 +641,30 @@ TEST(atca_cmd_basic_test, sha_hmac_tempkey) t_test_case_info sha_basic_test_info[] = { #if TEST_ATCAB_SHA_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_long), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_short), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha2_256_nist1), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha2_256_nist2), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha2_256_nist_short), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha), REGISTER_TEST_CONDITION(atca_cmd_basic_test, sha) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_long), REGISTER_TEST_CONDITION(atca_cmd_basic_test, sha) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_short), REGISTER_TEST_CONDITION(atca_cmd_basic_test, sha) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha2_256_nist1), REGISTER_TEST_CONDITION(atca_cmd_basic_test, sha) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha2_256_nist2), REGISTER_TEST_CONDITION(atca_cmd_basic_test, sha) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha2_256_nist_short), REGISTER_TEST_CONDITION(atca_cmd_basic_test, sha) }, //{ REGISTER_TEST_CASE(atca_cmd_basic_test, sha2_256_nist_long), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC }, //{ REGISTER_TEST_CASE(atca_cmd_basic_test, sha2_256_nist_monte), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC }, #if CALIB_SHA_CONTEXT_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_context), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_context), atca_test_cond_ecc608 }, #endif #if TALIB_SHA_CONTEXT_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_context_simple), DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_context_simple), atca_test_cond_ta100 }, #endif #endif /* TEST_ATCAB_SHA_EN */ #if TEST_ATCAB_SHA_HMAC_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_hmac), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_hmac), REGISTER_TEST_CONDITION(atca_cmd_basic_test, sha_hmac) }, #ifdef ATCA_ATECC608_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_hmac_tempkey), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sha_hmac_tempkey), atca_test_cond_ecc608 }, #endif #endif /* TEST_ATCAB_SHA_HMAC_EN */ - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_sign.c b/test/api_atcab/atca_tests_sign.c index 1a2578a7f..18c5cdef4 100644 --- a/test/api_atcab/atca_tests_sign.c +++ b/test/api_atcab/atca_tests_sign.c @@ -121,7 +121,16 @@ TEST(atca_cmd_basic_test, sign_hw_verify) #endif #ifdef ATCA_ECC_SUPPORT -TEST(atca_cmd_basic_test, sign_internal) +TEST_CONDITION(atca_cmd_basic_test, sign_internal_ecc) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608 == dev_type)); +} + +TEST(atca_cmd_basic_test, sign_internal_ecc) { uint8_t internal_key_id = 4; // Which slot to sign digest of (via GenDig) uint16_t private_key_id = 0; // Slot with private key to do the signing @@ -214,19 +223,21 @@ TEST(atca_cmd_basic_test, read_sig) // *INDENT-OFF* - Preserve formatting t_test_case_info sign_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, sign), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sign), atca_test_cond_p256_sign }, #if ATCA_HOSTLIB_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, sign_sw_verify), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sign_sw_verify), atca_test_cond_p256_sign }, #endif #if !ATCA_HOSTLIB_EN && (defined(ATCA_ECC_SUPPORT) || defined(ATCA_TA100_SUPPORT)) - { REGISTER_TEST_CASE(atca_cmd_basic_test, sign_hw_verify), DEVICE_MASK_ATECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sign_hw_verify), atca_test_cond_p256_sign_verify }, #endif #ifdef ATCA_ECC_SUPPORT - { REGISTER_TEST_CASE(atca_cmd_basic_test, sign_internal), DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, sign_internal_ecc), REGISTER_TEST_CONDITION(atca_cmd_basic_test, sign_internal_ecc) }, #endif #if 0 - { REGISTER_TEST_CASE(atca_cmd_basic_test, read_sig), DEVICE_MASK_ATECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, read_sig), atca_test_cond_p256_sign }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-OFN* diff --git a/test/api_atcab/atca_tests_startup.c b/test/api_atcab/atca_tests_startup.c index 6c83c2926..6de63c40b 100644 --- a/test/api_atcab/atca_tests_startup.c +++ b/test/api_atcab/atca_tests_startup.c @@ -70,10 +70,11 @@ TEST(atca_cmd_basic_test, doubleinit) // *INDENT-OFF* - Preserve formatting t_test_case_info startup_basic_test_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, version), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, init), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, doubleinit), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ + { REGISTER_TEST_CASE(atca_cmd_basic_test, version), NULL }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, init), NULL }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, doubleinit), NULL }, + + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_updateextra.c b/test/api_atcab/atca_tests_updateextra.c index fe327ddea..813f4d35f 100644 --- a/test/api_atcab/atca_tests_updateextra.c +++ b/test/api_atcab/atca_tests_updateextra.c @@ -36,7 +36,7 @@ TEST(atca_cmd_basic_test, updateextra) // *INDENT-OFF* - Preserve formatting t_test_case_info updateextra_basic_test_info[] = { - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_verify.c b/test/api_atcab/atca_tests_verify.c index 66e7df7ee..f40a3e16a 100644 --- a/test/api_atcab/atca_tests_verify.c +++ b/test/api_atcab/atca_tests_verify.c @@ -237,6 +237,15 @@ TEST(atca_cmd_basic_test, verify_stored) } #if TEST_ATCAB_VERIFY_REQRANDOM_EN +TEST_CONDITION(atca_cmd_basic_test, verify_stored_on_reqrandom_set) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608 == dev_type)); +} + TEST(atca_cmd_basic_test, verify_stored_on_reqrandom_set) { ATCA_STATUS status; @@ -528,11 +537,27 @@ static void test_basic_verify_validate(void) TEST_ASSERT_EQUAL(true, is_verified); } +TEST_CONDITION(atca_cmd_basic_test, verify_validate) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608 == dev_type)); +} + TEST(atca_cmd_basic_test, verify_validate) { test_basic_verify_validate(); } +TEST_CONDITION(atca_cmd_basic_test, verify_invalidate) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC508A == dev_type) || (ATECC608 == dev_type)); +} + TEST(atca_cmd_basic_test, verify_invalidate) { const uint16_t public_key_id = 14; @@ -675,25 +700,27 @@ TEST(atca_cmd_basic_test, verify_invalidate) t_test_case_info verify_basic_test_info[] = { #if TEST_ATCAB_VERIFY_EXTERN_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_extern_nist), DEVICE_MASK_ATECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_extern), DEVICE_MASK_ATECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_extern_nist), atca_test_cond_p256_sign_verify }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_extern), atca_test_cond_p256_sign_verify }, #if TEST_ATCAB_VERIFY_MAC_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_extern_mac), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_extern_mac), atca_test_cond_ecc608 }, #endif #endif /* TEST_ATCAB_VERIFY_EXTERN_EN */ #if TEST_ATCAB_VERIFY_STORED_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_stored), DEVICE_MASK_ATECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_stored), atca_test_cond_p256_sign_verify }, #if TEST_ATCAB_VERIFY_REQRANDOM_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_stored_on_reqrandom_set), DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_stored_on_reqrandom_set), REGISTER_TEST_CONDITION(atca_cmd_basic_test, verify_stored_on_reqrandom_set) }, #endif #if TEST_ATCAB_VERIFY_MAC_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_stored_mac), DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_stored_mac), atca_test_cond_ecc608 }, #endif #endif /* TEST_ATCAB_VERIFY_STORED_EN */ #if TEST_ATCAB_VERIFY_VALIDATE_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_validate), DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_invalidate), DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_validate), REGISTER_TEST_CONDITION(atca_cmd_basic_test, verify_validate) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, verify_invalidate), REGISTER_TEST_CONDITION(atca_cmd_basic_test, verify_invalidate) }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* diff --git a/test/api_atcab/atca_tests_write.c b/test/api_atcab/atca_tests_write.c index 4743cb183..78394a2a3 100644 --- a/test/api_atcab/atca_tests_write.c +++ b/test/api_atcab/atca_tests_write.c @@ -28,7 +28,7 @@ #include "test_atcab.h" #ifndef TEST_ATCAB_WRITE_EN -#define TEST_ATCAB_WRITE_EN (CALIB_WRITE_EN || CALIB_WRITE_ECC204_EN || TALIB_WRITE_EN) +#define TEST_ATCAB_WRITE_EN (CALIB_WRITE_EN || CALIB_WRITE_CA2_EN || TALIB_WRITE_EN) #endif #ifndef TEST_ATCAB_WRITE_ENC_EN @@ -42,6 +42,13 @@ #endif #if CALIB_WRITE_EN +TEST_CONDITION(atca_cmd_basic_test, write) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return (atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)); +} + TEST(atca_cmd_basic_test, write_boundary_conditions) { ATCA_STATUS status = ATCA_SUCCESS; @@ -393,8 +400,15 @@ TEST(atca_cmd_basic_test, write_slot4_key) } #endif -#if CALIB_WRITE_ECC204_EN -TEST(atca_cmd_basic_test, write_ecc204_hmac_key) +#if CALIB_WRITE_CA2_EN +TEST_CONDITION(atca_cmd_basic_test, write_hmac_key) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ECC204 == dev_type) || (TA010 == dev_type)); +} + +TEST(atca_cmd_basic_test, write_hmac_key) { ATCA_STATUS status = ATCA_SUCCESS; uint16_t key_id; @@ -410,6 +424,19 @@ TEST(atca_cmd_basic_test, write_ecc204_hmac_key) } #endif +TEST_CONDITION(atca_cmd_basic_test, write_data_zone_blocks) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608A == dev_type) + || (ECC204 == dev_type) + || (TA010 == dev_type) + || (TA100 == dev_type) + ); +} + TEST(atca_cmd_basic_test, write_data_zone_blocks) { ATCA_STATUS status = ATCA_SUCCESS; @@ -418,7 +445,7 @@ TEST(atca_cmd_basic_test, write_data_zone_blocks) uint16_t slot; /* Note - This test assumes ECC slot sizes */ - if (ECC204 == gCfg->devtype) + if (atcab_is_ca2_device(gCfg->devtype)) { /* This test for the ECC204 needs to be run when the device data is unlocked */ test_assert_config_is_locked(); @@ -433,7 +460,7 @@ TEST(atca_cmd_basic_test, write_data_zone_blocks) status = atca_test_config_get_id(TEST_TYPE_DATA, &slot); TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); - if (ECC204 != gCfg->devtype) + if (!atcab_is_ca2_device(gCfg->devtype)) { #if CALIB_RANDOM_EN // Generate random data to be written @@ -452,7 +479,7 @@ TEST(atca_cmd_basic_test, write_data_zone_blocks) status = atcab_write_bytes_zone(ATCA_ZONE_DATA, slot, 4, write_data, sizeof(write_data)); TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); - if (ECC204 != gCfg->devtype) + if (!atcab_is_ca2_device(gCfg->devtype)) { status = atcab_read_bytes_zone(ATCA_ZONE_DATA, slot, 4, read_data, sizeof(read_data)); TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); @@ -465,7 +492,7 @@ TEST(atca_cmd_basic_test, write_data_zone_blocks) TEST_ASSERT_EQUAL_MEMORY(write_data, read_data, sizeof(write_data)); - if (ECC204 != gCfg->devtype) + if (!atcab_is_ca2_device(gCfg->devtype)) { // Test mid-block word writes status = atcab_write_zone(ATCA_ZONE_DATA, slot, 1, 6, write_data, 4); @@ -608,6 +635,17 @@ TEST(atca_cmd_basic_test, write_zone) // TODO - implement write zone basic api test } + +TEST_CONDITION(atca_cmd_basic_test, write_config_zone) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((atcab_is_ca_device(dev_type) && (ATSHA206A != dev_type)) + || atcab_is_ca2_device(dev_type) + || (TA100 == dev_type) + ); +} + TEST(atca_cmd_basic_test, write_config_zone) { ATCA_STATUS status = ATCA_NO_DEVICES; @@ -633,8 +671,9 @@ TEST(atca_cmd_basic_test, write_config_zone) status = atcab_write_config_zone(test_ecc608_configdata); break; #endif -#ifdef ATCA_ECC204_SUPPORT +#if defined(ATCA_ECC204_SUPPORT) || defined(ATCA_TA010_SUPPORT) case ECC204: + case TA010: status = atcab_write_config_zone(test_ecc204_configdata); break; #endif @@ -653,6 +692,17 @@ TEST(atca_cmd_basic_test, write_config_zone) } #if CALIB_WRITE_EN || TALIB_WRITE_EN +TEST_CONDITION(atca_cmd_basic_test, write_pubkey) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608A == dev_type) + || (TA100 == dev_type) + ); +} + TEST(atca_cmd_basic_test, write_pubkey) { uint16_t public_key_id; @@ -693,31 +743,33 @@ t_test_case_info write_basic_test_info[] = { #if TEST_ATCAB_WRITE_EN #if CALIB_WRITE_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_boundary_conditions), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - //{ REGISTER_TEST_CASE(atca_cmd_basic_test, write_upper_slots), DEVICE_MASK_ECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_invalid_block), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_invalid_block_len), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_bytes_zone_config), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_otp_zone_nolock), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_otp_zone_nolock_check), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_otp_zone), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_slot4_key), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_boundary_conditions), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, + //{ REGISTER_TEST_CASE(atca_cmd_basic_test, write_upper_slots), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_invalid_block), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write)}, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_invalid_block_len), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_bytes_zone_config), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_otp_zone_nolock), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_otp_zone_nolock_check), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_otp_zone), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_slot4_key), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, #endif - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_data_zone_blocks), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, -#if CALIB_WRITE_ECC204_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_ecc204_hmac_key), DEVICE_MASK(ECC204) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_data_zone_blocks), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write_data_zone_blocks) }, +#if CALIB_WRITE_CA2_EN + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_hmac_key), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write_hmac_key) }, #endif #if TEST_ATCAB_WRITE_ENC_EN //{ REGISTER_TEST_CASE(atca_cmd_basic_test, write_bytes_zone_slot8), DEVICE_MASK_ECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_enc), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_enc_data_unlock), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_enc), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_enc_data_unlock), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write) }, #endif - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_zone), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ATECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_config_zone), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_zone), NULL }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_config_zone), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write_config_zone) }, #if CALIB_WRITE_EN - { REGISTER_TEST_CASE(atca_cmd_basic_test, write_pubkey), DEVICE_MASK_ATECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, write_pubkey), REGISTER_TEST_CONDITION(atca_cmd_basic_test, write_pubkey) }, #endif #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* diff --git a/test/api_calib/test_calib.c b/test/api_calib/test_calib.c new file mode 100644 index 000000000..6fff94383 --- /dev/null +++ b/test/api_calib/test_calib.c @@ -0,0 +1,84 @@ +/** + * \file + * \brief Tests for the cryptoauthlib calib API + * + * \copyright (c) 2015-2020 Microchip Technology Inc. and its subsidiaries. + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip software + * and any derivatives exclusively with Microchip products. It is your + * responsibility to comply with third party license terms applicable to your + * use of third party software (including open source software) that may + * accompany Microchip software. + * + * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED + * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A + * PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, + * SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE + * OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + * MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + * FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL + * LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED + * THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR + * THIS SOFTWARE. + */ + +#include "atca_test.h" +#include "test_calib.h" + +//extern t_test_case_info calib_commands_info[]; +//extern t_test_case_info calib_packet_info[]; +extern t_test_case_info calib_info_tests[]; +extern t_test_case_info calib_delete_tests[]; + +static t_test_case_info* calib_test_list[] = +{ + /* Basic tests that should pass for all parts */ + calib_info_tests, + + /* Chip and Key Features */ + calib_delete_tests, + + /* Array Termination element*/ + (t_test_case_info*)NULL, +}; + +void run_all_calib_tests(void) +{ + RunAllTests(calib_test_list); +} + +int run_calib_tests(int argc, char* argv[]) +{ + return run_test(argc, argv, run_all_calib_tests); +} + +const char* CALIB_HELPER_FILE = "In helper: " __FILE__; +const char* TEST_GROUP_calib = "calib"; + +TEST_SETUP(calib) +{ + UnityMalloc_StartTest(); + + ATCA_STATUS status = atcab_init(gCfg); + TEST_ASSERT_SUCCESS_MSG(status, CALIB_HELPER_FILE); +} + +TEST_TEAR_DOWN(calib) +{ + ATCA_STATUS status; + bool test_failed = atca_test_already_exiting(); + bool comm_failed = atca_test_unresponsive(); + + status = atcab_release(); + if (!test_failed && !comm_failed) + { + /* Don't override the existing failure location or the global + status return value */ + TEST_ASSERT_SUCCESS_MSG(status, CALIB_HELPER_FILE); + } + + UnityMalloc_EndTest(); +} diff --git a/test/api_calib/test_calib.h b/test/api_calib/test_calib.h index 1c159c16f..beb9190e2 100644 --- a/test/api_calib/test_calib.h +++ b/test/api_calib/test_calib.h @@ -34,12 +34,17 @@ extern "C" { #endif -extern t_test_case_info calib_commands_info[]; -extern t_test_case_info calib_packet_info[]; - ATCA_STATUS calib_config_get_slot_by_test(uint8_t test_type, uint16_t* handle); ATCA_STATUS calib_config_get_ecc204_slot_by_test(uint8_t test_type, uint16_t* handle); +/* Test Commands */ +int run_calib_tests(int argc, char* argv[]); + +/* Common test setup/teardown */ +extern const char* TEST_GROUP_calib; +void TEST_calib_SETUP(void); +void TEST_calib_TEAR_DOWN(void); + #ifdef __cplusplus } #endif diff --git a/test/api_calib/test_calib_config.c b/test/api_calib/test_calib_config.c index 72b9ff482..37b426d2c 100644 --- a/test/api_calib/test_calib_config.c +++ b/test/api_calib/test_calib_config.c @@ -101,9 +101,9 @@ ATCA_STATUS calib_config_get_slot_by_test(uint8_t test_type, uint16_t* handle) } #endif -#ifdef ATCA_ECC204_SUPPORT +#if defined(ATCA_ECC204_SUPPORT) || defined(ATCA_TA010_SUPPORT) -const uint8_t test_ecc204_configdata[ATCA_ECC204_CONFIG_SIZE] = { +const uint8_t test_ecc204_configdata[ATCA_CA2_CONFIG_SIZE] = { 0xB9, 0xFA, 0x3C, 0x1A, 0xAA, 0xD4, 0x91, 0x7C, 0x03, 0x3C, 0x00, 0x00, 0x3E, 0xAF, 0x81, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, @@ -126,4 +126,3 @@ ATCA_STATUS calib_config_get_ecc204_slot_by_test(uint8_t test_type, uint16_t* ha #endif - diff --git a/test/api_calib/test_calib_delete.c b/test/api_calib/test_calib_delete.c new file mode 100644 index 000000000..117de1061 --- /dev/null +++ b/test/api_calib/test_calib_delete.c @@ -0,0 +1,73 @@ +/** + * \file + * \brief Unity tests for the cryptoauthlib Delete Command + * + * \copyright (c) 2015-2020 Microchip Technology Inc. and its subsidiaries. + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip software + * and any derivatives exclusively with Microchip products. It is your + * responsibility to comply with third party license terms applicable to your + * use of third party software (including open source software) that may + * accompany Microchip software. + * + * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED + * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A + * PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, + * SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE + * OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + * MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + * FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL + * LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED + * THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR + * THIS SOFTWARE. + */ +#include +#include "test_calib.h" + +#ifndef TEST_CALIB_DELETE_EN +#define TEST_CALIB_DELETE_EN (CALIB_DELETE_EN && ATCA_CA2_SUPPORT) +#endif + +#if defined(ATCA_TEST_DELETE_ENABLE) && TEST_CALIB_DELETE_EN + +TEST(calib, delete_test) +{ + ATCA_STATUS status = ATCA_SUCCESS; + uint8_t chip_status[4]; + uint8_t num_in[NONCE_NUMIN_SIZE] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20 }; + + // CSZ0 and CSZ1 should be locked + test_assert_config_is_locked(); + + // Get chip_status + status = atcab_info_chip_status(chip_status); + TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); + + if (0x00 == chip_status[0]) + { + // Perform delete + status = calib_delete(atcab_get_device(), num_in, g_slot4_key); + TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); + + // Read chip_status to ensure delete is successful + status = atcab_info_chip_status(chip_status); + TEST_ASSERT_EQUAL(ATCA_SUCCESS, status); + TEST_ASSERT_EQUAL(0xFF, chip_status[0]); + } +} +#endif + +// *INDENT-OFF* - Preserve formatting +t_test_case_info calib_delete_tests[] = +{ +#if defined(ATCA_TEST_DELETE_ENABLE) && TEST_CALIB_DELETE_EN + { REGISTER_TEST_CASE(calib, delete_test), atca_test_cond_ca2 }, +#endif + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, +}; +// *INDENT-ON* diff --git a/test/api_calib/test_calib_info.c b/test/api_calib/test_calib_info.c new file mode 100644 index 000000000..3289cbd25 --- /dev/null +++ b/test/api_calib/test_calib_info.c @@ -0,0 +1,98 @@ +/** + * \file + * \brief calib info tests + * + * \copyright (c) 2015-2020 Microchip Technology Inc. and its subsidiaries. + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip software + * and any derivatives exclusively with Microchip products. It is your + * responsibility to comply with third party license terms applicable to your + * use of third party software (including open source software) that may + * accompany Microchip software. + * + * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED + * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A + * PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, + * SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE + * OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + * MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + * FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL + * LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED + * THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR + * THIS SOFTWARE. + */ +#include +#include "test_calib.h" + +TEST(calib, info) +{ + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t revision[4]; + + status = atcab_info(revision); + TEST_ASSERT_SUCCESS(status); + if (atcab_is_ca_device(gCfg->devtype)) + { +#if ATCA_CA_SUPPORT + ATCADeviceType devtype = calib_get_devicetype(revision); + if (gCfg->devtype != devtype) + { + g_test_abort = true; + } + TEST_ASSERT_EQUAL_MESSAGE(gCfg->devtype, devtype, "Device Type Mismatch"); +#endif + } +} + +#if ATCA_CA2_SUPPORT +TEST(calib, info_lock_status) +{ + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t is_locked, slot = 1; + uint16_t param2; + + // lockstatus of Config subzone + param2 = ATCA_ZONE_CA2_CONFIG | (slot << 1); + + // is_locked = 0x00 means unlocked + // is_locked = 0x01 means locked + status = calib_info_lock_status(atcab_get_device(), param2, &is_locked); + TEST_ASSERT_SUCCESS(status); + + // lockstatus of Data zone + param2 = ATCA_ZONE_CA2_DATA | (slot << 1); + + // is_locked = 0x00 means unlocked + // is_locked = 0x01 means locked + status = calib_info_lock_status(atcab_get_device(), param2, &is_locked); + TEST_ASSERT_SUCCESS(status); +} + +TEST(calib, info_chip_status) +{ + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t chip_status[4]; + + // chip_status[0] = 0x00 means No Deletion + // chip_status[0] = 0xFF means Deletion has completed + status = calib_info_chip_status(atcab_get_device(), chip_status); + TEST_ASSERT_SUCCESS(status); +} +#endif + +// *INDENT-OFF* - Preserve formatting +t_test_case_info calib_info_tests[] = +{ + { REGISTER_TEST_CASE(calib, info), NULL}, +#if ATCA_CA2_SUPPORT + { REGISTER_TEST_CASE(calib, info_lock_status), atca_test_cond_ca2}, + { REGISTER_TEST_CASE(calib, info_chip_status), atca_test_cond_ca2}, +#endif + + /* Array Termination element*/ + { (fp_test_case)NULL, NULL }, +}; +// *INDENT-ON* diff --git a/test/api_crypto/test_crypto_aes.c b/test/api_crypto/test_crypto_aes.c index afb6f6e09..e14effc6d 100644 --- a/test/api_crypto/test_crypto_aes.c +++ b/test/api_crypto/test_crypto_aes.c @@ -218,9 +218,9 @@ TEST(atcac_aes, aes128_cmac_nist) // *INDENT-OFF* - Preserve formatting t_test_case_info atcac_aes_test_info[] = { - { REGISTER_TEST_CASE(atcac_aes, aes128_gcm_nist), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_aes, aes128_cmac_nist), DEVICE_MASK_NONE }, - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { REGISTER_TEST_CASE(atcac_aes, aes128_gcm_nist), NULL }, + { REGISTER_TEST_CASE(atcac_aes, aes128_cmac_nist), NULL }, + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* diff --git a/test/api_crypto/test_crypto_pad.c b/test/api_crypto/test_crypto_pad.c index 5011baf32..3bb73b7b8 100644 --- a/test/api_crypto/test_crypto_pad.c +++ b/test/api_crypto/test_crypto_pad.c @@ -123,10 +123,10 @@ TEST(atcac_pkcs7, unpad_invalid) t_test_case_info atcac_pad_test_info[] = { #if TEST_ATCAC_PKCS7_EN - { REGISTER_TEST_CASE(atcac_pkcs7, pad_success), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_pkcs7, unpad_success), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_pkcs7, unpad_invalid), DEVICE_MASK_NONE }, + { REGISTER_TEST_CASE(atcac_pkcs7, pad_success), NULL }, + { REGISTER_TEST_CASE(atcac_pkcs7, unpad_success), NULL }, + { REGISTER_TEST_CASE(atcac_pkcs7, unpad_invalid), NULL }, #endif /* Array Termination element*/ - { (fp_test_case)NULL, (uint8_t)0 }, + { (fp_test_case)NULL, NULL }, }; diff --git a/test/api_crypto/test_crypto_pbkdf2.c b/test/api_crypto/test_crypto_pbkdf2.c index 3bdea42f4..048cfa439 100644 --- a/test/api_crypto/test_crypto_pbkdf2.c +++ b/test/api_crypto/test_crypto_pbkdf2.c @@ -95,6 +95,13 @@ TEST_TEAR_DOWN(atcab_pbkdf2) UnityMalloc_EndTest(); } +TEST_CONDITION(atcab_pbkdf2, vectors) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return (dev_type == TA100 || dev_type == ATSHA204A || dev_type == ATECC608A); +} + TEST(atcab_pbkdf2, vectors) { ATCA_STATUS status; @@ -118,13 +125,11 @@ TEST(atcab_pbkdf2, vectors) t_test_case_info atcac_pbkdf2_test_info[] = { #if TEST_ATCAC_PBKDF2_EN - { REGISTER_TEST_CASE(atcac_pbkdf2, vectors), DEVICE_MASK_NONE }, + { REGISTER_TEST_CASE(atcac_pbkdf2, vectors), NULL }, #endif #if TEST_ATCAB_PBKDF2_EN - { REGISTER_TEST_CASE(atcab_pbkdf2, vectors), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atcab_pbkdf2, vectors), REGISTER_TEST_CONDITION(atcab_pbkdf2, vectors)}, #endif /* Array Termination element*/ - { (fp_test_case)NULL, (uint8_t)0 }, + { (fp_test_case)NULL, NULL }, }; - - diff --git a/test/api_crypto/test_crypto_pk.c b/test/api_crypto/test_crypto_pk.c index 5915ad0e0..fefc4ba9c 100644 --- a/test/api_crypto/test_crypto_pk.c +++ b/test/api_crypto/test_crypto_pk.c @@ -202,11 +202,11 @@ TEST(atcac_pk, derive_ecdh_p256_nist) // *INDENT-OFF* - Preserve formatting t_test_case_info atcac_pk_test_info[] = { - { REGISTER_TEST_CASE(atcac_pk, verify_nist), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_pk, init_public), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_pk, sign_simple), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_pk, derive_ecdh_p256_nist), DEVICE_MASK_NONE }, - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { REGISTER_TEST_CASE(atcac_pk, verify_nist), NULL }, + { REGISTER_TEST_CASE(atcac_pk, init_public), NULL }, + { REGISTER_TEST_CASE(atcac_pk, sign_simple), NULL }, + { REGISTER_TEST_CASE(atcac_pk, derive_ecdh_p256_nist), NULL }, + { (fp_test_case)NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* diff --git a/test/api_crypto/test_crypto_sha.c b/test/api_crypto/test_crypto_sha.c index b4407dcdc..8f3c2530c 100644 --- a/test/api_crypto/test_crypto_sha.c +++ b/test/api_crypto/test_crypto_sha.c @@ -612,23 +612,23 @@ TEST(atcac_sha, sha256_hmac_nist) t_test_case_info atcac_sha_test_info[] = { #if TEST_ATCAC_SHA1_EN - { REGISTER_TEST_CASE(atcac_sha, sha1_nist1), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha1_nist2), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha1_nist3), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha1_nist_short), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha1_nist_long), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha1_nist_monte), DEVICE_MASK_NONE }, + { REGISTER_TEST_CASE(atcac_sha, sha1_nist1), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha1_nist2), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha1_nist3), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha1_nist_short), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha1_nist_long), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha1_nist_monte), NULL }, #endif #if TEST_ATCAC_SHA256_EN - { REGISTER_TEST_CASE(atcac_sha, sha256_nist1), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha256_nist2), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha256_nist3), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha256_nist_short), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha256_nist_long), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha256_nist_monte), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha256_hmac), DEVICE_MASK_NONE }, - { REGISTER_TEST_CASE(atcac_sha, sha256_hmac_nist), DEVICE_MASK_NONE }, + { REGISTER_TEST_CASE(atcac_sha, sha256_nist1), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha256_nist2), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha256_nist3), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha256_nist_short), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha256_nist_long), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha256_nist_monte), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha256_hmac), NULL }, + { REGISTER_TEST_CASE(atcac_sha, sha256_hmac_nist), NULL }, #endif - { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ + { NULL, NULL }, /* Array Termination element*/ }; // *INDENT-ON* diff --git a/test/atca_test.c b/test/atca_test.c index e7d3b3a9e..507e5e5a2 100644 --- a/test/atca_test.c +++ b/test/atca_test.c @@ -181,7 +181,6 @@ int run_test(int argc, char* argv[], void (*fptest)(void)) void RunAllTests(t_test_case_info** tests_list) { t_test_case_info* sp_current_test; - uint32_t support_device_mask; /*Loop through all the commands test info*/ while ((*tests_list != NULL) && !atca_test_unresponsive()) @@ -192,12 +191,9 @@ void RunAllTests(t_test_case_info** tests_list) /*Loop through till last test in the test info*/ while (sp_current_test->fp_test != NULL) { - /*Get current device mask */ - support_device_mask = (gCfg->devtype < ATCA_DEV_UNKNOWN) ? DEVICE_MASK(gCfg->devtype) : DEVICE_MASK_NONE; + bool run_test = (NULL != sp_current_test->fp_condition) ? sp_current_test->fp_condition() : true; - /*check if current test mask contains current device mask*/ - if (!sp_current_test->support_device_mask || - ((sp_current_test->support_device_mask & support_device_mask) == support_device_mask)) + if(run_test) { /*Execute current test case*/ sp_current_test->fp_test(); @@ -391,7 +387,9 @@ ATCA_STATUS atca_test_config_get_id(uint8_t test_type, uint16_t* handle) status = calib_config_get_slot_by_test(test_type, handle); break; #endif -#ifdef ATCA_ECC204_SUPPORT +#if defined(ATCA_TA010_SUPPORT) || defined(ATCA_ECC204_SUPPORT) + case TA010: + /* fallthrough */ case ECC204: status = calib_config_get_ecc204_slot_by_test(test_type, handle); break; diff --git a/test/atca_test.h b/test/atca_test.h index 3ce56df37..65dfb8c9d 100644 --- a/test/atca_test.h +++ b/test/atca_test.h @@ -45,11 +45,12 @@ extern const uint8_t g_slot4_key[]; #define CMD_PROCESSOR_MAX_ARGS 16 typedef void (*fp_test_case)(void); +typedef bool (*fp_test_condition)(void); typedef struct { - fp_test_case fp_test; - uint32_t support_device_mask; + fp_test_case fp_test; + fp_test_condition fp_condition; }t_test_case_info; typedef int (*fp_menu_handler)(int argc, char* argv[]); @@ -74,14 +75,10 @@ typedef struct #define MENU_ITEM(c,d, f) {c, d, f} #endif -#define DEVICE_MASK(device) ((uint8_t)1 << device) -#define REGISTER_TEST_CASE(group, name) TEST_ ## group ## _ ## name ## _run +#define REGISTER_TEST_CASE(group, name) TEST_ ## group ## _ ## name ## _run +#define REGISTER_TEST_CONDITION(group, name) TEST_ ## group ## _ ## name ## _cond -#define DEVICE_MASK_SHA (DEVICE_MASK(ATSHA204A) | DEVICE_MASK(ATSHA206A)) -#define DEVICE_MASK_ATECC (DEVICE_MASK(ATECC108A) | DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608)) -#define DEVICE_MASK_ECC (DEVICE_MASK(ATECC108A) | DEVICE_MASK(ECC204) | DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608)) -#define DEVICE_MASK_NONE (0) -#define DEVICE_MASK_ANY UINT32_MAX +#define TEST_CONDITION(group, name) bool TEST_##group##_##name##_cond(void) #if !defined(ATCA_ECC_SUPPORT) && !defined(DO_NOT_TEST_CERT) #define DO_NOT_TEST_CERT @@ -129,8 +126,8 @@ extern const uint8_t test_ecc_configdata[ATCA_ECC_CONFIG_SIZE]; #ifdef ATCA_ATSHA204A_SUPPORT extern const uint8_t sha204_default_config[ATCA_SHA_CONFIG_SIZE]; #endif -#ifdef ATCA_ECC204_SUPPORT -extern const uint8_t test_ecc204_configdata[ATCA_ECC204_CONFIG_SIZE]; +#if defined(ATCA_ECC204_SUPPORT) || defined(ATCA_TA010_SUPPORT) +extern const uint8_t test_ecc204_configdata[ATCA_CA2_CONFIG_SIZE]; #endif #if ATCA_TA_SUPPORT extern const uint8_t test_ta100_configdata[TA_CONFIG_SIZE]; @@ -198,6 +195,14 @@ void RunPbkdf2Tests(void); /* Setup & Configuration */ void atca_test_config_set_ifacecfg(ATCAIfaceCfg * ifacecfg); ATCA_STATUS atca_test_genkey(uint16_t key_id, uint8_t *public_key); +ATCADeviceType atca_test_get_device_type(void); +bool atca_test_cond_p256_all(void); +bool atca_test_cond_p256_sign(void); +bool atca_test_cond_p256_sign_verify(void); +bool atca_test_cond_aes128_ecb(void); +bool atca_test_cond_ecc608(void); +bool atca_test_cond_ta100(void); +bool atca_test_cond_ca2(void); /* Commands */ int process_options(int argc, char* argv[]); diff --git a/test/atca_test_config.c b/test/atca_test_config.c index 1bf58d2bf..ea03d01e4 100644 --- a/test/atca_test_config.c +++ b/test/atca_test_config.c @@ -40,6 +40,7 @@ extern int select_508_custom(int argc, char* argv[]); extern int select_608_custom(int argc, char* argv[]); extern int select_ta100_custom(int argc, char* argv[]); extern int select_ecc204_custom(int argc, char* argv[]); +extern int select_ta010_custom(int argc, char* argv[]); #endif #ifdef ATCA_HAL_KIT_BRIDGE @@ -102,6 +103,79 @@ static void print_args(const char * f, int argc, char* argv[]) printf("\n"); } +/** \brief Retrieves the currently configured device + * +*/ +ATCADeviceType atca_test_get_device_type(void) +{ + return (NULL != gCfg) ? gCfg->devtype : ATCA_DEV_UNKNOWN; +} + +/** \brief Configured device is ECC608 */ +bool atca_test_cond_ecc608(void) +{ + return (ATECC608 == atca_test_get_device_type()); +} + +/** \brief Configured device is TA100 */ +bool atca_test_cond_ta100(void) +{ + return (TA100 == atca_test_get_device_type()); +} + +/** \brief Configured device supports all EC p256 operations + * +*/ +bool atca_test_cond_p256_all(void) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608 == dev_type) + || (TA100 == dev_type)); +} + +/** \brief Configured device supports EC p256 sign operations + * +*/ +bool atca_test_cond_p256_sign(void) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608 == dev_type) + || (ECC204 == dev_type) + || (TA010 == dev_type) + || (TA100 == dev_type)); +} + +/** \brief Configured device supports EC p256 sign & verify operations */ +bool atca_test_cond_p256_sign_verify(void) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC108A == dev_type) + || (ATECC508A == dev_type) + || (ATECC608 == dev_type) + || (TA100 == dev_type)); +} + +/** \brief Configured device supports AES128 ECB operations */ +bool atca_test_cond_aes128_ecb(void) +{ + ATCADeviceType dev_type = atca_test_get_device_type(); + + return ((ATECC608 == dev_type) || (TA100 == dev_type)); +} + +/** \brief Configured device is a second generation cryptoauth part */ +bool atca_test_cond_ca2(void) +{ + return atcab_is_ca2_device(atca_test_get_device_type()); +} + /** \brief Sets the device the command or test suite will use * * \param[in] ifacecfg Platform iface config to use @@ -147,7 +221,12 @@ static int select_custom(int argc, char* argv[]) ret = select_ecc204_custom(argc, argv); break; #endif -#ifdef ATCA_ECC204_SUPPORT +#ifdef ATCA_TA010_SUPPORT + case TA010: + ret = select_ta010_custom(argc, argv); + break; +#endif +#ifdef ATCA_TA100_SUPPORT case TA100: ret = select_ta100_custom(argc, argv); break; diff --git a/test/atca_test_console.c b/test/atca_test_console.c index 469ec58d2..dbe55e107 100644 --- a/test/atca_test_console.c +++ b/test/atca_test_console.c @@ -160,7 +160,7 @@ int do_randoms(int argc, char* argv[]) ((void)argc); ((void)argv); - if ((gCfg->devtype == ATSHA206A) || (ECC204 == gCfg->devtype)) + if ((gCfg->devtype == ATSHA206A) || (atcab_is_ca2_device(gCfg->devtype))) { printf("Selected Device doesn't support random command\r\n"); } diff --git a/test/cmd-processor.c b/test/cmd-processor.c index da73717a9..4d0f8cea2 100644 --- a/test/cmd-processor.c +++ b/test/cmd-processor.c @@ -84,6 +84,9 @@ static t_menu_info mas_menu_info[] = #ifdef ATCA_ECC204_SUPPORT { "ecc204", "Set Target Device to ECC204", select_device }, #endif +#ifdef ATCA_TA010_SUPPORT + { "ta010", "Set Target Device to TA010", select_device }, +#endif #ifdef ATCA_ATECC508A_SUPPORT { "ecc508", "Set Target Device to ATECC508A", select_device }, #endif @@ -128,6 +131,9 @@ static t_menu_info mas_menu_info[] = { "crypto_int", "Run crypto library integration tests", run_integration_tests }, #endif { "jwt", "Run JWT support tests", run_jwt_tests }, +#if ATCA_CA_SUPPORT + { "calib", "Run calib api tests", run_calib_tests }, +#endif #if ATCA_TA_SUPPORT { "config", "Create testing handles in TA100 device", talib_configure_device }, { "handles", "Print info for stored handles in TA100 device", talib_config_print_handles }, diff --git a/test/integration/test_mbedtls.c b/test/integration/test_mbedtls.c index 8cef2e513..7562308d3 100644 --- a/test/integration/test_mbedtls.c +++ b/test/integration/test_mbedtls.c @@ -226,11 +226,11 @@ TEST(mbedtls_ecdsa, sign_stored_key) t_test_case_info mbedtls_ecdsa_test_info[] = { - { REGISTER_TEST_CASE(mbedtls_ecdsa, verify_nist), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(mbedtls_ecdsa, verify_nist_stored_key), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(mbedtls_ecdsa, sign_stored_key), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(mbedtls_ecdsa, verify_nist), atca_test_cond_p256_sign_verify }, + { REGISTER_TEST_CASE(mbedtls_ecdsa, verify_nist_stored_key), atca_test_cond_p256_sign_verify }, + { REGISTER_TEST_CASE(mbedtls_ecdsa, sign_stored_key), atca_test_cond_p256_sign_verify }, /* Array Termination element*/ - { (fp_test_case)NULL, (uint8_t)0 }, + { (fp_test_case)NULL, NULL }, }; #endif diff --git a/test/jwt/atca_jwt_test.c b/test/jwt/atca_jwt_test.c index 93bf17d39..d43dd6a1f 100644 --- a/test/jwt/atca_jwt_test.c +++ b/test/jwt/atca_jwt_test.c @@ -27,7 +27,7 @@ #include "jwt/atca_jwt.h" #ifndef TEST_JWT_SIGN_EN -#define TEST_JWT_SIGN_EN (CALIB_SIGN_ECC204_EN || CALIB_SIGN_EN || TALIB_SIGN_EN) +#define TEST_JWT_SIGN_EN (CALIB_SIGN_CA2_EN || CALIB_SIGN_EN || TALIB_SIGN_EN) #endif #ifndef TEST_JWT_VERIFY_EN @@ -35,7 +35,6 @@ #endif /* Configuration Options */ -#define ATCA_JWT_TEST_DEVICES ( DEVICE_MASK(ATECC108A) | DEVICE_MASK(ATECC508A) | DEVICE_MASK(ATECC608) ) #define ATCA_JWT_TEST_SIGNING_KEY_ID (0) /* Test Vectors */ @@ -366,31 +365,31 @@ TEST(atca_jwt_crypto, finalize) // *INDENT-OFF* - Preserve formatting t_test_case_info jwt_unit_test_info[] = { - { REGISTER_TEST_CASE(atca_jwt, check_payload_start_period), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt, check_payload_start_brace), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt, check_payload_start_other), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt, check_payload_start_invalid_params), ATCA_JWT_TEST_DEVICES}, - - { REGISTER_TEST_CASE(atca_jwt, init), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt, init_invalid_params), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt, claim_add_string), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt, claim_add_string_invalid_params), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt, claim_add_numeric), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt, claim_add_numeric_invalid_params), ATCA_JWT_TEST_DEVICES}, + { REGISTER_TEST_CASE(atca_jwt, check_payload_start_period), NULL }, + { REGISTER_TEST_CASE(atca_jwt, check_payload_start_brace), NULL }, + { REGISTER_TEST_CASE(atca_jwt, check_payload_start_other), NULL }, + { REGISTER_TEST_CASE(atca_jwt, check_payload_start_invalid_params), NULL }, + + { REGISTER_TEST_CASE(atca_jwt, init), NULL }, + { REGISTER_TEST_CASE(atca_jwt, init_invalid_params), NULL }, + { REGISTER_TEST_CASE(atca_jwt, claim_add_string), NULL }, + { REGISTER_TEST_CASE(atca_jwt, claim_add_string_invalid_params), NULL }, + { REGISTER_TEST_CASE(atca_jwt, claim_add_numeric), NULL }, + { REGISTER_TEST_CASE(atca_jwt, claim_add_numeric_invalid_params), NULL }, #if TEST_JWT_VERIFY_EN - { REGISTER_TEST_CASE(atca_jwt, verify_invalid_params), ATCA_JWT_TEST_DEVICES}, + { REGISTER_TEST_CASE(atca_jwt, verify_invalid_params), NULL }, #endif #if TEST_JWT_SIGN_EN - { REGISTER_TEST_CASE(atca_jwt, finalize_invalid_params), ATCA_JWT_TEST_DEVICES}, + { REGISTER_TEST_CASE(atca_jwt, finalize_invalid_params), NULL }, #endif #if TEST_JWT_VERIFY_EN - { REGISTER_TEST_CASE(atca_jwt_crypto, verify), ATCA_JWT_TEST_DEVICES}, - { REGISTER_TEST_CASE(atca_jwt_crypto, verify_invalid), ATCA_JWT_TEST_DEVICES}, + { REGISTER_TEST_CASE(atca_jwt_crypto, verify), atca_test_cond_p256_sign_verify }, + { REGISTER_TEST_CASE(atca_jwt_crypto, verify_invalid), atca_test_cond_p256_sign_verify }, #endif #if TEST_JWT_SIGN_EN - { REGISTER_TEST_CASE(atca_jwt_crypto, finalize), ATCA_JWT_TEST_DEVICES}, + { REGISTER_TEST_CASE(atca_jwt_crypto, finalize), atca_test_cond_p256_sign_verify }, #endif { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; diff --git a/test/tng/tng_atca_test.c b/test/tng/tng_atca_test.c index 63b30aec7..c42a4b7d2 100644 --- a/test/tng/tng_atca_test.c +++ b/test/tng/tng_atca_test.c @@ -67,7 +67,7 @@ TEST(tng_atca, tng_get_device_pubkey) // *INDENT-OFF* - Preserve formatting t_test_case_info tng_atca_unit_test_info[] = { - { REGISTER_TEST_CASE(tng_atca, tng_get_device_pubkey), DEVICE_MASK(ATECC608)}, + { REGISTER_TEST_CASE(tng_atca, tng_get_device_pubkey), atca_test_cond_ecc608 }, { (fp_test_case)NULL, (uint8_t)0 }, }; -// *INDENT-ON* \ No newline at end of file +// *INDENT-ON* diff --git a/test/tng/tng_atcacert_client_test.c b/test/tng/tng_atcacert_client_test.c index 10a489adb..6da054b4a 100644 --- a/test/tng/tng_atcacert_client_test.c +++ b/test/tng/tng_atcacert_client_test.c @@ -415,17 +415,18 @@ TEST(tng_atcacert_client, tng_atcacert_device_public_key_cert) // *INDENT-OFF* - Preserve formatting t_test_case_info tng_atcacert_client_unit_test_info[] = { - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_root_public_key), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_root_cert), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_max_signer_cert_size), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_read_signer_cert), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_signer_public_key_no_cert), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_signer_public_key_cert), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_max_device_cert_size), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_read_device_cert_no_signer), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_read_device_cert_signer), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_device_public_key_no_cert), DEVICE_MASK(ATECC608)}, - { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_device_public_key_cert), DEVICE_MASK(ATECC608)}, - { (fp_test_case)NULL, (uint8_t)0 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_root_public_key), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_root_cert), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_max_signer_cert_size), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_read_signer_cert), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_signer_public_key_no_cert), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_signer_public_key_cert), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_max_device_cert_size), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_read_device_cert_no_signer), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_read_device_cert_signer), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_device_public_key_no_cert), atca_test_cond_ecc608 }, + { REGISTER_TEST_CASE(tng_atcacert_client, tng_atcacert_device_public_key_cert), atca_test_cond_ecc608 }, + + { (fp_test_case)NULL, NULL }, }; // *INDENT-ON* diff --git a/test/vectors/ecdh_nist_vectors.c b/test/vectors/ecdh_nist_vectors.c index d88a013bb..cc24c4eed 100644 --- a/test/vectors/ecdh_nist_vectors.c +++ b/test/vectors/ecdh_nist_vectors.c @@ -40,148 +40,148 @@ const ecdh_p256_test_vector ecdh_p256_test_vectors[] = { 0xcc, 0xc5, 0x85, 0x20, 0x60, 0x56, 0x1e, 0x68, 0x04, 0x0d, 0xd7, 0x77, 0x89, 0x97, 0xbd, 0x7b }, }, { - { 0x80, 0x9f, 0x04, 0x28, 0x9c, 0x64, 0x34, 0x8c, 0x01, 0x51, 0x5e, 0xb0, 0x3d, 0x5c, 0xe7, 0xac,0x1a, 0x8c, 0xb9, 0x49, 0x8f, 0x5c, 0xaa, 0x50, 0x19, 0x7e, 0x58, 0xd4, 0x3a, 0x86, 0xa7, 0xae, }, - { 0xb2, 0x9d, 0x84, 0xe8, 0x11, 0x19, 0x7f, 0x25, 0xeb, 0xa8, 0xf5, 0x19, 0x40, 0x92, 0xcb, 0x6f,0xf4, 0x40, 0xe2, 0x6d, 0x44, 0x21, 0x01, 0x13, 0x72, 0x46, 0x1f, 0x57, 0x92, 0x71, 0xcd, 0xa3, }, - { 0x38, 0xf6, 0x5d, 0x6d, 0xce, 0x47, 0x67, 0x60, 0x44, 0xd5, 0x8c, 0xe5, 0x13, 0x95, 0x82, 0xd5,0x68, 0xf6, 0x4b, 0xb1, 0x60, 0x98, 0xd1, 0x79, 0xdb, 0xab, 0x07, 0x74, 0x1d, 0xd5, 0xca, 0xf5, }, - { 0x05, 0x7d, 0x63, 0x60, 0x96, 0xcb, 0x80, 0xb6, 0x7a, 0x8c, 0x03, 0x8c, 0x89, 0x0e, 0x88, 0x7d,0x1a, 0xdf, 0xa4, 0x19, 0x5e, 0x9b, 0x3c, 0xe2, 0x41, 0xc8, 0xa7, 0x78, 0xc5, 0x9c, 0xda, 0x67, } + { 0x80, 0x9f, 0x04, 0x28, 0x9c, 0x64, 0x34, 0x8c, 0x01, 0x51, 0x5e, 0xb0, 0x3d, 0x5c, 0xe7, 0xac,0x1a, 0x8c, 0xb9, 0x49, 0x8f, 0x5c, 0xaa, 0x50, 0x19, 0x7e, 0x58, 0xd4, 0x3a, 0x86, 0xa7, 0xae, }, + { 0xb2, 0x9d, 0x84, 0xe8, 0x11, 0x19, 0x7f, 0x25, 0xeb, 0xa8, 0xf5, 0x19, 0x40, 0x92, 0xcb, 0x6f,0xf4, 0x40, 0xe2, 0x6d, 0x44, 0x21, 0x01, 0x13, 0x72, 0x46, 0x1f, 0x57, 0x92, 0x71, 0xcd, 0xa3, }, + { 0x38, 0xf6, 0x5d, 0x6d, 0xce, 0x47, 0x67, 0x60, 0x44, 0xd5, 0x8c, 0xe5, 0x13, 0x95, 0x82, 0xd5,0x68, 0xf6, 0x4b, 0xb1, 0x60, 0x98, 0xd1, 0x79, 0xdb, 0xab, 0x07, 0x74, 0x1d, 0xd5, 0xca, 0xf5, }, + { 0x05, 0x7d, 0x63, 0x60, 0x96, 0xcb, 0x80, 0xb6, 0x7a, 0x8c, 0x03, 0x8c, 0x89, 0x0e, 0x88, 0x7d,0x1a, 0xdf, 0xa4, 0x19, 0x5e, 0x9b, 0x3c, 0xe2, 0x41, 0xc8, 0xa7, 0x78, 0xc5, 0x9c, 0xda, 0x67, } }, { - { 0xa2, 0x33, 0x9c, 0x12, 0xd4, 0xa0, 0x3c, 0x33, 0x54, 0x6d, 0xe5, 0x33, 0x26, 0x8b, 0x4a, 0xd6,0x67, 0xde, 0xbf, 0x45, 0x8b, 0x46, 0x4d, 0x77, 0x44, 0x36, 0x36, 0x44, 0x0e, 0xe7, 0xfe, 0xc3, }, - { 0xef, 0x48, 0xa3, 0xab, 0x26, 0xe2, 0x02, 0x20, 0xbc, 0xda, 0x2c, 0x18, 0x51, 0x07, 0x68, 0x39,0xda, 0xe8, 0x8e, 0xae, 0x96, 0x28, 0x69, 0xa4, 0x97, 0xbf, 0x73, 0xcb, 0x66, 0xfa, 0xf5, 0x36, }, - { 0x1a, 0xcc, 0xfa, 0xf1, 0xb9, 0x77, 0x12, 0xb8, 0x5a, 0x6f, 0x54, 0xb1, 0x48, 0x98, 0x5a, 0x1b,0xdc, 0x4c, 0x9b, 0xec, 0x0b, 0xd2, 0x58, 0xca, 0xd4, 0xb3, 0xd6, 0x03, 0xf4, 0x9f, 0x32, 0xc8, }, - { 0x2d, 0x45, 0x7b, 0x78, 0xb4, 0x61, 0x41, 0x32, 0x47, 0x76, 0x18, 0xa5, 0xb0, 0x77, 0x96, 0x5e,0xc9, 0x07, 0x30, 0xa8, 0xc8, 0x1a, 0x1c, 0x75, 0xd6, 0xd4, 0xec, 0x68, 0x00, 0x5d, 0x67, 0xec, }, + { 0xa2, 0x33, 0x9c, 0x12, 0xd4, 0xa0, 0x3c, 0x33, 0x54, 0x6d, 0xe5, 0x33, 0x26, 0x8b, 0x4a, 0xd6,0x67, 0xde, 0xbf, 0x45, 0x8b, 0x46, 0x4d, 0x77, 0x44, 0x36, 0x36, 0x44, 0x0e, 0xe7, 0xfe, 0xc3, }, + { 0xef, 0x48, 0xa3, 0xab, 0x26, 0xe2, 0x02, 0x20, 0xbc, 0xda, 0x2c, 0x18, 0x51, 0x07, 0x68, 0x39,0xda, 0xe8, 0x8e, 0xae, 0x96, 0x28, 0x69, 0xa4, 0x97, 0xbf, 0x73, 0xcb, 0x66, 0xfa, 0xf5, 0x36, }, + { 0x1a, 0xcc, 0xfa, 0xf1, 0xb9, 0x77, 0x12, 0xb8, 0x5a, 0x6f, 0x54, 0xb1, 0x48, 0x98, 0x5a, 0x1b,0xdc, 0x4c, 0x9b, 0xec, 0x0b, 0xd2, 0x58, 0xca, 0xd4, 0xb3, 0xd6, 0x03, 0xf4, 0x9f, 0x32, 0xc8, }, + { 0x2d, 0x45, 0x7b, 0x78, 0xb4, 0x61, 0x41, 0x32, 0x47, 0x76, 0x18, 0xa5, 0xb0, 0x77, 0x96, 0x5e,0xc9, 0x07, 0x30, 0xa8, 0xc8, 0x1a, 0x1c, 0x75, 0xd6, 0xd4, 0xec, 0x68, 0x00, 0x5d, 0x67, 0xec, }, }, { - { 0xdf, 0x39, 0x89, 0xb9, 0xfa, 0x55, 0x49, 0x57, 0x19, 0xb3, 0xcf, 0x46, 0xdc, 0xcd, 0x28, 0xb5,0x15, 0x3f, 0x78, 0x08, 0x19, 0x1d, 0xd5, 0x18, 0xef, 0xf0, 0xc3, 0xcf, 0xf2, 0xb7, 0x05, 0xed, }, - { 0x42, 0x22, 0x94, 0xff, 0x46, 0x00, 0x34, 0x29, 0xd7, 0x39, 0xa3, 0x32, 0x06, 0xc8, 0x75, 0x25,0x52, 0xc8, 0xba, 0x54, 0xa2, 0x70, 0xde, 0xfc, 0x06, 0xe2, 0x21, 0xe0, 0xfe, 0xaf, 0x6a, 0xc4, }, - { 0x20, 0x7c, 0x43, 0xa7, 0x9b, 0xfe, 0xe0, 0x3d, 0xb6, 0xf4, 0xb9, 0x44, 0xf5, 0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0xf3, 0xff, 0xa0, 0x2e, 0x33, 0xa0, 0x72, 0x2a, 0x13, 0x28, }, + { 0x59, 0x13, 0x7e, 0x38, 0x15, 0x23, 0x50, 0xb1, 0x95, 0xc9, 0x71, 0x8d, 0x39, 0x67, 0x3d, 0x51,0x98, 0x38, 0x05, 0x5a, 0xd9, 0x08, 0xdd, 0x47, 0x57, 0x15, 0x2f, 0xd8, 0x25, 0x5c, 0x09, 0xbf, }, + { 0x19, 0xd4, 0x4c, 0x8d, 0x63, 0xe8, 0xe8, 0xdd, 0x12, 0xc2, 0x2a, 0x87, 0xb8, 0xcd, 0x4e, 0xce,0x27, 0xac, 0xdd, 0xe0, 0x4d, 0xbf, 0x47, 0xf7, 0xf2, 0x75, 0x37, 0xa6, 0x99, 0x9a, 0x8e, 0x62, }, }, { - { 0x33, 0xe8, 0x20, 0x92, 0xa0, 0xf1, 0xfb, 0x38, 0xf5, 0x64, 0x9d, 0x58, 0x67, 0xfb, 0xa2, 0x8b,0x50, 0x31, 0x72, 0xb7, 0x03, 0x55, 0x74, 0xbf, 0x8e, 0x5b, 0x71, 0x00, 0xa3, 0x05, 0x27, 0x92, }, - { 0xf2, 0xcf, 0x6b, 0x60, 0x1e, 0x0a, 0x05, 0x94, 0x5e, 0x33, 0x55, 0x50, 0xbf, 0x64, 0x8d, 0x78,0x2f, 0x46, 0x18, 0x6c, 0x77, 0x2c, 0x0f, 0x20, 0xd3, 0xcd, 0x0d, 0x6b, 0x8c, 0xa1, 0x4b, 0x2f, }, - { 0xf5, 0xf8, 0xe0, 0x17, 0x46, 0x10, 0xa6, 0x61, 0x27, 0x79, 0x79, 0xb5, 0x8c, 0xe5, 0xc9, 0x0f,0xee, 0x6c, 0x9b, 0x3b, 0xb3, 0x46, 0xa9, 0x0a, 0x71, 0x96, 0x25, 0x5e, 0x40, 0xb1, 0x32, 0xef, }, - { 0x66, 0x4e, 0x45, 0xd5, 0xbb, 0xa4, 0xac, 0x93, 0x1c, 0xd6, 0x5d, 0x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 0xc8, 0xf6, 0xc3, 0x95, 0xe9, 0xf8, 0x48, }, - { 0x83, 0x88, 0xfa, 0x79, 0xc4, 0xba, 0xbd, 0xca, 0x02, 0xa8, 0xe8, 0xa3, 0x4f, 0x9e, 0x43, 0x55,0x49, 0x76, 0xe4, 0x20, 0xa4, 0xad, 0x27, 0x3c, 0x81, 0xb2, 0x6e, 0x42, 0x28, 0xe9, 0xd3, 0xa3, }, + { 0xf7, 0x5a, 0x5f, 0xe5, 0x6b, 0xda, 0x34, 0xf3, 0xc1, 0x39, 0x62, 0x96, 0x62, 0x6e, 0xf0, 0x12,0xdc, 0x07, 0xe4, 0x82, 0x58, 0x38, 0x77, 0x8a, 0x64, 0x5c, 0x82, 0x48, 0xcf, 0xf0, 0x16, 0x58, }, + { 0x33, 0xbb, 0xdf, 0x1b, 0x17, 0x72, 0xd8, 0x05, 0x9d, 0xf5, 0x68, 0xb0, 0x61, 0xf3, 0xf1, 0x12,0x2f, 0x28, 0xa8, 0xd8, 0x19, 0x16, 0x7c, 0x97, 0xbe, 0x44, 0x8e, 0x3d, 0xc3, 0xfb, 0x0c, 0x3c, }, + { 0x77, 0xc1, 0x5d, 0xcf, 0x44, 0x61, 0x0e, 0x41, 0x69, 0x6b, 0xab, 0x75, 0x89, 0x43, 0xef, 0xf1,0x40, 0x93, 0x33, 0xe4, 0xd5, 0xa1, 0x1b, 0xbe, 0x72, 0xc8, 0xf6, 0xc3, 0x95, 0xe9, 0xf8, 0x48, }, + { 0x83, 0x88, 0xfa, 0x79, 0xc4, 0xba, 0xbd, 0xca, 0x02, 0xa8, 0xe8, 0xa3, 0x4f, 0x9e, 0x43, 0x55,0x49, 0x76, 0xe4, 0x20, 0xa4, 0xad, 0x27, 0x3c, 0x81, 0xb2, 0x6e, 0x42, 0x28, 0xe9, 0xd3, 0xa3, }, }, { - { 0x2d, 0xb4, 0x54, 0x0d, 0x50, 0x23, 0x07, 0x56, 0x15, 0x8a, 0xbf, 0x61, 0xd9, 0x83, 0x57, 0x12,0xb6, 0x48, 0x6c, 0x74, 0x31, 0x21, 0x83, 0xcc, 0xef, 0xca, 0xef, 0x27, 0x97, 0xb7, 0x67, 0x4d, }, - { 0x62, 0xf5, 0x7f, 0x31, 0x4e, 0x3f, 0x34, 0x95, 0xdc, 0x4e, 0x09, 0x90, 0x12, 0xf5, 0xe0, 0xba,0x71, 0x77, 0x0f, 0x96, 0x60, 0xa1, 0xea, 0xda, 0x54, 0x10, 0x4c, 0xdf, 0xde, 0x77, 0x24, 0x3e, }, - { 0x42, 0xa8, 0x3b, 0x98, 0x50, 0x11, 0xd1, 0x23, 0x03, 0xdb, 0x1a, 0x80, 0x0f, 0x26, 0x10, 0xf7,0x4a, 0xa7, 0x1c, 0xdf, 0x19, 0xc6, 0x7d, 0x54, 0xce, 0x6c, 0x9e, 0xd9, 0x51, 0xe9, 0x09, 0x3e, }, - { 0x72, 0x87, 0x7c, 0xea, 0x33, 0xcc, 0xc4, 0x71, 0x50, 0x38, 0xd4, 0xbc, 0xbd, 0xfe, 0x0e, 0x43,0xf4, 0x2a, 0x9e, 0x2c, 0x0c, 0x3b, 0x01, 0x7f, 0xc2, 0x37, 0x0f, 0x4b, 0x9a, 0xcb, 0xda, 0x4a, }, + { 0x2d, 0xb4, 0x54, 0x0d, 0x50, 0x23, 0x07, 0x56, 0x15, 0x8a, 0xbf, 0x61, 0xd9, 0x83, 0x57, 0x12,0xb6, 0x48, 0x6c, 0x74, 0x31, 0x21, 0x83, 0xcc, 0xef, 0xca, 0xef, 0x27, 0x97, 0xb7, 0x67, 0x4d, }, + { 0x62, 0xf5, 0x7f, 0x31, 0x4e, 0x3f, 0x34, 0x95, 0xdc, 0x4e, 0x09, 0x90, 0x12, 0xf5, 0xe0, 0xba,0x71, 0x77, 0x0f, 0x96, 0x60, 0xa1, 0xea, 0xda, 0x54, 0x10, 0x4c, 0xdf, 0xde, 0x77, 0x24, 0x3e, }, + { 0x42, 0xa8, 0x3b, 0x98, 0x50, 0x11, 0xd1, 0x23, 0x03, 0xdb, 0x1a, 0x80, 0x0f, 0x26, 0x10, 0xf7,0x4a, 0xa7, 0x1c, 0xdf, 0x19, 0xc6, 0x7d, 0x54, 0xce, 0x6c, 0x9e, 0xd9, 0x51, 0xe9, 0x09, 0x3e, }, + { 0x72, 0x87, 0x7c, 0xea, 0x33, 0xcc, 0xc4, 0x71, 0x50, 0x38, 0xd4, 0xbc, 0xbd, 0xfe, 0x0e, 0x43,0xf4, 0x2a, 0x9e, 0x2c, 0x0c, 0x3b, 0x01, 0x7f, 0xc2, 0x37, 0x0f, 0x4b, 0x9a, 0xcb, 0xda, 0x4a, }, }, { - { 0xcd, 0x94, 0xfc, 0x94, 0x97, 0xe8, 0x99, 0x07, 0x50, 0x30, 0x9e, 0x9a, 0x85, 0x34, 0xfd, 0x11,0x4b, 0x0a, 0x6e, 0x54, 0xda, 0x89, 0xc4, 0x79, 0x61, 0x01, 0x89, 0x70, 0x41, 0xd1, 0x4e, 0xcb, }, - { 0xc3, 0xde, 0xf4, 0xb5, 0xfe, 0x04, 0xfa, 0xee, 0x0a, 0x11, 0x93, 0x22, 0x29, 0xff, 0xf5, 0x63,0x63, 0x7b, 0xfd, 0xee, 0x0e, 0x79, 0xc6, 0xde, 0xea, 0xf4, 0x49, 0xf8, 0x54, 0x01, 0xc5, 0xc4, }, - { 0xce, 0xed, 0x35, 0x50, 0x7b, 0x5c, 0x93, 0xea, 0xd5, 0x98, 0x91, 0x19, 0xb9, 0xba, 0x34, 0x2c,0xfe, 0x38, 0xe6, 0xe6, 0x38, 0xba, 0x6e, 0xea, 0x34, 0x3a, 0x55, 0x47, 0x5d, 0xe2, 0x80, 0x0b, }, - { 0xe4, 0xe7, 0x40, 0x8d, 0x85, 0xff, 0x0e, 0x0e, 0x9c, 0x83, 0x80, 0x03, 0xf2, 0x8c, 0xdb, 0xd5,0x24, 0x7c, 0xdc, 0xe3, 0x1f, 0x32, 0xf6, 0x24, 0x94, 0xb7, 0x0e, 0x5f, 0x1b, 0xc3, 0x63, 0x07, }, + { 0xcd, 0x94, 0xfc, 0x94, 0x97, 0xe8, 0x99, 0x07, 0x50, 0x30, 0x9e, 0x9a, 0x85, 0x34, 0xfd, 0x11,0x4b, 0x0a, 0x6e, 0x54, 0xda, 0x89, 0xc4, 0x79, 0x61, 0x01, 0x89, 0x70, 0x41, 0xd1, 0x4e, 0xcb, }, + { 0xc3, 0xde, 0xf4, 0xb5, 0xfe, 0x04, 0xfa, 0xee, 0x0a, 0x11, 0x93, 0x22, 0x29, 0xff, 0xf5, 0x63,0x63, 0x7b, 0xfd, 0xee, 0x0e, 0x79, 0xc6, 0xde, 0xea, 0xf4, 0x49, 0xf8, 0x54, 0x01, 0xc5, 0xc4, }, + { 0xce, 0xed, 0x35, 0x50, 0x7b, 0x5c, 0x93, 0xea, 0xd5, 0x98, 0x91, 0x19, 0xb9, 0xba, 0x34, 0x2c,0xfe, 0x38, 0xe6, 0xe6, 0x38, 0xba, 0x6e, 0xea, 0x34, 0x3a, 0x55, 0x47, 0x5d, 0xe2, 0x80, 0x0b, }, + { 0xe4, 0xe7, 0x40, 0x8d, 0x85, 0xff, 0x0e, 0x0e, 0x9c, 0x83, 0x80, 0x03, 0xf2, 0x8c, 0xdb, 0xd5,0x24, 0x7c, 0xdc, 0xe3, 0x1f, 0x32, 0xf6, 0x24, 0x94, 0xb7, 0x0e, 0x5f, 0x1b, 0xc3, 0x63, 0x07, }, }, { - { 0x15, 0xb9, 0xe4, 0x67, 0xaf, 0x4d, 0x29, 0x0c, 0x41, 0x74, 0x02, 0xe0, 0x40, 0x42, 0x6f, 0xe4,0xcf, 0x23, 0x6b, 0xae, 0x72, 0xba, 0xa3, 0x92, 0xed, 0x89, 0x78, 0x0d, 0xfc, 0xcd, 0xb4, 0x71, }, - { 0xcd, 0xf4, 0xe9, 0x17, 0x0f, 0xb9, 0x04, 0x30, 0x2b, 0x8f, 0xd9, 0x3a, 0x82, 0x0b, 0xa8, 0xcc,0x7e, 0xd4, 0xef, 0x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c6, 0x1f, 0x33, 0xad, 0xfe, 0x93, 0x11, 0xc9, 0x42, 0xfd, 0xbf, 0xf6, 0xba, 0x47,0x02, 0x0f, 0xef, 0xf4, 0x16, 0xb7, 0xbb, 0x63, 0xce, 0xc1, 0x3f, 0xaf, 0x9b, 0x09, 0x99, 0x54, }, - { 0x6c, 0xab, 0x31, 0xb0, 0x64, 0x19, 0xe5, 0x22, 0x1f, 0xca, 0x01, 0x4f, 0xb8, 0x4e, 0xc8, 0x70,0x62, 0x2a, 0x1b, 0x12, 0xba, 0xb5, 0xae, 0x43, 0x68, 0x2a, 0xa7, 0xea, 0x73, 0xea, 0x08, 0xd0, }, - { 0x4d, 0xfa, 0x12, 0xde, 0xfc, 0x60, 0x31, 0x90, 0x21, 0xb6, 0x81, 0xb3, 0xff, 0x84, 0xa1, 0x0a,0x51, 0x19, 0x58, 0xc8, 0x50, 0x93, 0x9e, 0xd4, 0x56, 0x35, 0x93, 0x4b, 0xa4, 0x97, 0x91, 0x47, }, - { 0x3c, 0xa1, 0xfc, 0x7a, 0xd8, 0x58, 0xfb, 0x1a, 0x6a, 0xba, 0x23, 0x25, 0x42, 0xf3, 0xe2, 0xa7,0x49, 0xff, 0xc7, 0x20, 0x3a, 0x23, 0x74, 0xa3, 0xf3, 0xd3, 0x26, 0x7f, 0x1f, 0xc9, 0x7b, 0x78, }, + { 0x2c, 0x91, 0xc6, 0x1f, 0x33, 0xad, 0xfe, 0x93, 0x11, 0xc9, 0x42, 0xfd, 0xbf, 0xf6, 0xba, 0x47,0x02, 0x0f, 0xef, 0xf4, 0x16, 0xb7, 0xbb, 0x63, 0xce, 0xc1, 0x3f, 0xaf, 0x9b, 0x09, 0x99, 0x54, }, + { 0x6c, 0xab, 0x31, 0xb0, 0x64, 0x19, 0xe5, 0x22, 0x1f, 0xca, 0x01, 0x4f, 0xb8, 0x4e, 0xc8, 0x70,0x62, 0x2a, 0x1b, 0x12, 0xba, 0xb5, 0xae, 0x43, 0x68, 0x2a, 0xa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xd6, 0x92, 0x2c, 0xf7, 0xfe,0x16, 0x26, 0xae, 0xd0, 0x44, 0x68, 0x5e, 0x95, 0xe2, 0xee, 0xbd, 0x46, 0x45, 0x05, 0xf0, 0x1f, }, + { 0xe9, 0xdd, 0xd5, 0x83, 0xa9, 0x63, 0x5a, 0x66, 0x77, 0x77, 0xd5, 0xb8, 0xa8, 0xf3, 0x1b, 0x0f,0x79, 0xeb, 0xa1, 0x2c, 0x75, 0x02, 0x34, 0x10, 0xb5, 0x4b, 0x85, 0x67, 0xdd, 0xdc, 0x0f, 0x38, }, + { 0x5a, 0xe0, 0x26, 0xcf, 0xc0, 0x60, 0xd5, 0x56, 0x00, 0x71, 0x7e, 0x55, 0xb8, 0xa1, 0x2e, 0x11,0x6d, 0x1d, 0x0d, 0xf3, 0x4a, 0xf8, 0x31, 0x97, 0x90, 0x57, 0x60, 0x7c, 0x2d, 0x9c, 0x2f, 0x76, }, + { 0x1c, 0xe9, 0xe6, 0x74, 0x05, 0x29, 0x49, 0x9f, 0x98, 0xd1, 0xf1, 0xd7, 0x13, 0x29, 0x14, 0x7a,0x33, 0xdf, 0x1d, 0x05, 0xe4, 0x76, 0x5b, 0x53, 0x9b, 0x11, 0xcf, 0x61, 0x5d, 0x69, 0x74, 0xd3, }, }, { - { 0xc1, 0x88, 0xff, 0xc8, 0x94, 0x7f, 0x73, 0x01, 0xfb, 0x7b, 0x53, 0xe3, 0x67, 0x46, 0x09, 0x7c,0x21, 0x34, 0xbf, 0x9c, 0xc9, 0x81, 0xba, 0x74, 0xb4, 0xe9, 0xc4, 0x36, 0x1f, 0x59, 0x5e, 0x4e, }, - { 0xbf, 0x7d, 0x2f, 0x20, 0x56, 0xe7, 0x24, 0x21, 0xef, 0x39, 0x3f, 0x0c, 0x0f, 0x2b, 0x0e, 0x00,0x13, 0x0e, 0x3c, 0xac, 0x4a, 0xbb, 0xcc, 0x00, 0x28, 0x61, 0x68, 0xe8, 0x5e, 0xc5, 0x50, 0x51, }, - { 0x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8a, 0x85, 0xae, 0x08, 0x44, 0x1b, 0x67, 0x56, 0x44, 0x5d, 0xf5, 0x49, 0x38, 0x57, }, + { 0x35, 0x6c, 0x5a, 0x44, 0x4c, 0x04, 0x9a, 0x52, 0xfe, 0xe0, 0xad, 0xeb, 0x7e, 0x5d, 0x82, 0xae,0x5a, 0xa8, 0x30, 0x30, 0xbf, 0xff, 0x31, 0xbb, 0xf8, 0xce, 0x20, 0x96, 0xcf, 0x16, 0x1c, 0x4b, }, + { 0x57, 0xd1, 0x28, 0xde, 0x8b, 0x2a, 0x57, 0xa0, 0x94, 0xd1, 0xa0, 0x01, 0xe5, 0x72, 0x17, 0x3f,0x96, 0xe8, 0x86, 0x6a, 0xe3, 0x52, 0xbf, 0x29, 0xcd, 0xda, 0xf9, 0x2f, 0xc8, 0x5b, 0x2f, 0x92, }, + { 0x85, 0xa2, 0x68, 0xf9, 0xd7, 0x77, 0x2f, 0x99, 0x0c, 0x36, 0xb4, 0x2b, 0x0a, 0x33, 0x1a, 0xdc,0x92, 0xb5, 0x94, 0x1d, 0xe0, 0xb8, 0x62, 0xd5, 0xd8, 0x9a, 0x34, 0x7c, 0xbf, 0x8f, 0xaa, 0xb0, }, + { 0x1e, 0x51, 0x37, 0x3b, 0xd2, 0xc6, 0x04, 0x4c, 0x12, 0x9c, 0x43, 0x6e, 0x74, 0x2a, 0x55, 0xbe,0x2a, 0x66, 0x8a, 0x85, 0xae, 0x08, 0x44, 0x1b, 0x67, 0x56, 0x44, 0x5d, 0xf5, 0x49, 0x38, 0x57, }, } }; diff --git a/test/vectors/ecdsa_nist_vectors.c b/test/vectors/ecdsa_nist_vectors.c index e44b2229a..9a11ff581 100644 --- a/test/vectors/ecdsa_nist_vectors.c +++ b/test/vectors/ecdsa_nist_vectors.c @@ -50,11 +50,11 @@ const ecdsa_p256_test_vector ecdsa_p256_test_vectors[] = { "3 - S Changed" }, { - { 0x06, 0x9a, 0x6e, 0x6b, 0x93, 0xdf, 0xee, 0x6d, 0x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 0x23, 0xd1, 0x30, 0xc6, 0x11, 0x7f, 0xb5, 0x75, 0x12, 0x01, 0x45, 0x5e, 0x99, 0xf3, 0x6f,0x59, 0xab, 0xa1, 0xa6, 0xa2, 0x1c, 0xf2, 0xd0, 0xe7, 0x48, 0x1a, 0x97, 0x45, 0x1d, 0x66, 0x93, }, - { 0xd6, 0xce, 0x77, 0x08, 0xc1, 0x8d, 0xbf, 0x35, 0xd4, 0xf8, 0xaa, 0x72, 0x40, 0x92, 0x2d, 0xc6,0x82, 0x3f, 0x2e, 0x70, 0x58, 0xcb, 0xc1, 0x48, 0x4f, 0xca, 0xd1, 0x59, 0x9d, 0xb5, 0x01, 0x8c, }, + { 0x06, 0x9a, 0x6e, 0x6b, 0x93, 0xdf, 0xee, 0x6d, 0xf6, 0xef, 0x69, 0x97, 0xcd, 0x80, 0xdd, 0x21,0x82, 0xc3, 0x66, 0x53, 0xce, 0xf1, 0x0c, 0x65, 0x5d, 0x52, 0x45, 0x85, 0x65, 0x54, 0x62, 0xd6, 0x83, 0x87, 0x7f, 0x95, 0xec, 0xc6, 0xd6, 0xc8, 0x16, 0x23, 0xd8, 0xfa, 0xc4, 0xe9, 0x00, 0xed, 0x00, 0x19, 0x96, 0x40, 0x94, 0xe7, 0xde, 0x91, 0xf1, 0x48, 0x19, 0x89, 0xae, 0x18, 0x73, 0x00, 0x45, 0x65, 0x78, 0x9c, 0xbf, 0x5d, 0xc5, 0x6c, 0x62, 0xae, 0xdc, 0x63, 0xf6, 0x2f, 0x3b, 0x89, 0x4c, 0x9c, 0x6f, 0x77, 0x88, 0xc8, 0xec, 0xaa, 0xdc, 0x9b, 0xd0, 0xe8, 0x1a, 0xd9, 0x1b, 0x2b, 0x35, 0x69, 0xea, 0x12, 0x26, 0x0e, 0x93, 0x92, 0x4f, 0xdd, 0xdd, 0x39, 0x72, 0xaf, 0x52, 0x73, 0x19, 0x8f, 0x5e, 0xfd, 0xa0, 0x74, 0x62, 0x19, 0x47, 0x50, 0x17, 0x55, 0x76, 0x16, 0x17, 0x0e, }, + { 0x5c, 0xf0, 0x2a, 0x00, 0xd2, 0x05, 0xbd, 0xfe, 0xe2, 0x01, 0x6f, 0x74, 0x21, 0x80, 0x7f, 0xc3,0x8a, 0xe6, 0x9e, 0x6b, 0x7c, 0xcd, 0x06, 0x4e, 0xe6, 0x89, 0xfc, 0x1a, 0x94, 0xa9, 0xf7, 0xd2, }, + { 0xec, 0x53, 0x0c, 0xe3, 0xcc, 0x5c, 0x9d, 0x1a, 0xf4, 0x63, 0xf2, 0x64, 0xd6, 0x85, 0xaf, 0xe2,0xb4, 0xdb, 0x4b, 0x58, 0x28, 0xd7, 0xe6, 0x1b, 0x74, 0x89, 0x30, 0xf3, 0xce, 0x62, 0x2a, 0x85, }, + { 0xdc, 0x23, 0xd1, 0x30, 0xc6, 0x11, 0x7f, 0xb5, 0x75, 0x12, 0x01, 0x45, 0x5e, 0x99, 0xf3, 0x6f,0x59, 0xab, 0xa1, 0xa6, 0xa2, 0x1c, 0xf2, 0xd0, 0xe7, 0x48, 0x1a, 0x97, 0x45, 0x1d, 0x66, 0x93, }, + { 0xd6, 0xce, 0x77, 0x08, 0xc1, 0x8d, 0xbf, 0x35, 0xd4, 0xf8, 0xaa, 0x72, 0x40, 0x92, 0x2d, 0xc6,0x82, 0x3f, 0x2e, 0x70, 0x58, 0xcb, 0xc1, 0x48, 0x4f, 0xca, 0xd1, 0x59, 0x9d, 0xb5, 0x01, 0x8c, }, false, "2 - R Changed" }, @@ -99,101 +99,101 @@ const ecdsa_p256_test_vector ecdsa_p256_test_vectors[] = { "P" }, { - { 0x73, 0xc5, 0xf6, 0xa6, 0x74, 0x56, 0xae, 0x48, 0x20, 0x9b, 0x5f, 0x85, 0xd1, 0xe7, 0xde, 0x77,0x58, 0xbf, 0x23, 0x53, 0x00, 0xc6, 0xae, 0x2b, 0xdc, 0xeb, 0x1d, 0xcb, 0x27, 0xa7, 0x73, 0x0f, 0xb6, 0x8c, 0x95, 0x0b, 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, 0xdb, 0x1e, 0x15,0x4b, 0x6f, 0x17, 0xbe, 0x70, 0xde, 0xb1, 0xb2, 0x10, 0x10, 0x7d, 0xec, 0xb1, 0xec, 0x2a, 0x5a, }, + { 0xe9, 0x3b, 0xfe, 0xbd, 0x2f, 0x14, 0xf3, 0xd8, 0x27, 0xca, 0x32, 0xb4, 0x64, 0xbe, 0x6e, 0x69,0x18, 0x7f, 0x5e, 0xdb, 0xd5, 0x2d, 0xef, 0x4f, 0x96, 0x59, 0x9c, 0x37, 0xd5, 0x8e, 0xee, 0x75, }, false, "4 - Q changed" }, { - { 0x16, 0x69, 0xbf, 0xb6, 0x57, 0xfd, 0xc6, 0x2c, 0x3d, 0xdd, 0x63, 0x26, 0x97, 0x87, 0xfc, 0x1c,0x96, 0x9f, 0x18, 0x50, 0xfb, 0x04, 0xc9, 0x33, 0xdd, 0xa0, 0x63, 0xef, 0x74, 0xa5, 0x6c, 0xe1, 0x3e, 0x3a, 0x64, 0x97, 0x00, 0x82, 0x0f, 0x00, 0x61, 0xef, 0xab, 0xf8, 0x49, 0xa8, 0x5d, 0x47, 0x43, 0x26, 0xc8, 0xa5, 0x41, 0xd9, 0x98, 0x30, 0xee, 0xa8, 0x13, 0x1e, 0xae, 0xa5, 0x84, 0xf2, 0x2d, 0x88, 0xc3, 0x53, 0x96, 0x5d, 0xab, 0xcd, 0xc4, 0xbf, 0x6b, 0x55, 0x94, 0x9f, 0xd5, 0x29, 0x50, 0x7d, 0xfb, 0x80, 0x3a, 0xb6, 0xb4, 0x80, 0xcd, 0x73, 0xca, 0x0b, 0xa0, 0x0c, 0xa1, 0x9c, 0x43, 0x88, 0x49, 0xe2, 0xce, 0xa2, 0x62, 0xa1, 0xc5, 0x7d, 0x8f, 0x81, 0xcd, 0x25, 0x7f, 0xb5, 0x8e, 0x19, 0xde, 0xc7, 0x90, 0x4d, 0xa9, 0x7d, 0x83, 0x86, 0xe8, 0x7b, 0x84, 0x94, 0x81, 0x69, }, - { 0x69, 0xb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7b, 0xfd, 0x36, 0x1d, 0xef,0x43, 0x71, 0x5f, 0xa3, 0x82, 0xb8, 0xc3, 0xed, 0xf4, 0xae, 0x15, 0xd6, 0xe5, 0x5e, 0x99, 0x79, }, false, "1 - Message changed" }, { - { 0x3f, 0xe6, 0x0d, 0xd9, 0xad, 0x6c, 0xac, 0xcf, 0x5a, 0x6f, 0x58, 0x3b, 0x3a, 0xe6, 0x59, 0x53,0x56, 0x34, 0x46, 0xc4, 0x51, 0x0b, 0x70, 0xda, 0x11, 0x5f, 0xfa, 0xa0, 0xba, 0x04, 0xc0, 0x76, 0x11, 0x5c, 0x70, 0x43, 0xab, 0x87, 0x33, 0x40, 0x3c, 0xd6, 0x9c, 0x7d, 0x14, 0xc2, 0x12, 0xc6, 0x55, 0xc0, 0x7b, 0x43, 0xa7, 0xc7, 0x1b, 0x9a, 0x4c, 0xff, 0xe2, 0x2c, 0x26, 0x84, 0x78, 0x8e, 0xc6, 0x87, 0x0d, 0xc2, 0x01, 0x3f, 0x26, 0x91, 0x72, 0xc8, 0x22, 0x25, 0x6f, 0x9e, 0x7c, 0xc6, 0x74, 0x79, 0x1b, 0xf2, 0xd8, 0x48, 0x6c, 0x0f, 0x56, 0x84, 0x28, 0x3e, 0x16, 0x49, 0x57, 0x6e, 0xfc, 0x98, 0x2e, 0xde, 0x17, 0xc7, 0xb7, 0x4b, 0x21, 0x47, 0x54, 0xd7, 0x04, 0x02, 0xfb, 0x4b, 0xb4, 0x5a, 0xd0, 0x86, 0xcf, 0x2c, 0xf7, 0x6b, 0x3d, 0x63, 0xf7, 0xfc, 0xe3, 0x9a, 0xc9, 0x70, }, - { 0xbf, 0x02, 0xcb, 0xcf, 0x6d, 0x8c, 0xc2, 0x6e, 0x91, 0x76, 0x6d, 0x8a, 0xf0, 0xb1, 0x64, 0xfc,0x59, 0x68, 0x53, 0x5e, 0x84, 0xc1, 0x58, 0xeb, 0x3b, 0xc4, 0xe2, 0xd7, 0x9c, 0x3c, 0xc6, 0x82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0x6c, 0x0f, 0x56, 0x84, 0x28, 0x3e, 0x16, 0x49, 0x57, 0x6e, 0xfc, 0x98, 0x2e, 0xde, 0x17, 0xc7, 0xb7, 0x4b, 0x21, 0x47, 0x54, 0xd7, 0x04, 0x02, 0xfb, 0x4b, 0xb4, 0x5a, 0xd0, 0x86, 0xcf, 0x2c, 0xf7, 0x6b, 0x3d, 0x63, 0xf7, 0xfc, 0xe3, 0x9a, 0xc9, 0x70, }, + { 0xbf, 0x02, 0xcb, 0xcf, 0x6d, 0x8c, 0xc2, 0x6e, 0x91, 0x76, 0x6d, 0x8a, 0xf0, 0xb1, 0x64, 0xfc,0x59, 0x68, 0x53, 0x5e, 0x84, 0xc1, 0x58, 0xeb, 0x3b, 0xc4, 0xe2, 0xd7, 0x9c, 0x3c, 0xc6, 0x82, }, + { 0x06, 0x9b, 0xa6, 0xcb, 0x06, 0xb4, 0x9d, 0x60, 0x81, 0x20, 0x66, 0xaf, 0xa1, 0x6e, 0xcf, 0x7b,0x51, 0x35, 0x2f, 0x2c, 0x03, 0xbd, 0x93, 0xec, 0x22, 0x08, 0x22, 0xb1, 0xf3, 0xdf, 0xba, 0x03, }, + { 0xf5, 0xac, 0xb0, 0x6c, 0x59, 0xc2, 0xb4, 0x92, 0x7f, 0xb8, 0x52, 0xfa, 0xa0, 0x7f, 0xaf, 0x4b,0x18, 0x52, 0xbb, 0xb5, 0xd0, 0x68, 0x40, 0x93, 0x5e, 0x84, 0x9c, 0x4d, 0x29, 0x3d, 0x1b, 0xad, }, + { 0x04, 0x9d, 0xab, 0x79, 0xc8, 0x9c, 0xc0, 0x2f, 0x14, 0x84, 0xc4, 0x37, 0xf5, 0x23, 0xe0, 0x80,0xa7, 0x5f, 0x13, 0x49, 0x17, 0xfd, 0xa7, 0x52, 0xf2, 0xd5, 0xca, 0x39, 0x7a, 0xdd, 0xfe, 0x5d, }, false, "3 - S changed" }, { - { 0x98, 0x3a, 0x71, 0xb9, 0x99, 0x4d, 0x95, 0xe8, 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76, 0x65, 0xe4, 0xc4, 0x30, 0x7f, 0xa0, 0xb0, 0xa3, 0x07, 0x5c, }, + { 0x22, 0x4a, 0x4d, 0x65, 0xb9, 0x58, 0xf6, 0xd6, 0xaf, 0xb2, 0x90, 0x48, 0x63, 0xef, 0xd2, 0xa7,0x34, 0xb3, 0x17, 0x98, 0x88, 0x48, 0x01, 0xfc, 0xab, 0x5a, 0x59, 0x0f, 0x4d, 0x6d, 0xa9, 0xde, }, + { 0x17, 0x8d, 0x51, 0xfd, 0xda, 0xda, 0x62, 0x80, 0x6f, 0x09, 0x7a, 0xa6, 0x15, 0xd3, 0x3b, 0x8f,0x24, 0x04, 0xe6, 0xb1, 0x47, 0x9f, 0x5f, 0xd4, 0x85, 0x9d, 0x59, 0x57, 0x34, 0xd6, 0xd2, 0xb9, }, + { 0x87, 0xb9, 0x3e, 0xe2, 0xfe, 0xcf, 0xda, 0x54, 0xde, 0xb8, 0xdf, 0xf8, 0xe4, 0x26, 0xf3, 0xc7,0x2c, 0x88, 0x64, 0x99, 0x1f, 0x8e, 0xc2, 0xb3, 0x20, 0x5b, 0xb3, 0xb4, 0x16, 0xde, 0x93, 0xd2, }, + { 0x40, 0x44, 0xa2, 0x4d, 0xf8, 0x5b, 0xe0, 0xcc, 0x76, 0xf2, 0x1a, 0x44, 0x30, 0xb7, 0x5b, 0x8e,0x77, 0xb9, 0x32, 0xa8, 0x7f, 0x51, 0xe4, 0xec, 0xcb, 0xc4, 0x5c, 0x26, 0x3e, 0xbf, 0x8f, 0x66, }, false, "2 - R changed" }, { - { 0x4a, 0x8c, 0x07, 0x1a, 0xc4, 0xfd, 0x0d, 0x52, 0xfa, 0xa4, 0x07, 0xb0, 0xfe, 0x5d, 0xab, 0x75,0x9f, 0x73, 0x94, 0xa5, 0x83, 0x21, 0x27, 0xf2, 0xa3, 0x49, 0x8f, 0x34, 0xaa, 0xc2, 0x87, 0x33, 0x9e, 0x04, 0x3b, 0x4f, 0xfa, 0x79, 0x52, 0x8f,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x89, 0x68, 0x0a, 0x9c, 0xb6, 0xd0, 0x55, 0xa0, 0x66, 0x22, 0x83, 0x69, }, + { 0xf8, 0x79, 0x01, 0x10, 0xb3, 0xc3, 0xb2, 0x81, 0xaa, 0x1e, 0xae, 0x03, 0x7d, 0x4f, 0x12, 0x34,0xaf, 0xf5, 0x87, 0xd9, 0x03, 0xd9, 0x3b, 0xa3, 0xaf, 0x22, 0x5c, 0x27, 0xdd, 0xc9, 0xcc, 0xac, }, + { 0x8a, 0xcd, 0x62, 0xe8, 0xc2, 0x62, 0xfa, 0x50, 0xdd, 0x98, 0x40, 0x48, 0x09, 0x69, 0xf4, 0xef,0x70, 0xf2, 0x18, 0xeb, 0xf8, 0xef, 0x95, 0x84, 0xf1, 0x99, 0x03, 0x11, 0x32, 0xc6, 0xb1, 0xce, }, + { 0xcf, 0xca, 0x7e, 0xd3, 0xd4, 0x34, 0x7f, 0xb2, 0xa2, 0x9e, 0x52, 0x6b, 0x43, 0xc3, 0x48, 0xae,0x1c, 0xe6, 0xc6, 0x0d, 0x44, 0xf3, 0x19, 0x1b, 0x6d, 0x8e, 0xa3, 0xa2, 0xd9, 0xc9, 0x21, 0x54, }, false, "3 - S changed" }, { - { 0x0a, 0x3a, 0x12, 0xc3, 0x08, 0x4c, 0x86, 0x5d, 0xaf, 0x1d, 0x30, 0x2c, 0x78, 0x21, 0x5d, 0x39,0xbf, 0xe0, 0xb8, 0xbf, 0x28, 0x27, 0x2b, 0x3c, 0x0b, 0x74, 0xbe, 0xb4, 0xb7, 0x40, 0x9d, 0xb0, 0x71, 0x82, 0x39, 0xde, 0x70, 0x07, 0x85, 0x58, 0x15, 0x14, 0x32, 0x1c, 0x64, 0x40, 0xa4, 0xbb, 0xae, 0xa4, 0xc7, 0x6f, 0xa4, 0x74, 0x01, 0xe1, 0x51, 0xe6, 0x8c, 0xb6, 0xc2, 0x90, 0x17, 0xf0, 0xbc, 0xe4, 0x63, 0x12, 0x90, 0xaf, 0x5e, 0xa5, 0x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x98, 0x08, 0x82, 0x5b, 0x3d, 0x31, 0xf0, 0x29, 0xe8, 0x29, 0x64, 0x05, }, + { 0xdf, 0xae, 0xa6, 0xf2, 0x97, 0xfa, 0x32, 0x0b, 0x70, 0x78, 0x66, 0x12, 0x5c, 0x2a, 0x7d, 0x5d,0x51, 0x5b, 0x51, 0xa5, 0x03, 0xbe, 0xe8, 0x17, 0xde, 0x9f, 0xaa, 0x34, 0x3c, 0xc4, 0x8e, 0xeb, }, + { 0x8f, 0x78, 0x0a, 0xd7, 0x13, 0xf9, 0xc3, 0xe5, 0xa4, 0xf7, 0xfa, 0x4c, 0x51, 0x98, 0x33, 0xdf,0xef, 0xc6, 0xa7, 0x43, 0x23, 0x89, 0xb1, 0xe4, 0xaf, 0x46, 0x39, 0x61, 0xf0, 0x97, 0x64, 0xf2, }, false, "1 - Message changed" }, { - { 0x78, 0x5d, 0x07, 0xa3, 0xc5, 0x4f, 0x63, 0xdc, 0xa1, 0x1f, 0x5d, 0x1a, 0x5f, 0x49, 0x6e, 0xe2,0xc2, 0xf9, 0x28, 0x8e, 0x55, 0x00, 0x7e, 0x66, 0x6c, 0x78, 0xb0, 0x07, 0xd9, 0x5c, 0xc2, 0x85, 0x81, 0xdc, 0xe5, 0x1f, 0x49, 0x0b, 0x30, 0xfa, 0x73, 0xdc, 0x9e, 0x2d, 0x45, 0xd0, 0x75, 0xd7, 0xe3, 0xa9, 0x5f, 0xb8, 0xa9, 0xe1, 0x46, 0x5a, 0xd1, 0x91, 0x90, 0x41, 0x24, 0x16, 0x0b, 0x7c, 0x60, 0xfa, 0x72, 0x0e, 0xf4, 0xef, 0x1c, 0x5d, 0x29, 0x98, 0xf4, 0x05, 0x70, 0xae, 0x2a, 0x87, 0x0e, 0xf3, 0xe8, 0x94, 0xc2, 0xbc, 0x61, 0x7d, 0x8a, 0x1d, 0xc8, 0x5c, 0x3c, 0x55, 0x77, 0x49, 0x28, 0xc3, 0x87, 0x89, 0xb4, 0xe6, 0x61, 0x34,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e, 0xb7, 0xcb, 0xfd, 0xc1, 0xef, 0xf4, 0x39, 0x9a, 0x8a, 0x90, 0x0a, 0xe7, }, false, "1 - Message changed" }, { - { 0x60, 0xcd, 0x64, 0xb2, 0xcd, 0x2b, 0xe6, 0xc3, 0x38, 0x59, 0xb9, 0x48, 0x75, 0x12, 0x03, 0x61,0xa2, 0x40, 0x85, 0xf3, 0x76, 0x5c, 0xb8, 0xb2, 0xbf, 0x11, 0xe0, 0x26, 0xfa, 0x9d, 0x88, 0x55, 0xdb, 0xe4, 0x35, 0xac, 0xf7, 0x88, 0x2e, 0x84, 0xf3, 0xc7, 0x85, 0x7f, 0x96, 0xe2, 0xba, 0xab, 0x4d, 0x9a, 0xfe, 0x45, 0x88, 0xe4, 0xa8, 0x2e, 0x17, 0xa7, 0x88, 0x27, 0xbf, 0xdb, 0x5d, 0xdb, 0xd1, 0xc2, 0x11, 0xfb, 0xc2, 0xe6, 0xd8, 0x84, 0xcd, 0xdd, 0x7c, 0xb9, 0xd9, 0x0d, 0x5b, 0xf4, 0xa7, 0x31, 0x1b, 0x83, 0xf3, 0x52, 0x50, 0x80, 0x33, 0x81, 0x2c, 0x77, 0x6a, 0x0e, 0x00, 0xc0, 0x03, 0xc7, 0xe0, 0xd6, 0x28, 0xe5, 0x07, 0x36, 0xc7, 0x51, 0x2d, 0xf0, 0xac, 0xfa, 0x9f, 0x23, 0x20, 0xbd, 0x10, 0x22, 0x29, 0xf4, 0x64, 0x95, 0xae, 0x6d, 0x08, 0x57, 0xcc, 0x45, 0x2a, 0x84, }, - { 0x2d, 0x98, 0xea, 0x01, 0xf7, 0x54, 0xd3, 0x4b, 0xbc, 0x30, 0x03, 0xdf, 0x50, 0x50, 0x20, 0x0a,0xbf, 0x44, 0x5e, 0xc7, 0x28, 0x55, 0x6d, 0x7e, 0xd7, 0xd5, 0xc5, 0x4c, 0x55, 0x55, 0x2b, 0x6d, }, - { 0x9b, 0x52, 0x67, 0x27, 0x42, 0xd6, 0x37, 0xa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0x00, 0xc0, 0x03, 0xc7, 0xe0, 0xd6, 0x28, 0xe5, 0x07, 0x36, 0xc7, 0x51, 0x2d, 0xf0, 0xac, 0xfa, 0x9f, 0x23, 0x20, 0xbd, 0x10, 0x22, 0x29, 0xf4, 0x64, 0x95, 0xae, 0x6d, 0x08, 0x57, 0xcc, 0x45, 0x2a, 0x84, }, + { 0x2d, 0x98, 0xea, 0x01, 0xf7, 0x54, 0xd3, 0x4b, 0xbc, 0x30, 0x03, 0xdf, 0x50, 0x50, 0x20, 0x0a,0xbf, 0x44, 0x5e, 0xc7, 0x28, 0x55, 0x6d, 0x7e, 0xd7, 0xd5, 0xc5, 0x4c, 0x55, 0x55, 0x2b, 0x6d, }, + { 0x9b, 0x52, 0x67, 0x27, 0x42, 0xd6, 0x37, 0xa3, 0x2a, 0xdd, 0x05, 0x6d, 0xfd, 0x6d, 0x87, 0x92,0xf2, 0xa3, 0x3c, 0x2e, 0x69, 0xda, 0xfa, 0xbe, 0xa0, 0x9b, 0x96, 0x0b, 0xc6, 0x1e, 0x23, 0x0a, }, + { 0x06, 0x10, 0x8e, 0x52, 0x5f, 0x84, 0x5d, 0x01, 0x55, 0xbf, 0x60, 0x19, 0x32, 0x22, 0xb3, 0x21,0x9c, 0x98, 0xe3, 0xd4, 0x94, 0x24, 0xc2, 0xfb, 0x2a, 0x09, 0x87, 0xf8, 0x25, 0xc1, 0x79, 0x59, }, + { 0x62, 0xb5, 0xcd, 0xd5, 0x91, 0xe5, 0xb5, 0x07, 0xe5, 0x60, 0x16, 0x7b, 0xa8, 0xf6, 0xf7, 0xcd,0xa7, 0x46, 0x73, 0xeb, 0x31, 0x56, 0x80, 0xcb, 0x89, 0xcc, 0xbc, 0x4e, 0xec, 0x47, 0x7d, 0xce, }, true, "P" }