diff --git a/CMakeLists.txt b/CMakeLists.txt index 40375958a..4ae930d10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 2.6.4) project (cryptoauthlib C) # Set the current release version -set(VERSION "3.3.2") +set(VERSION "3.3.3") set(VERSION_MAJOR 3) set(VERSION_MINOR 3) -set(VERSION_PATCH 2) +set(VERSION_PATCH 3) # Build Options option(BUILD_TESTS "Create Test Application with library" OFF) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..af664c19b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,22 @@ +Contribution Guidelines +========================== + +While this is an open source project there are a few considerations that make +it somewhat unique in how it is managed. The first issue is that the development +workflow is a hybrid between internal development and CI/CD systems and external +develop and associated CI/CD systems. + +* This project contains a mixture of licenses depending on the section. The vast + majority is under a Microchip proprietary license that is restrictive. +* Contributors must be aware of the specific license they are working under and + must be aware that by submitting the patch that they agree to the terms of the + license covering the target file. +* Sources contained in the third_party path are covered by true open source + licenses and as such are not bound by Microchip's license restrictions. +* Third party contributions for HALs must be licensed under MIT, BSD (3 clause), + or Apache 2.0 license and are placed in third_party/hal/ +* Pull requests (PR) must attest to reviewing of these rules, that licensing terms + have been reviewed, the submitter has approval to submit the changes under the + target license terms. + + diff --git a/README.md b/README.md index 5cb80a1e4..a57f1c2a3 100644 --- a/README.md +++ b/README.md @@ -36,15 +36,6 @@ configuration is well tested, then you can commit it to a CryptoAuth Xplained Pro Extension, for example. Keep in mind that once you lock a device, it will not be changeable. -Licensing ---------------------------- - -The CryptoAuthLib license can be found in the accompaning [license.txt](https://github.com/MicrochipTech/cryptoauthlib/blob/main/license.txt) -file. - -Cryptoauthlib also includes optional third party software subject to their own licensing terms. If you are using one of these optional components please -verify the terms of those licenses as well in the third_party/ directories. - Examples ----------- @@ -113,19 +104,9 @@ Host Device Support --------------- CryptoAuthLib will run on a variety of platforms from small micro-controllers -to desktop host systems. The current list of hardware abstraction layer -support includes: - -Rich OS Hosts: - - Linux Kit Protocol over HID USB - - Linux I2C - - Linux SPI - - Windows Kit Protocol over HID USB +to desktop host systems. See [hal readme](lib/hal/readme.md) -Microcontrollers: - - Microchip AVR, SAM, & PIC families. See [hal readme](lib/hal/readme.md) - -If you have specific microcontrollers or Rich OS platforms you need support +If you have specific microcontrollers or platforms you need support for, please contact us through the Microchip portal with your request. CryptoAuthLib Architecture @@ -165,47 +146,7 @@ Tests There is a set of integration tests found in the test directory which will at least partially demonstrate the use of the objects. Some tests may depend upon a certain device being configured in a certain way and may not work for all -devices or specific configurations of the device. - -The test/cmd-processor.c file contains a main() function for running the tests. -It implements a command-line interface. Typing help will bring up the list of -commands available. - -One first selects a device type, with one of the following commands: - - 204 (ATSHA204A) - - 108 (ATECC108A) - - 508 (ATECC508A) - - 608 (ATECC608A/B) - -From there the following unit test sweets are available: - - unit (test command builder functions) - - basic (test basic API functions) - - cio (test certification i/o functions) - - cd (test certificate data functions) - - util (test utility functions) - - crypto (test software crypto functions) - -Tests available depend on the lock level of the device. The unit tests -won't lock the config or data zones automatically to allow retesting at desired -lock levels. Therefore, some commands will need to be repeated after locking -to exercise all available tests. - -Starting from a blank device, the sequence of commands to exercise all unit -tests is: -```text -unit -basic -lockcfg -unit -basic -lockdata -unit -basic -cio -cd -util -crypto -``` +devices or specific configurations of the device. See [test readme](test/README.md) Using CryptoAuthLib (Microchip CryptoAuth Library) =========================================== diff --git a/app/kit_host/ascii_kit_host.c b/app/kit_host/ascii_kit_host.c index a8ca2fda9..b30513da0 100644 --- a/app/kit_host/ascii_kit_host.c +++ b/app/kit_host/ascii_kit_host.c @@ -342,8 +342,8 @@ static ATCA_STATUS kit_host_ca_select(ascii_kit_host_context_t* ctx, int argc, c #if ATCA_CA_SUPPORT static kit_host_map_entry_t kit_host_ca_physical_map[] = { - { "select", kit_host_ca_select }, - { NULL, NULL } + { "select", kit_host_ca_select }, + { NULL, NULL } }; static ATCA_STATUS kit_host_ca_physical(ascii_kit_host_context_t* ctx, int argc, char* argv[], uint8_t* response, size_t* rlen) @@ -353,12 +353,12 @@ static ATCA_STATUS kit_host_ca_physical(ascii_kit_host_context_t* ctx, int argc, /* Cryptoauth Device commands */ static kit_host_map_entry_t kit_host_ca_map[] = { - { "wake", kit_host_ca_wake }, - { "idle", kit_host_ca_idle }, - { "sleep", kit_host_ca_sleep }, - { "talk", kit_host_ca_talk }, - { "physical", kit_host_ca_physical }, - { NULL, NULL } + { "wake", kit_host_ca_wake }, + { "idle", kit_host_ca_idle }, + { "sleep", kit_host_ca_sleep }, + { "talk", kit_host_ca_talk }, + { "physical", kit_host_ca_physical }, + { NULL, NULL } }; static ATCA_STATUS kit_host_process_ca(ascii_kit_host_context_t* ctx, int argc, char* argv[], uint8_t* response, size_t* rlen) @@ -520,8 +520,8 @@ static ATCA_STATUS kit_host_ta_receive(ascii_kit_host_context_t* ctx, int argc, } static kit_host_map_entry_t kit_host_ta_physical_map[] = { - { "select", kit_host_ca_select }, /* Selection logic is the same */ - { NULL, NULL } + { "select", kit_host_ca_select }, /* Selection logic is the same */ + { NULL, NULL } }; static ATCA_STATUS kit_host_ta_physical(ascii_kit_host_context_t* ctx, int argc, char* argv[], uint8_t* response, size_t* rlen) @@ -530,14 +530,14 @@ static ATCA_STATUS kit_host_ta_physical(ascii_kit_host_context_t* ctx, int argc, } static kit_host_map_entry_t kit_host_ta_map[] = { - { "wake", kit_host_ta_wake }, - { "idle", kit_host_ta_idle }, - { "sleep", kit_host_ta_sleep }, - { "talk", kit_host_ta_talk }, - { "send", kit_host_ta_send }, - { "receive", kit_host_ta_receive }, - { "physical", kit_host_ta_physical }, - { NULL, NULL } + { "wake", kit_host_ta_wake }, + { "idle", kit_host_ta_idle }, + { "sleep", kit_host_ta_sleep }, + { "talk", kit_host_ta_talk }, + { "send", kit_host_ta_send }, + { "receive", kit_host_ta_receive }, + { "physical", kit_host_ta_physical }, + { NULL, NULL } }; ATCA_STATUS kit_host_process_ta(ascii_kit_host_context_t* ctx, int argc, char* argv[], uint8_t* response, size_t* rlen) @@ -578,10 +578,10 @@ static ATCA_STATUS kit_host_board_get_device(ascii_kit_host_context_t* ctx, int static kit_host_map_entry_t kit_host_board_map[] = { - { "version", kit_host_board_get_version }, - { "firmware", kit_host_board_get_firmware }, - { "device", kit_host_board_get_device }, - { NULL, NULL } + { "version", kit_host_board_get_version }, + { "firmware", kit_host_board_get_firmware }, + { "device", kit_host_board_get_device }, + { NULL, NULL } }; static ATCA_STATUS kit_host_process_board(ascii_kit_host_context_t* ctx, int argc, char* argv[], uint8_t* response, size_t* rlen) @@ -591,15 +591,15 @@ static ATCA_STATUS kit_host_process_board(ascii_kit_host_context_t* ctx, int arg static const kit_host_map_entry_t kit_host_target_map[] = { - { "board", kit_host_process_board }, + { "board", kit_host_process_board }, #if ATCA_CA_SUPPORT - { "ecc", kit_host_process_ca }, - { "sha", kit_host_process_ca }, + { "ecc", kit_host_process_ca }, + { "sha", kit_host_process_ca }, #endif #if ATCA_TA_SUPPORT - { "ta", kit_host_process_ta }, + { "ta", kit_host_process_ta }, #endif - { NULL, NULL } + { NULL, NULL } }; static ATCA_STATUS kit_host_process_target(ascii_kit_host_context_t* ctx, int argc, char* argv[], uint8_t* response, size_t* rlen) diff --git a/app/pkcs11/example_cert_chain.c b/app/pkcs11/example_cert_chain.c index 2cb4f64bf..ff7a798d3 100644 --- a/app/pkcs11/example_cert_chain.c +++ b/app/pkcs11/example_cert_chain.c @@ -1,4 +1,3 @@ - #include "atcacert/atcacert_def.h" #include "example_cert_chain.h" @@ -56,35 +55,35 @@ const atcacert_cert_element_t g_cert_elements_1_signer[] = { }; const uint8_t g_cert_template_1_signer[] = { - 0x30, 0x82, 0x01, 0xc8, 0x30, 0x82, 0x01, 0x6e, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x57, - 0x06, 0x2e, 0xf0, 0x05, 0xea, 0x8a, 0x70, 0x44, 0xff, 0x1b, 0x90, 0x00, 0x21, 0x78, 0xd6, 0x30, - 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x30, 0x31, 0x14, 0x30, - 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, - 0x49, 0x6e, 0x63, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x45, 0x78, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, - 0x0d, 0x31, 0x37, 0x30, 0x36, 0x30, 0x37, 0x31, 0x37, 0x35, 0x36, 0x31, 0x32, 0x5a, 0x17, 0x0d, - 0x32, 0x37, 0x30, 0x36, 0x30, 0x37, 0x31, 0x37, 0x35, 0x36, 0x31, 0x32, 0x5a, 0x30, 0x34, 0x31, - 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, - 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x20, 0x46, - 0x46, 0x46, 0x46, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, - 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xb1, 0xf5, - 0x9c, 0xbe, 0x22, 0x11, 0x7f, 0x28, 0x2f, 0x7f, 0x2e, 0xcb, 0xa2, 0x8c, 0x30, 0x3b, 0xae, 0x59, - 0x45, 0xb9, 0x5c, 0x0e, 0xba, 0xaa, 0x9b, 0x81, 0x73, 0x52, 0x63, 0x41, 0xbf, 0x37, 0x3c, 0x2e, - 0xdd, 0xcd, 0xea, 0x0e, 0x7c, 0x9d, 0x90, 0xea, 0x25, 0x9c, 0x64, 0xeb, 0xc6, 0x54, 0x47, 0x32, - 0x81, 0x63, 0xbf, 0x42, 0x5f, 0xdd, 0x5a, 0x3f, 0xd5, 0x71, 0x81, 0x9b, 0x77, 0x44, 0xa3, 0x66, - 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, - 0x01, 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, - 0x04, 0x04, 0x03, 0x02, 0x01, 0x86, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, - 0x14, 0x81, 0x1d, 0xc6, 0x7c, 0x0f, 0x18, 0x2b, 0x65, 0x96, 0xeb, 0x22, 0x73, 0xdb, 0xf3, 0x23, - 0x63, 0x6d, 0x79, 0x0f, 0xc8, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, - 0x80, 0x14, 0xdb, 0x2a, 0x0d, 0x06, 0x05, 0xc7, 0x98, 0xbc, 0xda, 0xc0, 0x34, 0x67, 0x66, 0xf4, - 0xe2, 0xb0, 0x61, 0xa3, 0xd2, 0xc8, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, - 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x49, 0xfe, 0xdf, 0xc9, 0x94, 0xe3, 0x07, - 0xdb, 0x08, 0xb3, 0x99, 0x9e, 0x04, 0xe4, 0x78, 0xe5, 0xf8, 0xb9, 0x09, 0xa9, 0xf0, 0x41, 0x66, - 0xc6, 0x69, 0x1b, 0x87, 0x30, 0x86, 0x10, 0xaf, 0x64, 0x02, 0x21, 0x00, 0xc8, 0xd6, 0x86, 0x61, - 0x94, 0x95, 0xdb, 0x45, 0xb3, 0x40, 0x8e, 0xac, 0x14, 0x9a, 0x19, 0xb6, 0x8c, 0x5c, 0x79, 0x9d, - 0x06, 0xcb, 0x52, 0x08, 0xa0, 0x1f, 0x49, 0x8b, 0x22, 0x4e, 0x52, 0x71 + 0x30, 0x82, 0x01, 0xc8, 0x30, 0x82, 0x01, 0x6e, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x57, + 0x06, 0x2e, 0xf0, 0x05, 0xea, 0x8a, 0x70, 0x44, 0xff, 0x1b, 0x90, 0x00, 0x21, 0x78, 0xd6, 0x30, + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x30, 0x31, 0x14, 0x30, + 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, + 0x49, 0x6e, 0x63, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x45, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, + 0x0d, 0x31, 0x37, 0x30, 0x36, 0x30, 0x37, 0x31, 0x37, 0x35, 0x36, 0x31, 0x32, 0x5a, 0x17, 0x0d, + 0x32, 0x37, 0x30, 0x36, 0x30, 0x37, 0x31, 0x37, 0x35, 0x36, 0x31, 0x32, 0x5a, 0x30, 0x34, 0x31, + 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, + 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x20, 0x46, + 0x46, 0x46, 0x46, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, + 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xb1, 0xf5, + 0x9c, 0xbe, 0x22, 0x11, 0x7f, 0x28, 0x2f, 0x7f, 0x2e, 0xcb, 0xa2, 0x8c, 0x30, 0x3b, 0xae, 0x59, + 0x45, 0xb9, 0x5c, 0x0e, 0xba, 0xaa, 0x9b, 0x81, 0x73, 0x52, 0x63, 0x41, 0xbf, 0x37, 0x3c, 0x2e, + 0xdd, 0xcd, 0xea, 0x0e, 0x7c, 0x9d, 0x90, 0xea, 0x25, 0x9c, 0x64, 0xeb, 0xc6, 0x54, 0x47, 0x32, + 0x81, 0x63, 0xbf, 0x42, 0x5f, 0xdd, 0x5a, 0x3f, 0xd5, 0x71, 0x81, 0x9b, 0x77, 0x44, 0xa3, 0x66, + 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, + 0x01, 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, + 0x04, 0x04, 0x03, 0x02, 0x01, 0x86, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, + 0x14, 0x81, 0x1d, 0xc6, 0x7c, 0x0f, 0x18, 0x2b, 0x65, 0x96, 0xeb, 0x22, 0x73, 0xdb, 0xf3, 0x23, + 0x63, 0x6d, 0x79, 0x0f, 0xc8, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0xdb, 0x2a, 0x0d, 0x06, 0x05, 0xc7, 0x98, 0xbc, 0xda, 0xc0, 0x34, 0x67, 0x66, 0xf4, + 0xe2, 0xb0, 0x61, 0xa3, 0xd2, 0xc8, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, + 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x49, 0xfe, 0xdf, 0xc9, 0x94, 0xe3, 0x07, + 0xdb, 0x08, 0xb3, 0x99, 0x9e, 0x04, 0xe4, 0x78, 0xe5, 0xf8, 0xb9, 0x09, 0xa9, 0xf0, 0x41, 0x66, + 0xc6, 0x69, 0x1b, 0x87, 0x30, 0x86, 0x10, 0xaf, 0x64, 0x02, 0x21, 0x00, 0xc8, 0xd6, 0x86, 0x61, + 0x94, 0x95, 0xdb, 0x45, 0xb3, 0x40, 0x8e, 0xac, 0x14, 0x9a, 0x19, 0xb6, 0x8c, 0x5c, 0x79, 0x9d, + 0x06, 0xcb, 0x52, 0x08, 0xa0, 0x1f, 0x49, 0x8b, 0x22, 0x4e, 0x52, 0x71 }; const atcacert_def_t g_cert_def_1_signer = { @@ -163,32 +162,32 @@ const atcacert_def_t g_cert_def_1_signer = { }; const uint8_t g_cert_template_2_device[] = { - 0x30, 0x82, 0x01, 0xa6, 0x30, 0x82, 0x01, 0x4b, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x41, - 0xa6, 0x8b, 0xe4, 0x36, 0xdd, 0xc3, 0xd8, 0x39, 0xfa, 0xbd, 0xd7, 0x27, 0xd9, 0x74, 0xe7, 0x30, - 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x34, 0x31, 0x14, 0x30, - 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, - 0x49, 0x6e, 0x63, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, 0x45, 0x78, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x20, 0x46, 0x46, 0x46, - 0x46, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x37, 0x31, 0x30, 0x32, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x5a, 0x18, 0x0f, 0x33, 0x30, 0x30, 0x30, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, - 0x35, 0x39, 0x5a, 0x30, 0x2f, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, - 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x17, 0x30, 0x15, 0x06, - 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x44, 0x65, - 0x76, 0x69, 0x63, 0x65, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, - 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x96, - 0x27, 0xf1, 0x3e, 0x80, 0xac, 0xf9, 0xd4, 0x12, 0xce, 0x3b, 0x0d, 0x68, 0xf7, 0x4e, 0xb2, 0xc6, - 0x07, 0x35, 0x00, 0xb7, 0x78, 0x5b, 0xac, 0xe6, 0x50, 0x30, 0x54, 0x77, 0x7f, 0xc8, 0x62, 0x21, - 0xce, 0xf2, 0x5a, 0x9a, 0x9e, 0x86, 0x40, 0xc2, 0x29, 0xd6, 0x4a, 0x32, 0x1e, 0xb9, 0x4a, 0x1b, - 0x1c, 0x94, 0xf5, 0x39, 0x88, 0xae, 0xfe, 0x49, 0xcc, 0xfd, 0xbf, 0x8a, 0x0d, 0x34, 0xb8, 0xa3, - 0x42, 0x30, 0x40, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x2d, 0xda, - 0x6c, 0x36, 0xd5, 0xa5, 0x5a, 0xce, 0x97, 0x10, 0x3d, 0xbb, 0xaf, 0x9c, 0x66, 0x2a, 0xcd, 0x3e, - 0xe6, 0xcf, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xc6, - 0x70, 0xe0, 0x5e, 0x8a, 0x45, 0x0d, 0xb8, 0x2c, 0x00, 0x2a, 0x40, 0x06, 0x39, 0x4c, 0x19, 0x58, - 0x04, 0x35, 0x76, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, - 0x49, 0x00, 0x30, 0x46, 0x02, 0x21, 0x00, 0xe1, 0xfc, 0x00, 0x23, 0xc1, 0x3d, 0x01, 0x3f, 0x22, - 0x31, 0x0b, 0xf0, 0xb8, 0xf4, 0xf4, 0x22, 0xfc, 0x95, 0x96, 0x33, 0x9c, 0xb9, 0x62, 0xb1, 0xfc, - 0x8a, 0x2d, 0xa8, 0x5c, 0xee, 0x67, 0x72, 0x02, 0x21, 0x00, 0xa1, 0x0d, 0x47, 0xe4, 0xfd, 0x0d, - 0x15, 0xd8, 0xde, 0xa1, 0xb5, 0x96, 0x28, 0x4e, 0x7a, 0x0b, 0xbe, 0xcc, 0xec, 0xe8, 0x8e, 0xcc, + 0x30, 0x82, 0x01, 0xa6, 0x30, 0x82, 0x01, 0x4b, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x41, + 0xa6, 0x8b, 0xe4, 0x36, 0xdd, 0xc3, 0xd8, 0x39, 0xfa, 0xbd, 0xd7, 0x27, 0xd9, 0x74, 0xe7, 0x30, + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x34, 0x31, 0x14, 0x30, + 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, + 0x49, 0x6e, 0x63, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, 0x45, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x20, 0x46, 0x46, 0x46, + 0x46, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x37, 0x31, 0x30, 0x32, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x5a, 0x18, 0x0f, 0x33, 0x30, 0x30, 0x30, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, + 0x35, 0x39, 0x5a, 0x30, 0x2f, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, + 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x17, 0x30, 0x15, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x44, 0x65, + 0x76, 0x69, 0x63, 0x65, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x96, + 0x27, 0xf1, 0x3e, 0x80, 0xac, 0xf9, 0xd4, 0x12, 0xce, 0x3b, 0x0d, 0x68, 0xf7, 0x4e, 0xb2, 0xc6, + 0x07, 0x35, 0x00, 0xb7, 0x78, 0x5b, 0xac, 0xe6, 0x50, 0x30, 0x54, 0x77, 0x7f, 0xc8, 0x62, 0x21, + 0xce, 0xf2, 0x5a, 0x9a, 0x9e, 0x86, 0x40, 0xc2, 0x29, 0xd6, 0x4a, 0x32, 0x1e, 0xb9, 0x4a, 0x1b, + 0x1c, 0x94, 0xf5, 0x39, 0x88, 0xae, 0xfe, 0x49, 0xcc, 0xfd, 0xbf, 0x8a, 0x0d, 0x34, 0xb8, 0xa3, + 0x42, 0x30, 0x40, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x2d, 0xda, + 0x6c, 0x36, 0xd5, 0xa5, 0x5a, 0xce, 0x97, 0x10, 0x3d, 0xbb, 0xaf, 0x9c, 0x66, 0x2a, 0xcd, 0x3e, + 0xe6, 0xcf, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xc6, + 0x70, 0xe0, 0x5e, 0x8a, 0x45, 0x0d, 0xb8, 0x2c, 0x00, 0x2a, 0x40, 0x06, 0x39, 0x4c, 0x19, 0x58, + 0x04, 0x35, 0x76, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, + 0x49, 0x00, 0x30, 0x46, 0x02, 0x21, 0x00, 0xe1, 0xfc, 0x00, 0x23, 0xc1, 0x3d, 0x01, 0x3f, 0x22, + 0x31, 0x0b, 0xf0, 0xb8, 0xf4, 0xf4, 0x22, 0xfc, 0x95, 0x96, 0x33, 0x9c, 0xb9, 0x62, 0xb1, 0xfc, + 0x8a, 0x2d, 0xa8, 0x5c, 0xee, 0x67, 0x72, 0x02, 0x21, 0x00, 0xa1, 0x0d, 0x47, 0xe4, 0xfd, 0x0d, + 0x15, 0xd8, 0xde, 0xa1, 0xb5, 0x96, 0x28, 0x4e, 0x7a, 0x0b, 0xbe, 0xcc, 0xec, 0xe8, 0x8e, 0xcc, 0x7a, 0x31, 0xb3, 0x00, 0x8b, 0xc0, 0x2e, 0x4f, 0x99, 0xc5 }; @@ -266,4 +265,3 @@ const atcacert_def_t g_cert_def_2_device = { .cert_template_size = sizeof(g_cert_template_2_device), .ca_cert_def = &g_cert_def_1_signer, }; - diff --git a/app/tng/tng_atca.c b/app/tng/tng_atca.c index 8fd753733..dde2e4319 100644 --- a/app/tng/tng_atca.c +++ b/app/tng/tng_atca.c @@ -45,22 +45,22 @@ typedef struct static tng_cert_map_element g_tng_cert_def_map[] = { #ifdef ATCA_TNG_LEGACY_SUPPORT - { "wdNxAjae", &g_tngtls_cert_def_2_device }, - { "Rsuy5YJh", &g_tngtls_cert_def_2_device }, - { "BxZvm6q2", &g_tnglora_cert_def_2_device }, + { "wdNxAjae", &g_tngtls_cert_def_2_device }, + { "Rsuy5YJh", &g_tngtls_cert_def_2_device }, + { "BxZvm6q2", &g_tnglora_cert_def_2_device }, #endif #ifdef ATCA_TFLEX_SUPPORT - { "MKMwyhP1", &g_tflxtls_cert_def_4_device }, + { "MKMwyhP1", &g_tflxtls_cert_def_4_device }, #endif #ifdef ATCA_TNGTLS_SUPPORT - { "KQp2ZkD8", &g_tngtls_cert_def_3_device }, - { "x6tjuZMy", &g_tngtls_cert_def_3_device }, + { "KQp2ZkD8", &g_tngtls_cert_def_3_device }, + { "x6tjuZMy", &g_tngtls_cert_def_3_device }, #endif #ifdef ATCA_TNGLORA_SUPPORT - { "jsMu7iYO", &g_tnglora_cert_def_4_device }, - { "09qJNxI3", &g_tnglora_cert_def_4_device }, + { "jsMu7iYO", &g_tnglora_cert_def_4_device }, + { "09qJNxI3", &g_tnglora_cert_def_4_device }, #endif - { "", NULL } + { "", NULL } }; static const size_t g_tng_cert_def_cnt = sizeof(g_tng_cert_def_map) / sizeof(tng_cert_map_element) - 1; diff --git a/cryptoauthlib-manual.pdf b/cryptoauthlib-manual.pdf index 366d69012..9931714da 100644 Binary files a/cryptoauthlib-manual.pdf and b/cryptoauthlib-manual.pdf differ diff --git a/harmony/config/cryptoauthlib.py b/harmony/config/cryptoauthlib.py index 3a7b3b665..ef683ab31 100644 --- a/harmony/config/cryptoauthlib.py +++ b/harmony/config/cryptoauthlib.py @@ -32,7 +32,7 @@ calPlibTracker = {} calHalTracker = {} -_HAL_FILES = ["atca_hal.c", "atca_hal.h", "atca_start_config.h", "atca_start_iface.h"] +_HAL_FILES = ["atca_hal.c", "atca_hal.h"] _CORE_PATHS = ['crypto/**/*', 'crypto/*', 'jwt/*', '*'] _CA_PATHS = ['atcacert/*', 'calib/*', 'host/*'] _TA_PATHS = ['talib/*'] @@ -76,6 +76,12 @@ def updateHalTracker(id, inc): symbol = Database.getComponentByID('cryptoauthlib').getSymbolByID('CAL_FILE_SRC_HAL_' + id) symbol.setEnabled(cnt > 0) + try: + symbol = Database.getComponentByID('cryptoauthlib').getSymbolByID('CAL_FILE_SRC_HAL_{}_HEADER'.format(id)) + symbol.setEnabled(cnt > 0) + except: + pass + calHalList = Database.getComponentByID('cryptoauthlib').getSymbolByID('CAL_HAL_LIST_ENTRIES') if cnt == 0: @@ -120,7 +126,7 @@ def updateDevCfgTracker(id, inc): def extendDevCfgList(new_list, cnt): calDevCfgList = Database.getComponentByID('cryptoauthlib').getSymbolByID('CAL_DEV_CFG_LIST_ENTRIES') - + for value in new_list: values = list(calDevCfgList.getValues()) if value not in values: @@ -200,7 +206,7 @@ def onAttachmentConnected(source, target): global _ta_dev_cnt srcComponent = source["component"] srcConnectionID = source["id"] - + targetComponentID = target["component"].getID().upper() # Check if a dependency got satisfied @@ -218,7 +224,7 @@ def onAttachmentConnected(source, target): if 'SHA206' in targetComponentID: updateFileEnable(srcComponent, _SHA206_PATHS, True) updateFileEnable(srcComponent, _CA_PATHS, True) - + if srcConnectionID == 'FreeRTOS': calEnableRtos = srcComponent.getSymbolByID('CAL_ENABLE_RTOS') calEnableRtos.setValue(True) @@ -229,7 +235,7 @@ def onAttachmentConnected(source, target): if targetComponentID == 'LIB_WOLFCRYPT': calEnableWolfCrypto = srcComponent.getSymbolByID('CAL_ENABLE_WOLFCRYPTO') calEnableWolfCrypto.setValue(True) - + WolfCrypto = srcComponent.getSymbolByID('CAL_FILE_SRC_WOLFSSL_WRAPPER') WolfCrypto.setEnabled(True) @@ -261,8 +267,8 @@ def onAttachmentDisconnected(source, target): if 0 == _ca_dev_cnt: if 'SHA206' in targetComponentID: updateFileEnable(srcComponent, _SHA206_PATHS, False) - updateFileEnable(srcComponent, _CA_PATHS, False) - + updateFileEnable(srcComponent, _CA_PATHS, False) + if srcConnectionID == 'FreeRTOS': calEnableRtos = srcComponent.getSymbolByID('CAL_ENABLE_RTOS') @@ -274,7 +280,7 @@ def onAttachmentDisconnected(source, target): if targetComponentID == 'LIB_WOLFCRYPT': WolfCrypto = srcComponent.getSymbolByID('CAL_ENABLE_WOLFCRYPTO') WolfCrypto.setValue(False) - + WolfCrypto = srcComponent.getSymbolByID('CAL_FILE_SRC_WOLFSSL_WRAPPER') WolfCrypto.setEnabled(False) @@ -309,7 +315,7 @@ def instantiateComponent(calComponent): for search_path in _CORE_PATHS: AddFilesDir(calComponent, 'lib', search_path, 'library/cryptoauthlib', 'config/{}/library/cryptoauthlib'.format(configName)) - + # Add device library files (default disabled) for search_path in _CA_PATHS: AddFilesDir(calComponent, 'lib', search_path, 'library/cryptoauthlib', @@ -371,7 +377,7 @@ def instantiateComponent(calComponent): calEnableWolfCrypto = calComponent.createBooleanSymbol('CAL_ENABLE_WOLFCRYPTO', None) calEnableWolfCrypto.setValue(False) calEnableWolfCrypto.setVisible(False) - + calLibWolfSSLSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_WOLFSSL_WRAPPER", None) calLibWolfSSLSrcFile.setSourcePath("lib/wolfssl/atca_wolfssl_interface.c") calLibWolfSSLSrcFile.setOutputName("atca_wolfssl_interface.c") @@ -399,7 +405,7 @@ def instantiateComponent(calComponent): calLibUartHalSrcFile.setType('SOURCE') calLibUartHalSrcFile.setEnabled(False) calLibUartHalSrcFile.setDependencies(CALSecFileUpdate, ["CAL_NON_SECURE"]) - + calLibSwiUartHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_SWI_UART", None) calLibSwiUartHalSrcFile.setSourcePath("lib/hal/hal_swi_uart.c") calLibSwiUartHalSrcFile.setOutputName("hal_swi_uart.c") @@ -409,24 +415,24 @@ def instantiateComponent(calComponent): calLibSwiUartHalSrcFile.setEnabled(False) calLibSwiUartHalSrcFile.setDependencies(CALSecFileUpdate, ["CAL_NON_SECURE"]) - calLibSwiBBHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_BB", None) - calLibSwiBBHalSrcFile.setSourcePath("lib/hal/hal_gpio_harmony.c") - calLibSwiBBHalSrcFile.setOutputName("hal_gpio_harmony.c") - calLibSwiBBHalSrcFile.setDestPath("library/cryptoauthlib/hal") - calLibSwiBBHalSrcFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/") - calLibSwiBBHalSrcFile.setType('SOURCE') - calLibSwiBBHalSrcFile.setEnabled(False) - calLibSwiBBHalSrcFile.setDependencies(CALSecFileUpdate, ["CAL_NON_SECURE"]) - calLibSwiBBHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_SWI_BB", None) - calLibSwiBBHalSrcFile.setSourcePath("lib/hal/hal_swi_bitbang_harmony.c") - calLibSwiBBHalSrcFile.setOutputName("hal_swi_bitbang_harmony.c") + calLibSwiBBHalSrcFile.setSourcePath("lib/hal/hal_swi_gpio.c") + calLibSwiBBHalSrcFile.setOutputName("hal_swi_gpio.c") calLibSwiBBHalSrcFile.setDestPath("library/cryptoauthlib/hal") calLibSwiBBHalSrcFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/") calLibSwiBBHalSrcFile.setType('SOURCE') calLibSwiBBHalSrcFile.setEnabled(False) calLibSwiBBHalSrcFile.setDependencies(CALSecFileUpdate, ["CAL_NON_SECURE"]) - + + calLibSwiBBHalHdrFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_SWI_BB_HEADER", None) + calLibSwiBBHalHdrFile.setSourcePath("lib/hal/hal_swi_gpio.h") + calLibSwiBBHalHdrFile.setOutputName("hal_swi_gpio.h") + calLibSwiBBHalHdrFile.setDestPath("library/cryptoauthlib/hal") + calLibSwiBBHalHdrFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/") + calLibSwiBBHalHdrFile.setType('HEADER') + calLibSwiBBHalHdrFile.setEnabled(False) + calLibSwiBBHalHdrFile.setDependencies(CALSecFileUpdate, ["CAL_NON_SECURE"]) + calLibSpiHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_SPI", None) calLibSpiHalSrcFile.setSourcePath("lib/hal/hal_spi_harmony.c") calLibSpiHalSrcFile.setOutputName("hal_spi_harmony.c") @@ -478,7 +484,18 @@ def instantiateComponent(calComponent): calLibCoreM0PlusSrcFile.setMarkup(True) calLibCoreM0PlusSrcFile.setDependencies(CALSecFileUpdate, ["CAL_NON_SECURE"]) - # Configuration header file + # cryptoauthlib configuration structures that are create per device instance + calLibCoreM0PlusSrcFile = calComponent.createFileSymbol("CAL_HAL_HARMONY_GPIO", None) + calLibCoreM0PlusSrcFile.setSourcePath("harmony/templates/hal_gpio_harmony.c.ftl") + calLibCoreM0PlusSrcFile.setOutputName("hal_gpio_harmony.c") + calLibCoreM0PlusSrcFile.setDestPath("library/cryptoauthlib/hal") + calLibCoreM0PlusSrcFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/") + calLibCoreM0PlusSrcFile.setType("SOURCE") + calLibCoreM0PlusSrcFile.setOverwrite(True) + calLibCoreM0PlusSrcFile.setMarkup(True) + calLibCoreM0PlusSrcFile.setDependencies(CALSecFileUpdate, ["CAL_NON_SECURE"]) + + # Configuration header file calLibConfigFile = calComponent.createFileSymbol("CAL_LIB_CONFIG_DATA", None) calLibConfigFile.setSourcePath("harmony/templates/atca_config.h.ftl") calLibConfigFile.setOutputName("atca_config.h") diff --git a/harmony/templates/atca_config.h.ftl b/harmony/templates/atca_config.h.ftl index 1d4eecda2..6a4d60d56 100644 --- a/harmony/templates/atca_config.h.ftl +++ b/harmony/templates/atca_config.h.ftl @@ -104,8 +104,9 @@ <#assign pliblist = CAL_PLIB_LIST?word_list> <#if pliblist?size != 0> <#list pliblist as plib_id> -<#assign plib_info = plib_id?split("_", 1)> -<#if plib_info[1] == "i2c"> +<#assign plib_info = plib_id?split("_")> + +<#if plib_info[plib_info?size-1] == "i2c"> <#if is_atca_plib_i2c_exists == "False"> <#assign size_var = "size_t"> <#if plib_id?contains("sercom")> @@ -145,7 +146,7 @@ typedef struct atca_plib_i2c_api -<#if plib_info[1] == "spi"> +<#if plib_info[plib_info?size-1] == "spi"> <#if is_atca_plib_spi_exists == "False"> typedef bool (* atca_spi_plib_read)( void * , size_t ); typedef bool (* atca_spi_plib_write)( void *, size_t ); @@ -163,7 +164,7 @@ typedef struct atca_plib_spi_api -<#if plib_info[1] == "swi" && plib_info[2] == "uart" || plib_info[1] == "uart"> +<#if plib_info[plib_info?size-1] == "uart"> <#if is_atca_plib_uart_exists == "False"> <#if plib_id?contains("flexcom")> #define PLIB_SWI_ERROR FLEXCOM_USART_ERROR @@ -215,7 +216,8 @@ typedef struct atca_plib_uart_api /** SWI Transmit delay */ #define SWI_TX_DELAY ((uint32_t)90) -<#elseif plib_info[2] == "bb"> + +<#elseif plib_info[plib_info?size-1] == "bb"> <#if is_atca_plib_bb_exists == "False"> typedef bool (* atca_swi_plib_read)( uint8_t ); typedef void (* atca_swi_plib_write)( uint8_t, bool ); @@ -228,7 +230,7 @@ typedef struct atca_plib_swi_api atca_swi_plib_write write; atca_swi_set_pin_output set_pin_output_dir; atca_swi_set_pin_input set_pin_input_dir; -}atca_plib_swi_bb_api_t; +}atca_plib_bb_api_t; <#assign is_atca_plib_bb_exists = "True"> /** @@ -256,7 +258,6 @@ typedef struct atca_plib_swi_api //! should be 93 us (Setting little less value as there would be other process before these steps) #define RX_TX_DELAY atca_delay_us(65) - @@ -272,8 +273,8 @@ typedef struct atca_plib_swi_api <#list pliblist as plib_id> -<#assign plib_info = plib_id?split("_", 1)> -<#assign plib_drv = plib_id?substring(plib_id?index_of("_") + 1)> +<#assign plib_info = plib_id?split("_")> +<#assign plib_drv = plib_info[plib_info?size-1]> extern atca_plib_${plib_drv!"i2c"}_api_t ${plib_info[0]}_plib_${plib_drv!"i2c"}_api; diff --git a/harmony/templates/device_instance.c.ftl b/harmony/templates/device_instance.c.ftl index 44a176434..2501a6a01 100644 --- a/harmony/templates/device_instance.c.ftl +++ b/harmony/templates/device_instance.c.ftl @@ -9,10 +9,13 @@ #include "cryptoauthlib.h" <#assign PLIB_NAME = core.PORT_API_PREFIX?string> -ATCAIfaceCfg ${NAME?lower_case}_${INDEX?string}_init_data = { + <#if INTERFACE == "ATCA_SWI_BB_IFACE"> -<#assign INTERFACE = "ATCA_SWI_IFACE"> +<#assign INTERFACE = "ATCA_SWI_GPIO_IFACE"> +static const uint32_t ${NAME?lower_case}_${INDEX?string}_pin_id = ${PLIB_NAME}_PIN_${SWIBB_CRYPTO_PIN?upper_case}; + +ATCAIfaceCfg ${NAME?lower_case}_${INDEX?string}_init_data = { .iface_type = ${INTERFACE}, .devtype = ${NAME?upper_case}, <#if INTERFACE == "ATCA_I2C_IFACE"> @@ -33,16 +36,18 @@ ATCAIfaceCfg ${NAME?lower_case}_${INDEX?string}_init_data = { <#else> .atcaspi.baud = ${.vars["${HAL_INTERFACE?lower_case}"].SPI_BAUD_RATE}, +<#elseif INTERFACE == "ATCA_SWI_GPIO_IFACE"> +<#assign plib_type = "bb"> + .atcaswi.bus = ${PLIB_NAME}_PIN_${SWIBB_CRYPTO_PIN?upper_case}, <#elseif INTERFACE == "ATCA_SWI_IFACE"> -<#if HAL_INTERFACE?contains("GPIO")> -<#assign plib_type = "swi_bb"> - .atcaswi.bus = ${PLIB_NAME}_PIN_${SWIBB_CRYPTO_PIN?upper_case}, -<#else> -<#assign plib_type = "swi_uart"> +<#assign plib_type = "uart"> .atcaswi.bus = 0, - .wake_delay = ${WAKEUP_DELAY}, .rx_retries = ${RECEIVE_RETRY}, +<#if plib_type != "bb"> .cfg_data = &${HAL_INTERFACE?lower_case}_plib_${plib_type}_api +<#else> + .cfg_data = (void*)&${NAME?lower_case}_${INDEX?string}_pin_id + }; diff --git a/harmony/templates/hal_gpio_harmony.c.ftl b/harmony/templates/hal_gpio_harmony.c.ftl new file mode 100644 index 000000000..be2bd12ae --- /dev/null +++ b/harmony/templates/hal_gpio_harmony.c.ftl @@ -0,0 +1,135 @@ +/** + * + * \file + * \brief ATCA Hardware abstraction layer for GPIO + * + * \copyright (c) 2015-2021 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_hal.h" + +<#assign PLIB_NAME = core.PORT_API_PREFIX?string> + +/** + * \brief Initialize a gpio interface using given config. + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_gpio_init(ATCAIface iface, ATCAIfaceCfg *cfg) +{ + return ATCA_SUCCESS; +} + +/** + * \brief Post Init for gpio hal + * + * \return ATCA_SUCCESS + */ +ATCA_STATUS hal_gpio_post_init(ATCAIface iface) +{ + return ATCA_SUCCESS; +} + +/** + * \brief Set the state of the pin + * + * \return ATCA_SUCCESS + */ +ATCA_STATUS hal_gpio_send( + ATCAIface iface, /**< Interface context */ + uint8_t word_address, /**< Unused parameter */ + uint8_t* pin_state, /**< Pin state to output */ + int unused_param /**< Unused parameter */ +) +{ + (void)word_address; + (void)unused_param; + uint32_t pin_id = *(uint32_t*)atgetifacecfg(iface)->cfg_data; + + ${PLIB_NAME}_PinWrite(pin_id, *pin_state); + + return ATCA_SUCCESS; +} + +/** + * \brief Read the state of the pin + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_gpio_receive( + ATCAIface iface, /**< Interface context */ + uint8_t word_address, /**< Unused parameter */ + uint8_t* pin_state, /**< Pin state to output */ + uint16_t* unused_param /**< Unused parameter */ +) +{ + (void)word_address; + (void)unused_param; + uint32_t pin_id = *(uint32_t*)atgetifacecfg(iface)->cfg_data; + + *pin_state = ${PLIB_NAME}_PinRead(pin_id); + + return ATCA_SUCCESS; +} + +ATCA_STATUS hal_gpio_control(ATCAIface iface, uint8_t option, void* param, size_t paramlen) +{ + (void)paramlen; + + if (iface && iface->mIfaceCFG) + { + switch (option) + { + case ATCA_HAL_CONTROL_DIRECTION: + { + uint8_t pin_dir = *(uint8_t*)param; + uint32_t pin_id = *(uint32_t*)atgetifacecfg(iface)->cfg_data; + + if (pin_dir == 0) { + ${PLIB_NAME}_PinInputEnable(pin_id); + } + else + { + ${PLIB_NAME}_PinOutputEnable(pin_id); + } + } + return ATCA_SUCCESS; + default: + return ATCA_UNIMPLEMENTED; + } + } + return ATCA_BAD_PARAM; +} + +/** + * \brief Release and clean up the HAL + * + * \param[in] hal_data opaque pointer to hal data structure - known only + * to the HAL implementation + * + * \return ATCA_SUCCESS + */ +ATCA_STATUS hal_gpio_release(void *hal_data) +{ + return ATCA_SUCCESS; +} \ No newline at end of file diff --git a/harmony/templates/hal_harmony_init.c.ftl b/harmony/templates/hal_harmony_init.c.ftl index 2f59eb396..7f59baccd 100644 --- a/harmony/templates/hal_harmony_init.c.ftl +++ b/harmony/templates/hal_harmony_init.c.ftl @@ -37,7 +37,7 @@ <#if pliblist?size != 0> <#list pliblist as plib_id> <#assign plib_info = plib_id?split("_")> -<#if plib_info?size == 1 || plib_info[1] == "i2c"> +<#if plib_info[plib_info?size-1] == "i2c"> atca_plib_i2c_api_t ${plib_info[0]}_plib_i2c_api = { .read = ${.vars["${plib_info[0]}"].I2C_PLIB_API_PREFIX}_Read, .write = ${.vars["${plib_info[0]}"].I2C_PLIB_API_PREFIX}_Write, @@ -45,7 +45,7 @@ atca_plib_i2c_api_t ${plib_info[0]}_plib_i2c_api = { .error_get = ${.vars["${plib_info[0]}"].I2C_PLIB_API_PREFIX}_ErrorGet, .transfer_setup = ${.vars["${plib_info[0]}"].I2C_PLIB_API_PREFIX}_TransferSetup }; -<#elseif plib_info[1] == "spi"> +<#elseif plib_info[plib_info?size-1] == "spi"> static void ${plib_info[0]}_select_pin(uint32_t pin, bool value) { ${PLIB_NAME}_PinWrite(pin, value); @@ -57,7 +57,7 @@ atca_plib_spi_api_t ${plib_info[0]}_plib_spi_api = { .is_busy = ${.vars["${plib_info[0]}"].SPI_PLIB_API_PREFIX}_IsBusy, .select = &${plib_info[0]}_select_pin }; -<#elseif plib_info[1] == "swi" && plib_info[2] == "uart" || plib_info[1] == "uart"> +<#elseif plib_info[plib_info?size-1] == "uart"> atca_plib_uart_api_t ${plib_info[0]}_plib_uart_api = { .read = ${.vars["${plib_info[0]}"].USART_PLIB_API_PREFIX}_Read, .write = ${.vars["${plib_info[0]}"].USART_PLIB_API_PREFIX}_Write, @@ -66,33 +66,6 @@ atca_plib_uart_api_t ${plib_info[0]}_plib_uart_api = { .readcount_get = ${.vars["${plib_info[0]}"].USART_PLIB_API_PREFIX}_ReadCountGet, .readcallback_reg = ${.vars["${plib_info[0]}"].USART_PLIB_API_PREFIX}_ReadCallbackRegister }; -<#elseif plib_info[1] == "gpio"> -static void ${plib_info[0]}_SetupPinDirection(uint32_t pin, uint8_t pin_dir) -{ - if (pin_dir == 0) { - ${PLIB_NAME}_PinInputEnable(pin); - } - else - { - ${PLIB_NAME}_PinOutputEnable(pin); - } -} - -static void ${plib_info[0]}_Write(uint32_t pin, bool value) -{ - ${PLIB_NAME}_PinWrite(pin, value); -} - -static bool ${plib_info[0]}_Read(uint32_t pin) -{ - return ${PLIB_NAME}_PinRead(pin); -} - -atca_plib_gpio_api_t ${plib_info[0]}_plib_gpio_api = { - .read = ${.vars["${plib_info[0]}"].GPIO_PLIB_API_PREFIX}_Read, - .write = ${.vars["${plib_info[0]}"].GPIO_PLIB_API_PREFIX}_Write, - .pin_setup = ${.vars["${plib_info[0]}"].GPIO_PLIB_API_PREFIX}_SetupPinDirection -}; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index bdc7891f8..749ee727a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -10,7 +10,8 @@ option(ATCA_HAL_KIT_BRIDGE "General purpose kit protocol (Packet and Stream)") option(ATCA_HAL_I2C "Include the I2C Hal Driver - Linux & MCU only") option(ATCA_HAL_SPI "Include the SPI HAL Driver - Linux & MCU only") option(ATCA_HAL_CUSTOM "Include support for Custom/Plug-in Hal Driver") -option(ATCA_HAL_KIT_UART "Include th UART HAL Driver") +option(ATCA_HAL_KIT_UART "Include the UART HAL Driver") +option(ATCA_HAL_SWI_UART "Include the SWI using UART Driver") # Library Options option(ATCA_PRINTF "Enable Debug print statements in library") @@ -40,6 +41,10 @@ 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) +# RTOS Selection +if (TARGET zephyr_interface) +SET(ATCA_ZEPHYR_SUPPORT ON CACHE INTERNAL "Include zephyr hal drivers") +endif() # TA100 Dependent Configuration options cmake_dependent_option(ATCA_TA100_AES_AUTH_SUPPORT "Include Encrypted (GCM) and CMAC Auth session support" ON "ATCA_TA100_SUPPORT" OFF) @@ -164,9 +169,17 @@ set(WOLFSSL_LIB_SRC ../third_party/wolfssl/wolfcrypt/src/aes.c add_library(wolfssl STATIC ${WOLFSSL_LIB_SRC}) -target_compile_definitions(wolfssl PRIVATE -DWC_NO_HARDEN -DHAVE_ECC -DHAVE_ALL_CURVES -DWOLFCRYPT_ONLY -DWOLFSSL_PEM_TO_DER -DWOLFSSL_VALIDATE_ECC_IMPORT -DWOLFSSL_AES_DIRECT -DHAVE_AESGCM -DWOLFSSL_CMAC -DNO_OLD_TLS -DNO_MD5) +target_compile_definitions(wolfssl PRIVATE -DWOLFSSL_USER_SETTINGS) +configure_file(../third_party/wolfssl_settings.h.in user_settings.h @ONLY) +set(WOLFSSL_USER_SETTINGS TRUE) + +if(NOT WIN32) +target_compile_options(wolfssl PRIVATE -fPIC) +endif() + include_directories(wolfssl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/wolfssl) + ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/wolfssl + ${CMAKE_CURRENT_BINARY_DIR}) file(GLOB WOLFSSL_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "wolfssl/*.c") @@ -210,14 +223,13 @@ set(CRYPTOAUTH_SRC ${LIB_SRC} set(HAL_INC hal/atca_hal.h) -if(ATCA_HAL_KIT_HID OR ATCA_HAL_KIT_CDC) +if(ATCA_HAL_KIT_HID) set(NEED_USB true) endif() if(WIN32) set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} hal/hal_windows.c) set(HID_SRC ../third_party/hidapi/windows/hid.c) -set(CDC_SRC hal/hal_win_kit_cdc.c) elseif(APPLE) set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} hal/hal_linux.c) set(HID_SRC ../third_party/hidapi/mac/hid.c) @@ -228,6 +240,12 @@ set(SPI_SRC hal/hal_linux_spi_userspace.c) set(LINUX TRUE) endif() +if(ATCA_ZEPHYR_SUPPORT) +set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} ../third_party/hal/zephyr/hal_zephyr.c) +SET(TWI_SRC ../third_party/hal/zephyr/hal_zephyr_i2c.c) +SET(SPI_SRC ../third_party/hal/zephyr/hal_zephyr_spi.c) +endif() + if(LINUX AND NEED_USB) find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h PATH_SUFFIXES "include" "libusb" "libusb-1.0") find_path(LIBUDEV_INCLUDE_DIR NAMES libudev.h PATH_SUFFIXES "include") @@ -244,10 +262,10 @@ endif() if(LIBUDEV_GOOD) set(USE_UDEV TRUE) -elseif(LIBUSB_GOOD AND NOT ATCA_HAL_KIT_CDC) +elseif(LIBUSB_GOOD) set(USE_LIBUSB TRUE) else() -message(FATAL_ERROR, "Missing Build Dependencies for USB - install libusb-1.0-0-dev or libudev-dev") +message(FATAL_ERROR "Missing Build Dependencies for USB - install libusb-1.0-0-dev or libudev-dev") endif() endif(LINUX AND NEED_USB) @@ -255,7 +273,6 @@ endif(LINUX AND NEED_USB) if(USE_UDEV) set(USB_INCLUDE_DIR ${LIBUDEV_INCLUDE_DIR}) set(HID_SRC ../third_party/hidapi/linux/hid.c) -set(CDC_SRC hal/hal_linux_kit_cdc.c) endif(USE_UDEV) if(USE_LIBUSB) @@ -271,17 +288,13 @@ if(ATCA_HAL_KIT_HID) set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} ${HID_SRC} hal/hal_all_platforms_kit_hidapi.c) endif(ATCA_HAL_KIT_HID) -if(ATCA_HAL_KIT_UART) +if(ATCA_HAL_KIT_UART OR ATCA_HAL_SWI_UART) if(WIN32) set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} hal/hal_windows_kit_uart.c) -elseif(LINUX) +elseif(LINUX OR APPLE) set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} hal/hal_linux_uart_userspace.c) endif() -endif(ATCA_HAL_KIT_UART) - -if(ATCA_HAL_KIT_CDC) -set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} ${CDC_SRC}) -endif(ATCA_HAL_KIT_CDC) +endif() if(ATCA_HAL_I2C) set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} ${TWI_SRC}) @@ -291,6 +304,10 @@ if(ATCA_HAL_SPI) set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} ${SPI_SRC}) endif(ATCA_HAL_SPI) +if(ATCA_HAL_SWI_UART) +set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} hal/hal_swi_uart.c) +endif(ATCA_HAL_SWI_UART) + if(ATCA_HAL_KIT_BRIDGE) set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} hal/hal_kit_bridge.c) endif(ATCA_HAL_KIT_BRIDGE) @@ -401,4 +418,4 @@ install(FILES ${JWT_INC} DESTINATION ${DEFAULT_INC_PATH}/jwt COMPONENT Developme install(FILES ${PKCS11_INC} DESTINATION ${DEFAULT_INC_PATH}/pkcs11 COMPONENT Development) install(FILES ${TNG_INC} DESTINATION ${DEFAULT_INC_PATH}/app/tng COMPONENT Development) install(FILES ${SHA206_API_INC} DESTINATION ${DEFAULT_INC_PATH}/app/api_206a COMPONENT Development) -endif(DEFAULT_INC_PATH) +endif(DEFAULT_INC_PATH) \ No newline at end of file diff --git a/lib/atca_basic.c b/lib/atca_basic.c index 685e1d93c..0cbee9100 100644 --- a/lib/atca_basic.c +++ b/lib/atca_basic.c @@ -1618,7 +1618,16 @@ ATCA_STATUS atcab_lock_config_zone_crc(uint16_t summary_crc) if (atcab_is_ca_device(dev_type)) { #if ATCA_CA_SUPPORT - status = calib_lock_config_zone_crc(_gDevice, summary_crc); + if (ECC204 == dev_type) + { +#if defined(ATCA_ECC204_SUPPORT) + status = ATCA_UNIMPLEMENTED; +#endif + } + else + { + status = calib_lock_config_zone_crc(_gDevice, summary_crc); + } #endif } else if (atcab_is_ta_device(dev_type)) @@ -1649,7 +1658,16 @@ ATCA_STATUS atcab_lock_data_zone(void) if (atcab_is_ca_device(dev_type)) { #if ATCA_CA_SUPPORT - status = calib_lock_data_zone(_gDevice); + if (ECC204 == dev_type) + { +#if defined(ATCA_ECC204_SUPPORT) + status = calib_ecc204_lock_data_zone(_gDevice); +#endif + } + else + { + status = calib_lock_data_zone(_gDevice); + } #endif } else if (atcab_is_ta_device(dev_type)) @@ -1683,7 +1701,16 @@ ATCA_STATUS atcab_lock_data_zone_crc(uint16_t summary_crc) if (atcab_is_ca_device(dev_type)) { #if ATCA_CA_SUPPORT - status = calib_lock_data_zone_crc(_gDevice, summary_crc); + if (ECC204 == dev_type) + { +#if defined(ATCA_ECC204_SUPPORT) + status = ATCA_UNIMPLEMENTED; +#endif + } + else + { + status = calib_lock_data_zone_crc(_gDevice, summary_crc); + } #endif } else if (atcab_is_ta_device(dev_type)) @@ -2193,7 +2220,7 @@ ATCA_STATUS atcab_is_config_locked(bool* is_locked) if (ECC204 == dev_type) { #if defined(ATCA_ECC204_SUPPORT) - status = calib_ecc204_is_locked(_gDevice, ATCA_ECC204_ZONE_CONFIG, is_locked); + status = calib_ecc204_is_locked(_gDevice, ATCA_ZONE_CONFIG, is_locked); #endif } else @@ -2228,13 +2255,13 @@ ATCA_STATUS atcab_is_data_locked(bool* is_locked) if (atcab_is_ca_device(dev_type)) { #if ATCA_CA_SUPPORT -#if defined(ATCA_ECC204_SUPPORT) if (ECC204 == dev_type) { - status = calib_ecc204_is_locked(_gDevice, ATCA_ECC204_ZONE_DATA, is_locked); +#if defined(ATCA_ECC204_SUPPORT) + status = calib_ecc204_is_locked(_gDevice, ATCA_ZONE_DATA, is_locked); +#endif } else -#endif { status = calib_is_locked(_gDevice, LOCK_ZONE_DATA, is_locked); } diff --git a/lib/atca_cfgs.c b/lib/atca_cfgs.c index 2e5f158ed..f04f1be7c 100644 --- a/lib/atca_cfgs.c +++ b/lib/atca_cfgs.c @@ -73,9 +73,9 @@ ATCAIfaceCfg cfg_ateccx08a_swi_default = { }; #endif -#if defined(ATCA_ECC_SUPPORT) && defined(ATCA_HAL_KIT_CDC) +#if defined(ATCA_ECC_SUPPORT) && defined(ATCA_HAL_KIT_UART) /** \brief default configuration for Kit protocol over the device's async interface */ -ATCAIfaceCfg cfg_ateccx08a_kitcdc_default = { +ATCAIfaceCfg cfg_ateccx08_kituart_default = { .iface_type = ATCA_UART_IFACE, .devtype = ATECC608, { @@ -141,9 +141,9 @@ ATCAIfaceCfg cfg_atsha20xa_swi_default = { }; #endif -#if defined(ATCA_SHA_SUPPORT) && defined(ATCA_HAL_KIT_CDC) +#if defined(ATCA_SHA_SUPPORT) && defined(ATCA_HAL_KIT_UART) /** \brief default configuration for Kit protocol over the device's async interface */ -ATCAIfaceCfg cfg_atsha20xa_kitcdc_default = { +ATCAIfaceCfg cfg_atsha20xa_kituart_default = { .iface_type = ATCA_UART_IFACE, .devtype = ATSHA204A, { diff --git a/lib/atca_compiler.h b/lib/atca_compiler.h index bf7e5c61f..c746ccb33 100644 --- a/lib/atca_compiler.h +++ b/lib/atca_compiler.h @@ -65,7 +65,9 @@ #elif defined(__XC8) || defined(__XC16) /* Microchip XC8 and XC16 Compilers ------------------------- */ +#ifndef SIZE_MAX #define SIZE_MAX 65535 +#endif #define ATCA_UINT16_HOST_TO_LE(x) (x) #define ATCA_UINT16_LE_TO_HOST(x) (x) diff --git a/lib/atca_config.h.in b/lib/atca_config.h.in index 720794cb8..49e14451b 100644 --- a/lib/atca_config.h.in +++ b/lib/atca_config.h.in @@ -9,7 +9,7 @@ #cmakedefine ATCA_HAL_SPI #cmakedefine ATCA_HAL_KIT_BRIDGE #cmakedefine ATCA_HAL_CUSTOM -#cmakedefine ATCA_HAL_SWI +#cmakedefine ATCA_HAL_SWI_UART #cmakedefine ATCA_HAL_1WIRE @@ -67,6 +67,13 @@ #cmakedefine ATCA_OPENSSL #cmakedefine ATCA_WOLFSSL +#ifdef ATCA_WOLFSSL +#cmakedefine WOLFSSL_USER_SETTINGS +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#endif +#endif + /** Additional Runtime Configuration */ #cmakedefine ATCA_LIBRARY_CONF "@ATCA_LIBRARY_CONF@" diff --git a/lib/atca_helpers.c b/lib/atca_helpers.c index ec68f1c5b..6086f341d 100644 --- a/lib/atca_helpers.c +++ b/lib/atca_helpers.c @@ -88,7 +88,7 @@ static void hex_to_lowercase(char *buffer, size_t length) { for (index = 0; index < length; index++) { - buffer[index] = tolower(buffer[index]); + buffer[index] = (uint8_t)(tolower(buffer[index])); } } } @@ -102,7 +102,7 @@ static void hex_to_uppercase(char *buffer, size_t length) { for (index = 0; index < length; index++) { - buffer[index] = toupper(buffer[index]); + buffer[index] = (uint8_t)(toupper(buffer[index])); } } } @@ -277,7 +277,7 @@ ATCA_STATUS atcab_hex2bin_(const char* hex, size_t hex_size, uint8_t* bin, size_ if (is_upper_nibble) { // Upper nibble - bin[bin_index] = hex_digit_to_num(hex[hex_index]) << 4; + bin[bin_index] = (uint8_t)(hex_digit_to_num(hex[hex_index]) << 4); } else { @@ -612,17 +612,17 @@ static ATCA_STATUS atcab_base64decode_block(const uint8_t id[4], uint8_t* data, } // Decode into output buffer - data[(*data_size)++] = ((id[0] << 2) | (id[1] >> 4)); + data[(*data_size)++] = (uint8_t)((id[0] << 2) | (id[1] >> 4)); if (id[2] == B64_IS_EQUAL) { break; } - data[(*data_size)++] = ((id[1] << 4) | (id[2] >> 2)); + data[(*data_size)++] = (uint8_t)((id[1] << 4) | (id[2] >> 2)); if (id[3] == B64_IS_EQUAL) { break; } - data[(*data_size)++] = ((id[2] << 6) | id[3]); + data[(*data_size)++] = (uint8_t)((id[2] << 6) | id[3]); } while (false); @@ -776,12 +776,12 @@ ATCA_STATUS atcab_base64encode_( id = (data[data_idx] & 0xFC) >> 2; encoded[b64_idx++] = base64Char(id, rules); - id = (data[data_idx] & 0x03) << 4; + id = (uint8_t)((data[data_idx] & 0x03) << 4); if (data_idx + 1 < data_size) { id |= (data[data_idx + 1] & 0xF0) >> 4; encoded[b64_idx++] = base64Char(id, rules); - id = (data[data_idx + 1] & 0x0F) << 2; + id = (uint8_t)((data[data_idx + 1] & 0x0F) << 2); if (data_idx + 2 < data_size) { id |= (data[data_idx + 2] & 0xC0) >> 6; @@ -874,7 +874,7 @@ int atcab_memset_s(void* dest, size_t destsz, int ch, size_t count) volatile unsigned char* p = dest; while (destsz-- && count--) { - *p++ = ch; + *p++ = (uint8_t)ch; } return 0; diff --git a/lib/atca_iface.c b/lib/atca_iface.c index b7010e38d..e9af196d7 100644 --- a/lib/atca_iface.c +++ b/lib/atca_iface.c @@ -345,6 +345,23 @@ bool atca_iface_is_kit(ATCAIface ca_iface) return ret; } +/** \brief Check if the given interface is configured as a SWI + * \return true if the interface is considered a kit + */ +bool atca_iface_is_swi(ATCAIface ca_iface) +{ + bool ret = false; + + if (ca_iface && ca_iface->mIfaceCFG) + { + if (ATCA_SWI_IFACE == ca_iface->mIfaceCFG->iface_type || ATCA_SWI_GPIO_IFACE == ca_iface->mIfaceCFG->iface_type) + { + ret = true; + } + } + return ret; +} + /** \brief Retrive the number of retries for a configured interface */ int atca_iface_get_retries(ATCAIface ca_iface) { diff --git a/lib/atca_iface.h b/lib/atca_iface.h index 58d35f185..1cb80eab6 100644 --- a/lib/atca_iface.h +++ b/lib/atca_iface.h @@ -72,8 +72,7 @@ typedef enum ATCA_KIT_I2C_IFACE, ATCA_KIT_SWI_IFACE, ATCA_KIT_SPI_IFACE, - ATCA_KIT_UNKNOWN_IFACE -} ATCAKitType; + ATCA_KIT_UNKNOWN_IFACE } ATCAKitType; /* ATCAIfaceCfg is the configuration object for a device @@ -204,6 +203,7 @@ void* atgetifacehaldat(ATCAIface ca_iface); /* Utilities */ bool atca_iface_is_kit(ATCAIface ca_iface); +bool atca_iface_is_swi(ATCAIface ca_iface); int atca_iface_get_retries(ATCAIface ca_iface); uint16_t atca_iface_get_wake_delay(ATCAIface ca_iface); diff --git a/lib/atca_version.h b/lib/atca_version.h index 535a1fc96..0a8d8bc4f 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 "20210623" +#define ATCA_LIBRARY_VERSION_DATE "20211006" #define ATCA_LIBRARY_VERSION_MAJOR 3 #define ATCA_LIBRARY_VERSION_MINOR 3 -#define ATCA_LIBRARY_VERSION_BUILD 2 +#define ATCA_LIBRARY_VERSION_BUILD 3 #endif /* _ATCA_VERSION_H */ diff --git a/lib/atcacert/atcacert_date.c b/lib/atcacert/atcacert_date.c index aca8b4c5c..66ae26ee8 100644 --- a/lib/atcacert/atcacert_date.c +++ b/lib/atcacert/atcacert_date.c @@ -163,7 +163,7 @@ int atcacert_date_get_max_date(atcacert_date_format_t format, atcacert_tm_utc_t* /** * \brief Convert an unsigned integer to a zero padded string with no terminating null. */ -static uint8_t* uint_to_str(uint32_t num, int width, uint8_t* str) +static uint8_t* uint_to_str(int num, int width, uint8_t* str) { uint8_t* ret = str + width; int i; @@ -1033,13 +1033,13 @@ int atcacert_date_enc_compcert(const atcacert_tm_utc_t* issue_date, memset(enc_dates, 0, 3); - enc_dates[0] = (enc_dates[0] & 0x07) | (((issue_date->tm_year + 1900 - 2000) & 0x1F) << 3); - enc_dates[0] = (enc_dates[0] & 0xF8) | (((issue_date->tm_mon + 1) & 0x0F) >> 1); - enc_dates[1] = (enc_dates[1] & 0x7F) | (((issue_date->tm_mon + 1) & 0x0F) << 7); - enc_dates[1] = (enc_dates[1] & 0x83) | ((issue_date->tm_mday & 0x1F) << 2); - enc_dates[1] = (enc_dates[1] & 0xFC) | ((issue_date->tm_hour & 0x1F) >> 3); - enc_dates[2] = (enc_dates[2] & 0x1F) | ((issue_date->tm_hour & 0x1F) << 5); - enc_dates[2] = (enc_dates[2] & 0xE0) | (expire_years & 0x1F); + enc_dates[0] = (enc_dates[0] & 0x07) | (uint8_t)(((issue_date->tm_year + 1900 - 2000) & 0x1F) << 3); + enc_dates[0] = (uint8_t)((enc_dates[0] & 0xF8) | (((issue_date->tm_mon + 1) & 0x0F) >> 1)); + enc_dates[1] = (uint8_t)((enc_dates[1] & 0x7F) | (((issue_date->tm_mon + 1) & 0x0F) << 7)); + enc_dates[1] = (uint8_t)((enc_dates[1] & 0x83) | ((issue_date->tm_mday & 0x1F) << 2)); + enc_dates[1] = (uint8_t)((enc_dates[1] & 0xFC) | ((issue_date->tm_hour & 0x1F) >> 3)); + enc_dates[2] = (uint8_t)((enc_dates[2] & 0x1F) | ((issue_date->tm_hour & 0x1F) << 5)); + enc_dates[2] = (uint8_t)((enc_dates[2] & 0xE0) | (expire_years & 0x1F)); return ATCACERT_E_SUCCESS; } diff --git a/lib/atcacert/atcacert_def.c b/lib/atcacert/atcacert_def.c index 097d2bc05..5da56ec3f 100644 --- a/lib/atcacert/atcacert_def.c +++ b/lib/atcacert/atcacert_def.c @@ -722,7 +722,7 @@ int atcacert_set_signature(const atcacert_def_t* cert_def, const uint8_t signature[64]) { int ret = 0; - uint16_t sig_offset; + int16_t sig_offset; size_t cur_der_sig_size; size_t new_der_sig_size; size_t old_cert_der_length_size; @@ -733,8 +733,8 @@ int atcacert_set_signature(const atcacert_def_t* cert_def, return ATCACERT_E_BAD_PARAMS; } - sig_offset = cert_def->std_cert_elements[STDCERT_SIGNATURE].offset; - sig_offset += get_effective_offset(cert_def, cert, sig_offset); + sig_offset = (int16_t)cert_def->std_cert_elements[STDCERT_SIGNATURE].offset; + sig_offset += get_effective_offset(cert_def, cert, (uint16_t)sig_offset); // Non X.509 signatures are treated like normal certificate elements if (cert_def->type != CERTTYPE_X509) @@ -748,10 +748,10 @@ int atcacert_set_signature(const atcacert_def_t* cert_def, } // Current size of the signature is from its offset to the end of the cert - cur_der_sig_size = *cert_size - sig_offset; + cur_der_sig_size = *cert_size - (uint16_t)sig_offset; // Find the size of buffer available for the new DER signature - new_der_sig_size = max_cert_size - sig_offset; + new_der_sig_size = max_cert_size - (uint16_t)sig_offset; // Set the new signature ret = atcacert_der_enc_ecdsa_sig_value(signature, &cert[sig_offset], &new_der_sig_size); @@ -759,12 +759,12 @@ int atcacert_set_signature(const atcacert_def_t* cert_def, { if (ret == ATCACERT_E_BUFFER_TOO_SMALL) { - *cert_size += (int)new_der_sig_size - (int)cur_der_sig_size; // Report the size needed + *cert_size += new_der_sig_size - cur_der_sig_size; // Report the size needed } return ret; } - *cert_size += (int)new_der_sig_size - (int)cur_der_sig_size; + *cert_size += new_der_sig_size - cur_der_sig_size; old_cert_der_length_size = *cert_size - 1; ret = atcacert_der_adjust_length( @@ -791,7 +791,7 @@ int atcacert_get_signature(const atcacert_def_t* cert_def, size_t cert_size, uint8_t signature[64]) { - uint16_t sig_offset; + int16_t sig_offset; size_t der_sig_size = 0; if (cert_def == NULL || cert == NULL || signature == NULL) @@ -799,8 +799,8 @@ int atcacert_get_signature(const atcacert_def_t* cert_def, return ATCACERT_E_BAD_PARAMS; } - sig_offset = cert_def->std_cert_elements[STDCERT_SIGNATURE].offset; - sig_offset += get_effective_offset(cert_def, cert, sig_offset); + sig_offset = (int16_t)cert_def->std_cert_elements[STDCERT_SIGNATURE].offset; + sig_offset += get_effective_offset(cert_def, cert, (uint16_t)sig_offset); // Non X.509 signatures are treated like normal certificate elements if (cert_def->type != CERTTYPE_X509) @@ -813,7 +813,7 @@ int atcacert_get_signature(const atcacert_def_t* cert_def, return ATCACERT_E_ELEM_OUT_OF_BOUNDS; // Signature element is shown as past the end of the certificate } - der_sig_size = cert_size - sig_offset; + der_sig_size = cert_size - (uint16_t)sig_offset; return atcacert_der_dec_ecdsa_sig_value(&cert[sig_offset], &der_sig_size, signature); } @@ -1507,8 +1507,8 @@ int atcacert_get_comp_cert(const atcacert_def_t* cert_def, return ret; } - comp_cert[69] = ((cert_def->template_id & 0x0F) << 4) | (cert_def->chain_id & 0x0F); - comp_cert[70] = ((uint8_t)(cert_def->sn_source & 0x0F) << 4) | 0; + comp_cert[69] = (uint8_t)(((cert_def->template_id & 0x0F) << 4) | (cert_def->chain_id & 0x0F)); + comp_cert[70] = (uint8_t)(((cert_def->sn_source & 0x0F) << 4) | 0); comp_cert[71] = 0; return ATCACERT_E_SUCCESS; @@ -1529,13 +1529,13 @@ int atcacert_get_tbs(const atcacert_def_t* cert_def, eff_offset = get_effective_offset(cert_def, cert, cert_def->tbs_cert_loc.offset + cert_def->tbs_cert_loc.count); - if ((size_t)(cert_def->tbs_cert_loc.offset + cert_def->tbs_cert_loc.count + eff_offset) > cert_size) + if ((size_t)(cert_def->tbs_cert_loc.offset + cert_def->tbs_cert_loc.count + (size_t)eff_offset) > cert_size) { return ATCACERT_E_BAD_CERT; } *tbs = &cert[cert_def->tbs_cert_loc.offset]; - *tbs_size = cert_def->tbs_cert_loc.count + eff_offset; + *tbs_size = cert_def->tbs_cert_loc.count + (size_t)eff_offset; return ATCACERT_E_SUCCESS; } @@ -1604,12 +1604,12 @@ int atcacert_set_cert_element(const atcacert_def_t* cert_def, eff_offset = get_effective_offset(cert_def, cert, cert_loc->offset); - if ((size_t)(cert_loc->offset + data_size + eff_offset) > cert_size) + if ((size_t)(cert_loc->offset + data_size + (size_t)eff_offset) > cert_size) { return ATCACERT_E_ELEM_OUT_OF_BOUNDS; } - memcpy(&cert[cert_loc->offset + eff_offset], data, data_size); + memcpy(&cert[cert_loc->offset + (size_t)eff_offset], data, data_size); return ATCACERT_E_SUCCESS; } @@ -1640,12 +1640,12 @@ int atcacert_get_cert_element(const atcacert_def_t* cert_def, eff_offset = get_effective_offset(cert_def, cert, cert_loc->offset); - if ((size_t)(cert_loc->offset + cert_loc->count + eff_offset) > cert_size) + if ((size_t)(cert_loc->offset + cert_loc->count + (size_t)eff_offset) > cert_size) { return ATCACERT_E_ELEM_OUT_OF_BOUNDS; } - memcpy(data, &cert[cert_loc->offset + eff_offset], data_size); + memcpy(data, &cert[cert_loc->offset + (size_t)eff_offset], data_size); return ATCACERT_E_SUCCESS; } diff --git a/lib/atcacert/atcacert_der.c b/lib/atcacert/atcacert_der.c index 6cabf4b86..40f2466c2 100644 --- a/lib/atcacert/atcacert_der.c +++ b/lib/atcacert/atcacert_der.c @@ -32,7 +32,7 @@ int atcacert_der_enc_length(uint32_t length, uint8_t* der_length, size_t* der_length_size) { size_t der_length_size_calc = 0; - int exp = sizeof(length) - 1; + int8_t exp = (int8_t)sizeof(length) - 1; if (der_length_size == NULL) { @@ -156,7 +156,7 @@ int atcacert_der_adjust_length(uint8_t* der_length, size_t* der_length_size, int { return ATCACERT_E_ERROR; } - new_len = old_len + delta_length; + new_len = old_len + (uint32_t)delta_length; if (new_length != NULL) { @@ -255,7 +255,7 @@ int atcacert_der_dec_integer(const uint8_t* der_int, { int ret = 0; size_t der_length_size = 0; - uint32_t int_data_size_calc = 0; + size_t int_data_size_calc = 0; if (der_int == NULL || der_int_size == NULL || (int_data != NULL && int_data_size == NULL)) { @@ -273,7 +273,7 @@ int atcacert_der_dec_integer(const uint8_t* der_int, } der_length_size = *der_int_size - 1; - ret = atcacert_der_dec_length(&der_int[1], &der_length_size, &int_data_size_calc); + ret = atcacert_der_dec_length(&der_int[1], &der_length_size, (uint32_t*)(&int_data_size_calc)); if (ret != ATCACERT_E_SUCCESS) { return ret; diff --git a/lib/atcacert/atcacert_pem.c b/lib/atcacert/atcacert_pem.c index c897b69ab..ca12fb9ca 100644 --- a/lib/atcacert/atcacert_pem.c +++ b/lib/atcacert/atcacert_pem.c @@ -139,7 +139,7 @@ int atcacert_decode_pem(const char* pem, } // Decode data - status = atcab_base64decode(data_pos, footer_pos - data_pos, der, der_size); + status = atcab_base64decode(data_pos, (size_t)(footer_pos - data_pos), der, der_size); if (status != ATCA_SUCCESS) { if (status == ATCA_SMALL_BUFFER) diff --git a/lib/calib/calib_aes_gcm.c b/lib/calib/calib_aes_gcm.c index 73adf094c..d7ee27494 100644 --- a/lib/calib/calib_aes_gcm.c +++ b/lib/calib/calib_aes_gcm.c @@ -286,7 +286,7 @@ ATCA_STATUS calib_aes_gcm_aad_update(ATCADevice device, atca_aes_gcm_ctx_t* ctx, ATCA_STATUS status; uint32_t block_count; uint32_t rem_size; - uint32_t copy_size; + size_t copy_size; if (ctx == NULL || (aad_size > 0 && aad == NULL)) { @@ -299,7 +299,7 @@ ATCA_STATUS calib_aes_gcm_aad_update(ATCADevice device, atca_aes_gcm_ctx_t* ctx, } rem_size = AES_DATA_SIZE - (uint32_t)ctx->partial_aad_size; - copy_size = aad_size > rem_size ? rem_size : aad_size; + copy_size = aad_size > rem_size ? (size_t)rem_size : (size_t)aad_size; // Copy data into current block memcpy(&ctx->partial_aad[ctx->partial_aad_size], aad, copy_size); @@ -328,7 +328,7 @@ ATCA_STATUS calib_aes_gcm_aad_update(ATCADevice device, atca_aes_gcm_ctx_t* ctx, // Save any remaining data ctx->aad_size += (block_count + 1) * AES_DATA_SIZE; ctx->partial_aad_size = aad_size % AES_DATA_SIZE; - memcpy(ctx->partial_aad, &aad[copy_size + block_count * AES_DATA_SIZE], ctx->partial_aad_size); + memcpy(ctx->partial_aad, &aad[copy_size + block_count * AES_DATA_SIZE], (size_t)ctx->partial_aad_size); return ATCA_SUCCESS; } diff --git a/lib/calib/calib_basic.c b/lib/calib/calib_basic.c index b9e08b571..cf37063d6 100644 --- a/lib/calib/calib_basic.c +++ b/lib/calib/calib_basic.c @@ -42,7 +42,7 @@ ATCA_STATUS calib_wakeup_i2c(ATCADevice device) if (iface) { - uint8_t retries = atca_iface_get_retries(iface); + int retries = atca_iface_get_retries(iface); uint8_t address = atcab_get_device_address(device); uint32_t temp; uint32_t wake; @@ -116,7 +116,7 @@ ATCA_STATUS calib_wakeup(ATCADevice device) #ifdef ATCA_HAL_LEGACY_API status = atwake(iface); #else - if (atca_iface_is_kit(iface) || (ATCA_SWI_IFACE == iface->mIfaceCFG->iface_type)) + if (atca_iface_is_kit(iface) || atca_iface_is_swi(&device->mIface)) { status = atwake(iface); } @@ -145,7 +145,7 @@ ATCA_STATUS calib_idle(ATCADevice device) #ifdef ATCA_HAL_LEGACY_API status = atidle(&device->mIface); #else - if (atca_iface_is_kit(&device->mIface) || (ATCA_SWI_IFACE == device->mIface.mIfaceCFG->iface_type)) + if (atca_iface_is_kit(&device->mIface) || atca_iface_is_swi(&device->mIface)) { status = atidle(&device->mIface); } @@ -176,7 +176,7 @@ ATCA_STATUS calib_sleep(ATCADevice device) #ifdef ATCA_HAL_LEGACY_API status = atsleep(&device->mIface); #else - if (atca_iface_is_kit(&device->mIface) || (ATCA_SWI_IFACE == device->mIface.mIfaceCFG->iface_type)) + if (atca_iface_is_kit(&device->mIface) || atca_iface_is_swi(&device->mIface)) { status = atsleep(&device->mIface); } @@ -229,14 +229,14 @@ ATCA_STATUS calib_get_addr(uint8_t zone, uint16_t slot, uint8_t block, uint8_t o offset = offset & (uint8_t)0x07; if ((mem_zone == ATCA_ZONE_CONFIG) || (mem_zone == ATCA_ZONE_OTP)) { - *addr = block << 3; + *addr = ((uint16_t)block) << 3; *addr |= offset; } else // ATCA_ZONE_DATA { *addr = slot << 3; *addr |= offset; - *addr |= block << 8; + *addr |= ((uint16_t)block) << 8; } } while (0); @@ -269,7 +269,7 @@ ATCA_STATUS calib_ecc204_get_addr(uint8_t zone, uint16_t slot, uint8_t block, ui // Initialize the addr to 00 *addr = 0; *addr = slot << 3; - *addr |= block << 8; + *addr |= ((uint16_t)block) << 8; return status; } @@ -318,8 +318,8 @@ ATCA_STATUS calib_get_zone_size(ATCADevice device, uint8_t zone, uint16_t slot, { switch (zone) { - case ATCA_ECC204_ZONE_CONFIG: *size = 16; break; - case ATCA_ECC204_ZONE_DATA: + case ATCA_ZONE_CONFIG: *size = 64; break; + case ATCA_ZONE_DATA: if ((0 == slot) || (3 == slot)) { *size = 32; diff --git a/lib/calib/calib_basic.h b/lib/calib/calib_basic.h index ee93ae07b..f5d3c3577 100644 --- a/lib/calib/calib_basic.h +++ b/lib/calib/calib_basic.h @@ -93,9 +93,10 @@ 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); // Lock ECC204 command functions -ATCA_STATUS calib_ecc204_lock_config_slot(ATCADevice device, uint8_t slot, uint16_t summary_crc); +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, uint8_t slot); +ATCA_STATUS calib_ecc204_lock_data_slot(ATCADevice device, uint16_t slot); +ATCA_STATUS calib_ecc204_lock_data_zone(ATCADevice device); // MAC command functions ATCA_STATUS calib_mac(ATCADevice device, uint8_t mode, uint16_t key_id, const uint8_t* challenge, uint8_t* digest); @@ -129,7 +130,7 @@ ATCA_STATUS calib_read_sig(ATCADevice device, uint16_t slot, uint8_t *sig); 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); // ECC204 Read command functions -ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint8_t slot, uint8_t block, size_t offset, +ATCA_STATUS calib_ecc204_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_config_zone(ATCADevice device, uint8_t* config_data); ATCA_STATUS calib_ecc204_read_serial_number(ATCADevice device, uint8_t* serial_number); @@ -217,10 +218,10 @@ ATCA_STATUS calib_write_enc(ATCADevice device, uint16_t key_id, uint8_t block, c #endif #if defined(ATCA_USE_CONSTANT_HOST_NONCE) -ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint8_t slot, uint8_t* data, uint8_t* transport_key, +ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint16_t slot, uint8_t* data, uint8_t* transport_key, uint8_t key_id); #else -ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint8_t slot, uint8_t* data, uint8_t* transport_key, +ATCA_STATUS calib_ecc204_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 diff --git a/lib/calib/calib_command.c b/lib/calib/calib_command.c index c73b0bb5b..f8d6fc585 100644 --- a/lib/calib/calib_command.c +++ b/lib/calib/calib_command.c @@ -394,14 +394,14 @@ ATCA_STATUS atSHA(ATCADeviceType device_type, ATCAPacket *packet, uint16_t write break; case SHA_MODE_SHA256_UPDATE: // UPDATE - packet->txsize = ATCA_CMD_SIZE_MIN + packet->param2; + packet->txsize = (uint8_t)(ATCA_CMD_SIZE_MIN + packet->param2); break; case SHA_MODE_SHA256_END: // END case SHA_MODE_HMAC_END: // check the given packet for a size variable in param2. If it is > 0, it should // be 0-63, incorporate that size into the packet - packet->txsize = ATCA_CMD_SIZE_MIN + packet->param2; + packet->txsize = (uint8_t)(ATCA_CMD_SIZE_MIN + packet->param2); break; case SHA_MODE_READ_CONTEXT: @@ -409,7 +409,7 @@ ATCA_STATUS atSHA(ATCADeviceType device_type, ATCAPacket *packet, uint16_t write break; case SHA_MODE_WRITE_CONTEXT: - packet->txsize = ATCA_CMD_SIZE_MIN + write_context_size; + packet->txsize = (uint8_t)(ATCA_CMD_SIZE_MIN + write_context_size); break; } diff --git a/lib/calib/calib_counter.c b/lib/calib/calib_counter.c index 32c39d1ab..0a53d40f6 100644 --- a/lib/calib/calib_counter.c +++ b/lib/calib/calib_counter.c @@ -74,10 +74,22 @@ ATCA_STATUS calib_counter(ATCADevice device, uint8_t mode, uint16_t counter_id, { if (packet.data[ATCA_COUNT_IDX] == 7) { - *counter_value = ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 0] << 0) | - ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 1] << 8) | - ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 2] << 16) | - ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 3] << 24); + if (ECC204 == device->mIface.mIfaceCFG->devtype) + { + #if defined(ATCA_ECC204_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) | + ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 0] << 24); + #endif + } + else + { + *counter_value = ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 0] << 0) | + ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 1] << 8) | + ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 2] << 16) | + ((uint32_t)packet.data[ATCA_RSP_DATA_IDX + 3] << 24); + } } else { diff --git a/lib/calib/calib_execution.c b/lib/calib/calib_execution.c index 86449ea81..0cc58334e 100644 --- a/lib/calib/calib_execution.c +++ b/lib/calib/calib_execution.c @@ -305,11 +305,11 @@ ATCA_STATUS calib_execute_send(ATCADevice device, uint8_t device_address, uint8_ #ifdef ATCA_HAL_LEGACY_API ((void)device_address); - status = atsend(&device->mIface, 0xFF, (uint8_t*)txdata, txlength - 1); + status = atsend(&device->mIface, 0xFF, (uint8_t*)txdata, (int)txlength - 1); #else if (atca_iface_is_kit(&device->mIface)) { - status = atsend(&device->mIface, 0xFF, (uint8_t*)txdata, txlength - 1); + status = atsend(&device->mIface, 0xFF, (uint8_t*)txdata, (int)txlength - 1); } else { @@ -317,7 +317,7 @@ ATCA_STATUS calib_execute_send(ATCADevice device, uint8_t device_address, uint8_ if (ATCA_UNIMPLEMENTED == status || ATCA_SUCCESS == status) { /* Send the command packet to the device */ - status = atsend(&device->mIface, device_address, (uint8_t*)txdata, txlength); + status = atsend(&device->mIface, device_address, (uint8_t*)txdata, (int)txlength); } (void)atcontrol(&device->mIface, ATCA_HAL_CONTROL_DESELECT, NULL, 0); } @@ -367,9 +367,13 @@ ATCA_STATUS calib_execute_receive(ATCADevice device, uint8_t device_address, uin word_address = 0; } - if (ATCA_SUCCESS != (status = atsend(&device->mIface, device_address, &word_address, sizeof(word_address)))) + // Skip word address send for ECC204 device + if (ECC204 != device->mIface.mIfaceCFG->devtype) { - break; + if (ATCA_SUCCESS != (status = atsend(&device->mIface, device_address, &word_address, sizeof(word_address)))) + { + break; + } } /* Read length bytes to know number of bytes to read */ @@ -397,6 +401,7 @@ ATCA_STATUS calib_execute_receive(ATCADevice device, uint8_t device_address, uin /* Read given length bytes from device */ read_length -= 1; + status = atreceive(&device->mIface, device_address, &rxdata[1], &read_length); if (ATCA_SUCCESS != status) @@ -470,6 +475,10 @@ 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)) + { + packet->_reserved = 0x03; + } 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; diff --git a/lib/calib/calib_helpers.c b/lib/calib/calib_helpers.c index ef38f7ce7..96e0b6e67 100644 --- a/lib/calib/calib_helpers.c +++ b/lib/calib/calib_helpers.c @@ -201,11 +201,11 @@ ATCA_STATUS calib_ecc204_is_locked(ATCADevice device, uint8_t zone, bool* is_loc { ATCA_STATUS status = ATCA_SUCCESS; - if (ATCA_ECC204_ZONE_CONFIG == zone) + if (ATCA_ZONE_CONFIG == zone) { status = calib_ecc204_is_config_locked(device, is_locked); } - else if (ATCA_ECC204_ZONE_DATA == zone) + else if (ATCA_ZONE_DATA == zone) { status = calib_ecc204_is_data_locked(device, is_locked); } diff --git a/lib/calib/calib_info.c b/lib/calib/calib_info.c index 98c229091..7f4a2870e 100644 --- a/lib/calib/calib_info.c +++ b/lib/calib/calib_info.c @@ -64,7 +64,6 @@ ATCA_STATUS calib_info_base(ATCADevice device, uint8_t mode, uint16_t param2, ui do { - if ((status = atInfo(atcab_get_device_type_ext(device), &packet)) != ATCA_SUCCESS) { ATCA_TRACE(status, "atInfo - failed"); @@ -73,8 +72,21 @@ ATCA_STATUS calib_info_base(ATCADevice device, uint8_t mode, uint16_t param2, ui if ((status = atca_execute_command(&packet, device)) != ATCA_SUCCESS) { - ATCA_TRACE(status, "calib_info_base - execution failed"); - break; + // For ECC204, 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)) + { + if (status == ATCA_CHECKMAC_VERIFY_FAILED) + { + status = ATCA_SUCCESS; + } + } + else + { + ATCA_TRACE(status, "calib_info_base - execution failed"); + break; + } } uint8_t response = packet.data[ATCA_COUNT_IDX]; diff --git a/lib/calib/calib_kdf.c b/lib/calib/calib_kdf.c index 293056284..07a1095f3 100644 --- a/lib/calib/calib_kdf.c +++ b/lib/calib/calib_kdf.c @@ -80,10 +80,10 @@ ATCA_STATUS calib_kdf(ATCADevice device, uint8_t mode, uint16_t key_id, const ui packet.param2 = key_id; // Add details parameter - packet.data[0] = details; - packet.data[1] = details >> 8; - packet.data[2] = details >> 16; - packet.data[3] = details >> 24; + packet.data[0] = (uint8_t)details; + packet.data[1] = (uint8_t)(details >> 8); + packet.data[2] = (uint8_t)(details >> 16); + packet.data[3] = (uint8_t)(details >> 24); // Add input message if ((mode & KDF_MODE_ALG_MASK) == KDF_MODE_ALG_AES) diff --git a/lib/calib/calib_lock.c b/lib/calib/calib_lock.c index 6c3e91466..f7fee5f65 100644 --- a/lib/calib/calib_lock.c +++ b/lib/calib/calib_lock.c @@ -159,9 +159,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, uint8_t slot, uint16_t summary_crc) +ATCA_STATUS calib_ecc204_lock_config_slot(ATCADevice device, uint16_t slot, uint16_t summary_crc) { - uint8_t mode = LOCK_ECC204_ZONE_CONFIG | (slot << 1); + uint8_t mode = (uint8_t)(LOCK_ECC204_ZONE_CONFIG | (slot << 1)); if (!summary_crc) { @@ -185,12 +185,21 @@ ATCA_STATUS calib_ecc204_lock_config_zone(ATCADevice device) while (slot <= 3) { - mode = LOCK_ZONE_NO_CRC | LOCK_ECC204_ZONE_CONFIG | (slot << 1); + mode = (uint8_t)(LOCK_ZONE_NO_CRC | LOCK_ECC204_ZONE_CONFIG | (slot << 1)); if (ATCA_SUCCESS != (status = calib_lock(device, mode, 0))) { - ATCA_TRACE(status, "calib_ecc204_lock_config_zone - failed"); - break; + // ECC204 returns execution error if slot is already locked. + // Consider already locked status as valid while locking the config zone. + if (status == ATCA_EXECUTION_ERROR) + { + status = ATCA_SUCCESS; + } + else + { + ATCA_TRACE(status, "calib_ecc204_lock_config_zone - failed"); + break; + } } slot += 1; //Increment slot @@ -206,7 +215,44 @@ 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, uint8_t slot) +ATCA_STATUS calib_ecc204_lock_data_slot(ATCADevice device, uint16_t slot) +{ + return calib_lock(device, (uint8_t)(LOCK_ECC204_ZONE_DATA | (slot << 1)), 0); +} + +/** \brief Use lock command to lock complete Data zone + * + * \param[in] device Device context pointer + * + * \return ATCA_SUCCESS on success, otherwise an error code + */ +ATCA_STATUS calib_ecc204_lock_data_zone(ATCADevice device) { - return calib_lock(device, LOCK_ECC204_ZONE_DATA | (slot << 1), 0); + ATCA_STATUS status = ATCA_GEN_FAIL; + uint8_t slot = 0; + uint8_t mode; + + while (slot <= 3) + { + mode = LOCK_ZONE_NO_CRC | LOCK_ECC204_ZONE_DATA | (slot << 1); + + if (ATCA_SUCCESS != (status = calib_lock(device, mode, 0))) + { + // ECC204 returns execution error if slot is already locked. + // Consider already locked status as valid while locking the config zone. + if (status == ATCA_EXECUTION_ERROR) + { + status = ATCA_SUCCESS; + } + else + { + ATCA_TRACE(status, "calib_ecc204_lock_data_zone - failed"); + break; + } + } + + slot += 1; //Increment slot + } + + return status; } diff --git a/lib/calib/calib_read.c b/lib/calib/calib_read.c index b8a362e60..4acefea7f 100644 --- a/lib/calib/calib_read.c +++ b/lib/calib/calib_read.c @@ -677,32 +677,53 @@ ATCA_STATUS calib_read_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot * * \return ATCA_SUCCESS on success, otherwise an error code */ -ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint8_t slot, uint8_t block, size_t offset, +ATCA_STATUS calib_ecc204_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; ATCAPacket packet; uint16_t addr; + uint8_t read_zone; (void)offset; + read_zone = (zone == ATCA_ZONE_CONFIG) ? ATCA_ECC204_ZONE_CONFIG : ATCA_ECC204_ZONE_DATA; + + if ((NULL == device) || (NULL == data)) { status = ATCA_TRACE(ATCA_BAD_PARAM, "Encountered Null pointer"); } - else if (((ATCA_ECC204_ZONE_CONFIG == zone) && (16 != len)) || - ((ATCA_ECC204_ZONE_DATA == zone) && (32 != len))) + else if (ATCA_ZONE_DATA == zone) { - status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); + if (32 != len) + { + status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); + } + else if ((0x00 == slot) || (0x03 == slot)) + { + status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid slot number received"); + } + else + { + read_zone = ATCA_ECC204_ZONE_DATA; + } } - else if ((ATCA_ECC204_ZONE_DATA == zone) && ((0x00 == slot) || (0x01 == slot))) + else if (ATCA_ECC204_ZONE_CONFIG == zone) { - status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid slot number received"); + if (16 != len) + { + status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); + } + else + { + read_zone = ATCA_ECC204_ZONE_CONFIG; + } } if (ATCA_SUCCESS == status) { - if (ATCA_SUCCESS != (status = calib_ecc204_get_addr(zone, slot, block, 0, &addr))) + if (ATCA_SUCCESS != (status = calib_ecc204_get_addr(read_zone, slot, block, 0, &addr))) { ATCA_TRACE(status, "Address Encoding failed"); } @@ -710,7 +731,7 @@ ATCA_STATUS calib_ecc204_read_zone(ATCADevice device, uint8_t zone, uint8_t slot if (ATCA_SUCCESS == status) { // Build packets - packet.param1 = zone; + packet.param1 = read_zone; packet.param2 = addr; (void)atRead(atcab_get_device_type_ext(device), &packet); @@ -790,30 +811,31 @@ ATCA_STATUS calib_ecc204_read_serial_number(ATCADevice device, uint8_t* serial_n * 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). + * \param[in] zone Zone to read data from. Option are ATCA_ZONE_CONFIG(1), + * or ATCA_ZONE_DATA(0). + * \param[in] slot Slot number to read from * Ignored for all other zones. - * \param[in] block Byte offset within the zone to read from. + * \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_ecc204_read_bytes_zone(ATCADevice device, uint8_t zone, uint16_t slot, - size_t block, uint8_t* data, size_t length) + size_t offset, uint8_t* data, size_t length) { ATCA_STATUS status = ATCA_GEN_FAIL; uint8_t block_size = (zone == ATCA_ECC204_ZONE_CONFIG) ? ATCA_ECC204_CONFIG_SLOT_SIZE : ATCA_BLOCK_SIZE; uint8_t no_of_blocks; uint8_t data_idx = 0; + size_t cur_block = 0; if ((NULL == device) || (NULL == data)) { return ATCA_TRACE(ATCA_BAD_PARAM, "Encountered NULL pointer"); } else if ((ATCA_ECC204_ZONE_DATA == zone) && (((length > 64) && (2 == slot)) || - ((length > 320) && (3 == slot)) || (1 == slot) || (0 == slot))) + ((length > 320) && (1 == slot)) || (3 == slot) || (0 == slot))) { return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); } @@ -822,10 +844,11 @@ ATCA_STATUS calib_ecc204_read_bytes_zone(ATCADevice device, uint8_t zone, uint16 return ATCA_SUCCESS; } - no_of_blocks = length / block_size; + cur_block = offset / block_size; + no_of_blocks = (uint8_t)(length / block_size); while (no_of_blocks--) { - if (ATCA_SUCCESS != (status = calib_ecc204_read_zone(device, zone, slot, block, 0, + if (ATCA_SUCCESS != (status = calib_ecc204_read_zone(device, zone, slot, cur_block, 0, &data[block_size * data_idx], block_size))) { @@ -833,7 +856,14 @@ ATCA_STATUS calib_ecc204_read_bytes_zone(ATCADevice device, uint8_t zone, uint16 break; } - block += 1; // Read next block + if (zone == ATCA_ECC204_ZONE_CONFIG) + { + slot += 1; + } + else + { + cur_block += 1; + } data_idx += 1; // increment data index } diff --git a/lib/calib/calib_sha.c b/lib/calib/calib_sha.c index 05a27c29b..ff54aa673 100644 --- a/lib/calib/calib_sha.c +++ b/lib/calib/calib_sha.c @@ -95,7 +95,7 @@ ATCA_STATUS calib_sha_base(ATCADevice device, uint8_t mode, uint16_t length, con if (cmd_mode != SHA_MODE_SHA256_PUBLIC && cmd_mode != SHA_MODE_HMAC_START && cmd_mode != SHA_MODE_ECC204_HMAC_START) { - memcpy(packet.data, message, length); + memcpy(packet.data, message, (size_t)length); } if ((status = atSHA(atcab_get_device_type_ext(device), &packet, length)) != ATCA_SUCCESS) @@ -239,7 +239,7 @@ ATCA_STATUS calib_hw_sha2_256_update(ATCADevice device, atca_sha256_ctx_t* ctx, ATCA_STATUS status = ATCA_SUCCESS; uint32_t block_count; uint32_t rem_size = ATCA_SHA256_BLOCK_SIZE - ctx->block_size; - uint32_t copy_size = data_size > rem_size ? rem_size : (uint32_t)data_size; + size_t copy_size = data_size > rem_size ? (size_t)rem_size : data_size; uint32_t i = 0; // Copy data into current block @@ -272,7 +272,7 @@ ATCA_STATUS calib_hw_sha2_256_update(ATCADevice device, atca_sha256_ctx_t* ctx, // Save any remaining data ctx->total_msg_size += (block_count + 1) * ATCA_SHA256_BLOCK_SIZE; ctx->block_size = data_size % ATCA_SHA256_BLOCK_SIZE; - memcpy(ctx->block, &data[copy_size + block_count * ATCA_SHA256_BLOCK_SIZE], ctx->block_size); + memcpy(ctx->block, &data[copy_size + block_count * ATCA_SHA256_BLOCK_SIZE], (size_t)ctx->block_size); return ATCA_SUCCESS; } @@ -315,7 +315,7 @@ ATCA_STATUS calib_hw_sha2_256_finish(ATCADevice device, atca_sha256_ctx_t* ctx, ctx->block[ctx->block_size++] = 0x80; // Add padding zeros plus upper 4 bytes of total message size in bits (only supporting 32bit message bit counts) - memset(&ctx->block[ctx->block_size], 0, pad_zero_count + 4); + memset(&ctx->block[ctx->block_size], 0, (size_t)pad_zero_count + 4); ctx->block_size += pad_zero_count + 4; // Add the total message size in bits to the end of the current block. Technically this is @@ -342,7 +342,7 @@ ATCA_STATUS calib_hw_sha2_256_finish(ATCADevice device, atca_sha256_ctx_t* ctx, } else { - if (ATCA_SUCCESS != (status = calib_sha_end(device, digest, ctx->block_size, ctx->block))) + if (ATCA_SUCCESS != (status = calib_sha_end(device, digest, (uint16_t)ctx->block_size, ctx->block))) { return ATCA_TRACE(status, "calib_sha_end - failed"); } @@ -425,7 +425,7 @@ ATCA_STATUS calib_sha_hmac_update(ATCADevice device, atca_hmac_sha256_ctx_t* ctx ATCA_STATUS status = ATCA_SUCCESS; uint32_t block_count; uint32_t rem_size = ATCA_SHA256_BLOCK_SIZE - ctx->block_size; - uint32_t copy_size = data_size > rem_size ? rem_size : (uint32_t)data_size; + size_t copy_size = data_size > rem_size ? (size_t)rem_size : data_size; uint32_t i = 0; // Copy data into current block @@ -458,7 +458,7 @@ ATCA_STATUS calib_sha_hmac_update(ATCADevice device, atca_hmac_sha256_ctx_t* ctx // Save any remaining data ctx->total_msg_size += (block_count + 1) * ATCA_SHA256_BLOCK_SIZE; ctx->block_size = data_size % ATCA_SHA256_BLOCK_SIZE; - memcpy(ctx->block, &data[copy_size + block_count * ATCA_SHA256_BLOCK_SIZE], ctx->block_size); + memcpy(ctx->block, &data[copy_size + block_count * ATCA_SHA256_BLOCK_SIZE], (size_t)ctx->block_size); return ATCA_SUCCESS; } @@ -502,7 +502,7 @@ ATCA_STATUS calib_sha_hmac_finish(ATCADevice device, atca_hmac_sha256_ctx_t *ctx mode |= target; - return calib_sha_base(device, mode, ctx->block_size, ctx->block, digest, &digest_size); + return calib_sha_base(device, mode, (uint16_t)ctx->block_size, ctx->block, digest, &digest_size); } /** \brief Use the SHA command to compute an HMAC/SHA-256 operation. diff --git a/lib/calib/calib_sign.c b/lib/calib/calib_sign.c index 253419358..940abf2a6 100644 --- a/lib/calib/calib_sign.c +++ b/lib/calib/calib_sign.c @@ -234,7 +234,7 @@ ATCA_STATUS calib_ecc204_sign(ATCADevice device, uint16_t key_id, const uint8_t* if (ATCA_SUCCESS == status) { - if (NULL == signature) + if (signature != NULL) { if (packet.data[ATCA_COUNT_IDX] == (ATCA_SIG_SIZE + ATCA_PACKET_OVERHEAD)) { diff --git a/lib/calib/calib_write.c b/lib/calib/calib_write.c index 5f8503b84..d07b686cf 100644 --- a/lib/calib/calib_write.c +++ b/lib/calib/calib_write.c @@ -378,7 +378,7 @@ ATCA_STATUS calib_write_pubkey(ATCADevice device, uint16_t slot, const uint8_t * { ATCA_STATUS status = ATCA_SUCCESS; uint8_t public_key_formatted[ATCA_BLOCK_SIZE * 3]; - int block; + uint8_t block; // Check the pointers if (public_key == NULL) @@ -539,8 +539,8 @@ ATCA_STATUS calib_write_config_counter(ATCADevice device, uint16_t counter_id, u lin_a = 0xFFFF >> (counter_value % 32); lin_b = 0xFFFF >> ((counter_value >= 16) ? (counter_value - 16) % 32 : 0); - bin_a = counter_value / 32; - bin_b = (counter_value >= 16) ? ((counter_value - 16) / 32) : 0; + bin_a = (uint16_t)(counter_value / 32); + bin_b = (counter_value >= 16) ? ((uint16_t)((counter_value - 16) / 32)) : 0; bytes[idx++] = lin_a >> 8; bytes[idx++] = lin_a & 0xFF; @@ -641,6 +641,7 @@ ATCA_STATUS calib_ecc204_write_zone(ATCADevice device, uint8_t zone, uint16_t sl { ATCA_STATUS status = ATCA_SUCCESS; uint16_t addr; + uint8_t write_zone = (zone == ATCA_ZONE_CONFIG) ? ATCA_ECC204_ZONE_CONFIG : ATCA_ECC204_ZONE_DATA; ((void)offset); @@ -648,22 +649,22 @@ ATCA_STATUS calib_ecc204_write_zone(ATCADevice device, uint8_t zone, uint16_t sl { status = ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); } - else if (((ATCA_ECC204_ZONE_CONFIG == zone) && (16 != len)) || - ((ATCA_ECC204_ZONE_DATA == zone) && (ATCA_BLOCK_SIZE != len))) + else if (((ATCA_ECC204_ZONE_CONFIG == write_zone) && (16 != len)) || + ((ATCA_ECC204_ZONE_DATA == write_zone) && (ATCA_BLOCK_SIZE != len))) { status = ATCA_TRACE(ATCA_BAD_PARAM, "Invalid length received"); } if (ATCA_SUCCESS == status) { - if (ATCA_SUCCESS != (status = calib_ecc204_get_addr(zone, slot, block, 0, &addr))) + if (ATCA_SUCCESS != (status = calib_ecc204_get_addr(write_zone, slot, block, 0, &addr))) { ATCA_TRACE(status, "calib_ecc204_get_addr - failed"); } if (ATCA_SUCCESS == status) { - status = calib_ecc204_write(device, zone, addr, data, NULL); + status = calib_ecc204_write(device, write_zone, addr, data, NULL); } } @@ -715,13 +716,13 @@ ATCA_STATUS calib_ecc204_write_config_zone(ATCADevice device, const uint8_t* con * \return ATCA_SUCCESS on success, otherwise an error code */ #if defined(ATCA_USE_CONSTANT_HOST_NONCE) -ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint8_t slot, uint8_t* data, uint8_t* transport_key, +ATCA_STATUS calib_ecc204_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] = { 0 }; #else -ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint8_t slot, uint8_t* data, uint8_t* transport_key, +ATCA_STATUS calib_ecc204_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]) { #endif @@ -827,8 +828,7 @@ ATCA_STATUS calib_ecc204_write_enc(ATCADevice device, uint8_t slot, uint8_t* dat * read the requested data. * * \param[in] device Device context pointer - * \param[in] zone zone to write data to. Option are - * ATCA_ECC204_ZONE_CONFIG(1), ATCA_ECC204_ZONE_DATA(0) + * \param[in] zone It accepts only ATCA_ZONE_DATA for ECC204 device * \param[in] slot slot number to write to. * \param[in] block offset bytes ignored * \param[in] data data to be written @@ -840,7 +840,7 @@ ATCA_STATUS calib_ecc204_write_bytes_zone(ATCADevice device, uint8_t zone, uint1 const uint8_t *data, size_t length) { ATCA_STATUS status = ATCA_SUCCESS; - uint8_t block_size = (zone == ATCA_ECC204_ZONE_CONFIG) ? ATCA_ECC204_CONFIG_SLOT_SIZE : ATCA_BLOCK_SIZE; + uint8_t block_size = ATCA_BLOCK_SIZE; uint8_t no_of_blocks; uint8_t data_idx = 0; @@ -848,8 +848,14 @@ ATCA_STATUS calib_ecc204_write_bytes_zone(ATCADevice device, uint8_t zone, uint1 { return ATCA_TRACE(ATCA_BAD_PARAM, "Encountered NULL pointer"); } - else if ((ATCA_ECC204_ZONE_DATA == zone) && (((length > 64) && (2 == slot)) || - ((length > 320) && (3 == slot)) || (1 == slot) || (0 == slot))) + else if (ATCA_ZONE_DATA == zone) + { + if (((length > 64) && (2 == slot)) || ((length > 320) && (1 == slot)) || (0 == slot)) + { + return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); + } + } + else if (ATCA_ZONE_CONFIG == zone) { return ATCA_TRACE(ATCA_BAD_PARAM, "Invalid parameter received"); } @@ -858,7 +864,7 @@ ATCA_STATUS calib_ecc204_write_bytes_zone(ATCADevice device, uint8_t zone, uint1 return ATCA_SUCCESS; } - no_of_blocks = length / block_size; + no_of_blocks = (uint8_t)(length / block_size); while (no_of_blocks--) { if (ATCA_SUCCESS != (status = calib_ecc204_write_zone(device, zone, slot, (uint8_t)block, 0, diff --git a/lib/crypto/atca_crypto_hw_aes_cbcmac.c b/lib/crypto/atca_crypto_hw_aes_cbcmac.c index ef5f504ba..ee4437c7e 100644 --- a/lib/crypto/atca_crypto_hw_aes_cbcmac.c +++ b/lib/crypto/atca_crypto_hw_aes_cbcmac.c @@ -117,7 +117,7 @@ ATCA_STATUS atcab_aes_cbcmac_update(atca_aes_cbcmac_ctx_t* ctx, const uint8_t* d // Store incomplete block to context structure if ((i * ATCA_AES128_BLOCK_SIZE) < data_size) { - memcpy(ctx->block, &data[i * ATCA_AES128_BLOCK_SIZE], data_size - i * ATCA_AES128_BLOCK_SIZE); + memcpy(ctx->block, &data[i * ATCA_AES128_BLOCK_SIZE], (size_t)(data_size - i * ATCA_AES128_BLOCK_SIZE)); ctx->block_size = (uint8_t)(data_size - i * ATCA_AES128_BLOCK_SIZE); } else @@ -149,7 +149,7 @@ ATCA_STATUS atcab_aes_cbcmac_finish(atca_aes_cbcmac_ctx_t* ctx, uint8_t* mac, ui if (ctx->block_size == 0) { // All processing is already done, copying the mac to result buffer - memcpy(mac, ctx->cbc_ctx.ciphertext, mac_size); + memcpy(mac, ctx->cbc_ctx.ciphertext, (size_t)mac_size); } else { diff --git a/lib/crypto/atca_crypto_hw_aes_ccm.c b/lib/crypto/atca_crypto_hw_aes_ccm.c index b3a52d4ca..fdbba037d 100644 --- a/lib/crypto/atca_crypto_hw_aes_ccm.c +++ b/lib/crypto/atca_crypto_hw_aes_ccm.c @@ -101,7 +101,7 @@ ATCA_STATUS atcab_aes_ccm_init_ext(ATCADevice device, atca_aes_ccm_ctx_t* ctx, u -----------------------*/ memset(B, 0, ATCA_AES128_BLOCK_SIZE); // Formatting flag field - B[0] = L | (M << 3) | ((aad_size > 0) << 6); + B[0] = (uint8_t)(L | (M << 3) | ((aad_size > 0) << 6)); /*---------------------- Octet Number Contents @@ -135,9 +135,12 @@ ATCA_STATUS atcab_aes_ccm_init_ext(ATCADevice device, atca_aes_ccm_ctx_t* ctx, u } // Loading AAD size in ctx buffer. - ctx->partial_aad[0] = (uint8_t)(aad_size >> 8) & 0xff; - ctx->partial_aad[1] = (uint8_t)(aad_size & 0xff); - ctx->partial_aad_size = 2; + if (aad_size > 0) + { + ctx->partial_aad[0] = (uint8_t)(aad_size >> 8) & 0xff; + ctx->partial_aad[1] = (uint8_t)(aad_size & 0xff); + ctx->partial_aad_size = 2; + } // --------------------- Init sequence for encryption/decryption .......................// memset(counter, 0, ATCA_AES128_BLOCK_SIZE); @@ -464,7 +467,7 @@ static ATCA_STATUS atcab_aes_ccm_update(atca_aes_ccm_ctx_t* ctx, const uint8_t* */ ATCA_STATUS atcab_aes_ccm_encrypt_update(atca_aes_ccm_ctx_t* ctx, const uint8_t* plaintext, uint32_t plaintext_size, uint8_t* ciphertext) { - return atcab_aes_ccm_update(ctx, plaintext, plaintext_size, ciphertext, true); + return atcab_aes_ccm_update(ctx, plaintext, (size_t)plaintext_size, ciphertext, true); } /** \brief Process data using CCM mode and a key within the ATECC608A device. @@ -479,7 +482,7 @@ ATCA_STATUS atcab_aes_ccm_encrypt_update(atca_aes_ccm_ctx_t* ctx, const uint8_t* */ ATCA_STATUS atcab_aes_ccm_decrypt_update(atca_aes_ccm_ctx_t* ctx, const uint8_t* ciphertext, uint32_t ciphertext_size, uint8_t* plaintext) { - return atcab_aes_ccm_update(ctx, ciphertext, ciphertext_size, plaintext, false); + return atcab_aes_ccm_update(ctx, ciphertext, (size_t)ciphertext_size, plaintext, false); } /** \brief Complete a CCM operation returning the authentication tag. diff --git a/lib/crypto/atca_crypto_hw_aes_cmac.c b/lib/crypto/atca_crypto_hw_aes_cmac.c index b3425e7a2..a6c15e353 100644 --- a/lib/crypto/atca_crypto_hw_aes_cmac.c +++ b/lib/crypto/atca_crypto_hw_aes_cmac.c @@ -92,7 +92,7 @@ ATCA_STATUS atcab_aes_cmac_init(atca_aes_cmac_ctx_t* ctx, uint16_t key_id, uint8 ATCA_STATUS atcab_aes_cmac_update(atca_aes_cmac_ctx_t* ctx, const uint8_t* data, uint32_t data_size) { uint32_t rem_size; - uint32_t copy_size; + size_t copy_size; ATCA_STATUS status = ATCA_SUCCESS; uint8_t ciphertext[ATCA_AES128_BLOCK_SIZE]; uint32_t block_count; @@ -104,7 +104,7 @@ ATCA_STATUS atcab_aes_cmac_update(atca_aes_cmac_ctx_t* ctx, const uint8_t* data, } rem_size = ATCA_AES128_BLOCK_SIZE - ctx->block_size; - copy_size = data_size > rem_size ? rem_size : data_size; + copy_size = data_size > rem_size ? (size_t)rem_size : (size_t)data_size; memcpy(&ctx->block[ctx->block_size], data, copy_size); @@ -140,7 +140,7 @@ ATCA_STATUS atcab_aes_cmac_update(atca_aes_cmac_ctx_t* ctx, const uint8_t* data, // Save any remaining data ctx->block_size = data_size; - memcpy(ctx->block, &data[copy_size + block_count * ATCA_AES128_BLOCK_SIZE], ctx->block_size); + memcpy(ctx->block, &data[copy_size + block_count * ATCA_AES128_BLOCK_SIZE], (size_t)ctx->block_size); return ATCA_SUCCESS; } @@ -156,7 +156,7 @@ static void left_shift_one(uint8_t* data, size_t data_size) for (i = 0; i < data_size; i++) { - data[i] = data[i] << 1; + data[i] = (uint8_t)(data[i] << 1); if (i + 1 < data_size && data[i + 1] & 0x80) { data[i] |= 0x01; // Next byte has a bit that needs to be shifted into this one @@ -228,7 +228,7 @@ ATCA_STATUS atcab_aes_cmac_finish(atca_aes_cmac_ctx_t* ctx, uint8_t* cmac, uint3 return status; } - memcpy(cmac, cmac_full, cmac_size); + memcpy(cmac, cmac_full, (size_t)cmac_size); return ATCA_SUCCESS; } diff --git a/lib/crypto/atca_crypto_sw.h b/lib/crypto/atca_crypto_sw.h index 4c002abbb..8e92a98b1 100644 --- a/lib/crypto/atca_crypto_sw.h +++ b/lib/crypto/atca_crypto_sw.h @@ -90,7 +90,7 @@ typedef atca_evp_ctx atcac_pk_ctx; #include "wolfssl/wolfcrypt/error-crypt.h" #include "wolfssl/wolfcrypt/asn_public.h" #include "wolfssl/wolfcrypt/asn.h" -#include "wolfssl/wolfcrypt/ecc.h" +#include "wolfssl/wolfcrypt/random.h" typedef struct { @@ -110,6 +110,9 @@ typedef Cmac atcac_aes_cmac_ctx; typedef Hmac atcac_hmac_sha256_ctx; typedef atca_wc_ctx atcac_pk_ctx; +/* Some configurations end up with a circular definition the above have to be defined before include ecc.h (since ecc.h can call cryptoauthlib functions) */ +#include "wolfssl/wolfcrypt/ecc.h" + #else #ifndef ATCA_ENABLE_SHA1_IMPL #define ATCA_ENABLE_SHA1_IMPL 1 diff --git a/lib/crypto/hashes/sha2_routines.c b/lib/crypto/hashes/sha2_routines.c index 43f4deffc..aeae01558 100644 --- a/lib/crypto/hashes/sha2_routines.c +++ b/lib/crypto/hashes/sha2_routines.c @@ -170,7 +170,7 @@ void sw_sha256_update(sw_sha256_ctx* ctx, const uint8_t* msg, uint32_t msg_size) { uint32_t block_count; uint32_t rem_size = SHA256_BLOCK_SIZE - ctx->block_size; - uint32_t copy_size = msg_size > rem_size ? rem_size : msg_size; + size_t copy_size = msg_size > rem_size ? (size_t)rem_size : (size_t)msg_size; // Copy data into current block memcpy(&ctx->block[ctx->block_size], msg, copy_size); @@ -193,7 +193,7 @@ void sw_sha256_update(sw_sha256_ctx* ctx, const uint8_t* msg, uint32_t msg_size) // Save any remaining data ctx->total_msg_size += (block_count + 1) * SHA256_BLOCK_SIZE; ctx->block_size = msg_size % SHA256_BLOCK_SIZE; - memcpy(ctx->block, &msg[copy_size + block_count * SHA256_BLOCK_SIZE], ctx->block_size); + memcpy(ctx->block, &msg[copy_size + block_count * SHA256_BLOCK_SIZE], (size_t)ctx->block_size); } @@ -203,7 +203,7 @@ void sw_sha256_update(sw_sha256_ctx* ctx, const uint8_t* msg, uint32_t msg_size) */ void sw_sha256_final(sw_sha256_ctx* ctx, uint8_t digest[SHA256_DIGEST_SIZE]) { - int i, j; + int32_t i, j; uint32_t msg_size_bits; uint32_t pad_zero_count; @@ -218,7 +218,7 @@ void sw_sha256_final(sw_sha256_ctx* ctx, uint8_t digest[SHA256_DIGEST_SIZE]) ctx->block[ctx->block_size++] = 0x80; // Add padding zeros plus upper 4 bytes of total msg size in bits (only supporting 32bit message bit counts) - memset(&ctx->block[ctx->block_size], 0, pad_zero_count + 4); + memset(&ctx->block[ctx->block_size], 0, (size_t)pad_zero_count + 4); ctx->block_size += pad_zero_count + 4; // Add the total message size in bits to the end of the current block. Technically this is diff --git a/lib/crypto/hashes/sha2_routines.h b/lib/crypto/hashes/sha2_routines.h index b01460603..09a036b84 100644 --- a/lib/crypto/hashes/sha2_routines.h +++ b/lib/crypto/hashes/sha2_routines.h @@ -30,8 +30,13 @@ #include +#ifndef SHA256_DIGEST_SIZE #define SHA256_DIGEST_SIZE (32) +#endif + +#ifndef SHA256_BLOCK_SIZE #define SHA256_BLOCK_SIZE (64) +#endif #ifdef __cplusplus extern "C" { diff --git a/lib/hal/atca_hal.c b/lib/hal/atca_hal.c index 790161896..d7fa1ef39 100644 --- a/lib/hal/atca_hal.c +++ b/lib/hal/atca_hal.c @@ -61,6 +61,17 @@ static ATCAHAL_t hal_swi_uart = { }; #endif +#if defined(ATCA_HAL_SWI_GPIO) || defined(ATCA_HAL_SWI_BB) +static ATCAHAL_t hal_swi_gpio = { + hal_swi_gpio_init, + hal_swi_gpio_post_init, + hal_swi_gpio_send, + hal_swi_gpio_receive, + hal_swi_gpio_control, + hal_swi_gpio_release +}; +#endif + #if defined(ATCA_HAL_UART) || defined(ATCA_HAL_SWI_UART) || defined(ATCA_HAL_KIT_UART) static ATCAHAL_t hal_uart = { hal_uart_init, @@ -83,15 +94,13 @@ static ATCAHAL_t hal_spi = { }; #endif -#ifdef ATCA_HAL_GPIO +#if defined(ATCA_HAL_GPIO) || defined(ATCA_HAL_BB) static ATCAHAL_t hal_gpio = { hal_gpio_init, hal_gpio_post_init, - hal_gpio_send, - hal_gpio_receive, - hal_gpio_wake, - hal_gpio_idle, - hal_gpio_sleep, + hal_gpio_send, /* Set IO State */ + hal_gpio_receive, /* Read IO State */ + hal_gpio_control, hal_gpio_release }; #endif @@ -146,27 +155,27 @@ typedef struct static atca_hal_list_entry_t atca_registered_hal_list[ATCA_MAX_HAL_CACHE] = { #ifdef ATCA_HAL_I2C - { ATCA_I2C_IFACE, &hal_i2c, NULL }, + { ATCA_I2C_IFACE, &hal_i2c, NULL }, #endif #ifdef ATCA_HAL_SWI_UART - { ATCA_SWI_IFACE, &hal_swi_uart, &hal_uart }, + { ATCA_SWI_IFACE, &hal_swi_uart, &hal_uart }, #endif #ifdef ATCA_HAL_KIT_UART - { ATCA_UART_IFACE, &hal_kit_v1, &hal_uart }, + { ATCA_UART_IFACE, &hal_kit_v1, &hal_uart }, #elif defined(ATCA_HAL_UART) - { ATCA_UART_IFACE, &hal_uart, NULL }, + { ATCA_UART_IFACE, &hal_uart, NULL }, #endif #ifdef ATCA_HAL_SPI - { ATCA_SPI_IFACE, &hal_spi, NULL }, + { ATCA_SPI_IFACE, &hal_spi, NULL }, #endif #ifdef ATCA_HAL_KIT_HID - { ATCA_HID_IFACE, &hal_kit_v1, &hal_hid }, + { ATCA_HID_IFACE, &hal_kit_v1, &hal_hid }, #endif #ifdef ATCA_HAL_KIT_BRIDGE - { ATCA_KIT_IFACE, &hal_kit_bridge, NULL }, + { ATCA_KIT_IFACE, &hal_kit_bridge, NULL }, #endif -#if ATCA_HAL_SWI_GPIO - { ATCA_SWI_GPIO_IFACE, &hal_gpio, NULL }, +#if defined(ATCA_HAL_SWI_GPIO) || defined(ATCA_HAL_SWI_BB) + { ATCA_SWI_GPIO_IFACE, &hal_swi_gpio, &hal_gpio }, #endif }; @@ -332,8 +341,20 @@ ATCA_STATUS hal_iface_release(ATCAIfaceType iface_type, void *hal_data) if (ATCA_SUCCESS == status) { - status = hal->halrelease ? hal->halrelease(hal_data) : ATCA_BAD_PARAM; - status = phy->halrelease ? phy->halrelease(hal_data) : ATCA_BAD_PARAM; + if (hal && hal->halrelease) + { + status = hal->halrelease(hal_data); + } + + if (phy && phy->halrelease) + { + ATCA_STATUS phy_status = phy->halrelease(hal_data); + + if (ATCA_SUCCESS == status) + { + status = phy_status; + } + } } return status; diff --git a/lib/hal/atca_hal.h b/lib/hal/atca_hal.h index 654a2434a..999925695 100644 --- a/lib/hal/atca_hal.h +++ b/lib/hal/atca_hal.h @@ -90,17 +90,22 @@ ATCA_STATUS hal_swi_sleep(ATCAIface iface); ATCA_STATUS hal_swi_release(void *hal_data); #endif +#if defined(ATCA_HAL_SWI_GPIO) || defined(ATCA_HAL_SWI_BB) +ATCA_STATUS hal_swi_gpio_init(ATCAIface iface, ATCAIfaceCfg *cfg); +ATCA_STATUS hal_swi_gpio_post_init(ATCAIface iface); +ATCA_STATUS hal_swi_gpio_send(ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength); +ATCA_STATUS hal_swi_gpio_receive(ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxlength); +ATCA_STATUS hal_swi_gpio_release(void *hal_data); +ATCA_STATUS hal_swi_gpio_control(ATCAIface iface, uint8_t option, void* param, size_t paramlen); +#endif -#if defined(ATCA_HAL_1WIRE) || defined(ATCA_HAL_SWI) -ATCA_STATUS hal_gpio_init(void *hal, ATCAIfaceCfg* cfg); +#if defined(ATCA_HAL_GPIO) || defined(ATCA_HAL_BB) +ATCA_STATUS hal_gpio_init(ATCAIface iface, ATCAIfaceCfg *cfg); ATCA_STATUS hal_gpio_post_init(ATCAIface iface); -ATCA_STATUS hal_gpio_send(ATCAIface iface, uint8_t word_address, uint8_t* txdata, int txlength); -ATCA_STATUS hal_gpio_receive(ATCAIface iface, uint8_t word_address, uint8_t* rxdata, uint16_t* rxlength); -ATCA_STATUS hal_gpio_idle(ATCAIface iface); -ATCA_STATUS hal_gpio_sleep(ATCAIface iface); -ATCA_STATUS hal_gpio_wake(ATCAIface iface); +ATCA_STATUS hal_gpio_send(ATCAIface iface, uint8_t word_address, uint8_t* pin_state, int unused_param); +ATCA_STATUS hal_gpio_receive(ATCAIface iface, uint8_t word_address, uint8_t* pin_state, uint16_t* unused_param); ATCA_STATUS hal_gpio_release(void *hal_data); -ATCA_STATUS hal_gpio_device_discovery(ATCAIface iface); +ATCA_STATUS hal_gpio_control(ATCAIface iface, uint8_t option, void* param, size_t paramlen); #endif #if defined(ATCA_HAL_SWI_UART) || defined(ATCA_HAL_KIT_UART) || defined(ATCA_HAL_UART) @@ -176,7 +181,8 @@ typedef enum ATCA_HAL_CONTROL_SELECT = 4, ATCA_HAL_CONTROL_DESELECT = 5, ATCA_HAL_CHANGE_BAUD = 6, - ATCA_HAL_FLUSH_BUFFER = 7 + ATCA_HAL_FLUSH_BUFFER = 7, + ATCA_HAL_CONTROL_DIRECTION = 8 } ATCA_HAL_CONTROL; /** \brief Timer API for legacy implementations */ diff --git a/lib/hal/hal_gpio_harmony.c b/lib/hal/hal_gpio_harmony.c index 3ea40e197..58a58c693 100644 --- a/lib/hal/hal_gpio_harmony.c +++ b/lib/hal/hal_gpio_harmony.c @@ -1,6 +1,6 @@ /** * \file - * \brief ATCA Hardware abstraction layer for 1WIRE or SWI over GPIO. + * \brief ATCA Hardware abstraction layer for GPIO * * \copyright (c) 2015-2020 Microchip Technology Inc. and its subsidiaries. * @@ -25,56 +25,21 @@ * THIS SOFTWARE. */ -#include "hal_gpio_harmony.h" +#include "atca_hal.h" -static ATCA_STATUS gpio_receive_bytes(ATCAIfaceCfg *cfg, uint8_t *rxdata, uint16_t rxlength); -static ATCA_STATUS gpio_send_bytes(ATCAIfaceCfg *cfg, uint8_t *txdata, uint16_t txlength); -static ATCA_STATUS send_logic_bit(ATCAIfaceCfg *cfg, bool bit_value); -#ifdef ATCA_HAL_1WIRE -static ATCA_STATUS start_stop_cond_1wire(ATCAIfaceCfg *cfg); -static ATCA_STATUS read_data_ACK_1wire(ATCAIfaceCfg *cfg, bool* bit_value); -static ATCA_STATUS device_discovery_1wire(ATCAIfaceCfg *cfg); -static ATCA_STATUS generate_wake_condition(ATCAIfaceCfg *cfg); -static ATCA_STATUS check_wake_1wire(ATCAIfaceCfg *cfg); -static uint8_t get_slave_addr_1wire(uint8_t dev_addr, uint8_t oper); -static ATCA_STATUS read_logic_bit_1wire(ATCAIfaceCfg *cfg, bool *bit_value); -#endif - -#ifdef ATCA_HAL_SWI -static ATCA_STATUS read_logic_bit_swi(ATCAIfaceCfg *cfg, bool *bit_value); -static ATCA_STATUS check_wake_swi(ATCAIfaceCfg *cfg); -#endif - -/** \brief initialize an GPIO interface using given config - * \param[in] cfg - interface configuration +/** + * \brief Initialize a gpio interface using given config. + * * \return ATCA_SUCCESS on success, otherwise an error code. */ -ATCA_STATUS hal_gpio_init(void *hal, ATCAIfaceCfg *cfg) +ATCA_STATUS hal_gpio_init(ATCAIface iface, ATCAIfaceCfg *cfg) { - ATCA_STATUS status = ATCA_BAD_PARAM; - atca_plib_gpio_api_t* plib; - - if (cfg) - { - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - - if (plib) - { - /* GPIO direction as output */ - plib->pin_setup(cfg->atcaswi.bus, ATCA_GPIO_OUTPUT_DIR); - /* by default, driving high */ - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - status = ATCA_SUCCESS; - } - } - return status; + return ATCA_SUCCESS; } /** - * \brief HAL implementation of GPIO post init. - * - * \param[in] iface ATCAIface instance + * \brief Post Init for gpio hal * * \return ATCA_SUCCESS */ @@ -83,706 +48,87 @@ ATCA_STATUS hal_gpio_post_init(ATCAIface iface) return ATCA_SUCCESS; } -/** \brief Discovery Response sequence is used by the master to perform a general - bus call to determine if a device is present on the bus - * \param[in] iface Device to interact with. - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_gpio_device_discovery(ATCAIface iface) -{ - ATCA_STATUS status = ATCA_BAD_PARAM; - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - atca_plib_gpio_api_t* plib; - - if (cfg) - { - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib) - { - status = ATCA_UNIMPLEMENTED; - if (cfg->devtype == ATECC204A) - { - #ifdef ATCA_HAL_1WIRE - status = device_discovery_1wire(cfg); - #endif - } - } - } - - return status; -} - -/** \brief HAL implementation of bit banging send over Harmony - * \param[in] iface instance - * \param[in] word_address device transaction type - * \param[in] txdata pointer to space to bytes to send - * \param[in] txlength number of bytes to send - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_gpio_send(ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - ATCA_STATUS status = ATCA_BAD_PARAM; - - #ifdef ATCA_HAL_1WIRE - uint8_t dev_write_addr; - #endif - - if (!cfg) - { - return status; - } - - if (cfg->devtype == ATECC204A) - { - #ifdef ATCA_HAL_1WIRE - if (ATCA_SUCCESS == (status = start_stop_cond_1wire(cfg))) - { - dev_write_addr = get_slave_addr_1wire(cfg->atcaswi.slave_address, ATCA_GPIO_WRITE); - if (ATCA_SUCCESS == (status = gpio_send_bytes(cfg, &dev_write_addr, sizeof(dev_write_addr)))) - { - if (ATCA_SUCCESS == (status = gpio_send_bytes(cfg, &word_address, sizeof(word_address)))) - { - status = gpio_send_bytes(cfg, txdata, txlength); - } - } - status = start_stop_cond_1wire(cfg); - } - #endif - } - else - { - #ifdef ATCA_HAL_SWI - if (ATCA_SUCCESS == (status = gpio_send_bytes(cfg, &word_address, sizeof(word_address)))) - { - status = gpio_send_bytes(cfg, txdata, txlength); - } - #endif - } - - return status; -} - -/** \brief HAL implementation of bit banging receive from HARMONY - * \param[in] iface Device to interact with. - * \param[in] word_address device transaction type - * \param[out] rxdata Data received will be returned here. - * \param[in,out] rxlength As input, the size of the rxdata buffer. - * As output, the number of bytes received. - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_gpio_receive(ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxlength) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - ATCA_STATUS status; - int retries; - - if ((NULL == cfg) || (NULL == rxlength) || (NULL == rxdata)) - { - return ATCA_BAD_PARAM; - } - - if (cfg->devtype == ATECC204A) - { - #ifdef ATCA_HAL_1WIRE - word_address = get_slave_addr_1wire(cfg->atcaswi.slave_address, ATCA_GPIO_READ); - if (ATCA_SUCCESS != (status = start_stop_cond_1wire(cfg))) - { - return status; - } - #endif - } - else - { - word_address = ATCA_SWI_TX_WORD_ADDR; - } - - retries = cfg->rx_retries; - do - { - if (ATCA_SUCCESS == (status = gpio_send_bytes(cfg, &word_address, sizeof(word_address)))) - { - /* Reading response length byte */ - if (ATCA_SUCCESS == (status = gpio_receive_bytes(cfg, &rxdata[0], ATCA_1WIRE_RESPONSE_LENGTH_SIZE))) - { - #ifdef ATCA_HAL_1WIRE - if (cfg->devtype == ATECC204A) - { - (void)send_ACK_1wire(cfg); - } - #endif - if (rxdata[0] >= ATCA_MIN_RESPONSE_LENGTH) - { - if (*rxlength < rxdata[0]) - { - status = ATCA_TRACE(ATCA_SMALL_BUFFER, "rxdata is small buffer"); - break; - } - else - { - /* Reading remaining response */ - if (ATCA_SUCCESS == (status = gpio_receive_bytes(cfg, &rxdata[1], rxdata[0] - ATCA_1WIRE_RESPONSE_LENGTH_SIZE))) - { - #ifdef ATCA_HAL_1WIRE - if (cfg->devtype == ATECC204A) - { - (void)send_NACK_1wire(cfg); - } - #endif - *rxlength = rxdata[0]; - } - } - } - else - { - status = ATCA_TRACE(ATCA_COMM_FAIL, "invalid response length"); - } - } - } - } - while ((retries-- > 0) && (status == ATCA_COMM_FAIL)); - -#ifdef ATCA_HAL_1WIRE - status = start_stop_cond_1wire(cfg); -#endif - - return status; -} - -/** \brief Put the device in idle mode - * \param[in] iface interface to logical device to idle - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_gpio_idle(ATCAIface iface) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - - if (cfg) - { - if (cfg->devtype == ATECC204A) - { - return ATCA_SUCCESS; - } - else - { - return hal_gpio_send(iface, ATCA_SWI_IDLE_WORD_ADDR, NULL, 0); - } - } - - return ATCA_BAD_PARAM; -} - -/** \brief send sleep command - * \param[in] iface interface to logical device to sleep - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_gpio_sleep(ATCAIface iface) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - uint8_t word_address; - - if (cfg) - { - word_address = (cfg->devtype == ATECC204A) ? ATCA_1WIRE_SLEEP_WORD_ADDR : \ - ATCA_SWI_SLEEP_WORD_ADDR; - - return hal_gpio_send(iface, word_address, NULL, 0); - } - - return ATCA_BAD_PARAM; -} - -/** \brief send wake token - * \param[in] iface interface to logical device to wakeup - * \return ATCA_WAKE_SUCCESS on success, otherwise an error code. +/** + * \brief Set the state of the pin + * + * \return ATCA_SUCCESS */ -ATCA_STATUS hal_gpio_wake(ATCAIface iface) +ATCA_STATUS hal_gpio_send( + ATCAIface iface, /**< Interface context */ + uint8_t word_address, /**< Unused parameter */ + uint8_t* pin_state, /**< Pin state to output */ + int unused_param /**< Unused parameter */ + ) { - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - atca_plib_gpio_api_t* plib; - ATCA_STATUS status = ATCA_WAKE_FAILED; - - if (NULL == cfg) - { - return ATCA_BAD_PARAM; - } + (void)word_address; + (void)unused_param; + uint32_t pin_id = *(uint32_t*)atgetifacecfg(iface)->cfg_data; - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_BAD_PARAM; - } + PORT_PinWrite(pin_id, *pin_state); - if (cfg->devtype == ATECC204A) - { - #ifdef ATCA_HAL_1WIRE - status = check_wake_1wire(cfg); - #endif - } - else - { - #ifdef ATCA_HAL_SWI - (void)generate_wake_condition(cfg); - status = check_wake_swi(cfg); - #endif - } - - return status; -} - -/** \brief releases resource if no more communication - * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_gpio_release(void *hal_data) -{ return ATCA_SUCCESS; } -/** \brief Function to send the specified number of bytes through GPIO bit banging - * \param[in] cfg Driver interface configurations - * \param[in] txdata pointer pointing bytes to send - * \param[in] txlength number of bytes to send - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS gpio_send_bytes(ATCAIfaceCfg *cfg, uint8_t *txdata, uint16_t txlength) -{ - uint8_t bit_mask; - uint8_t count; - - #ifdef ATCA_HAL_1WIRE - bool bit_value; - #endif - protocol_type proto_type; - ATCA_STATUS status = ATCA_BAD_PARAM; - - if (txdata == NULL) - { - return status; - } - - proto_type = (cfg->devtype == ATECC204A) ? ATCA_PROTOCOL_1WIRE : ATCA_PROTOCOL_SWI; - /* Disabling interrupts */ - __disable_irq(); - for (count = 0; count < txlength; count++) - { - bit_mask = (cfg->devtype == ATECC204A) ? ATCA_1WIRE_BIT_MASK : ATCA_SWI_BIT_MASK; - while (bit_mask > 0) - { - /* if the next bit transmitted is a logic '1' */ - if (bit_mask & txdata[count]) - { - status = send_logic_bit(cfg, ATCA_GPIO_LOGIC_BIT1); - } - /* if the next bit transmitted is a logic '0' */ - else - { - status = send_logic_bit(cfg, ATCA_GPIO_LOGIC_BIT0); - } - - bit_mask = (proto_type == ATCA_PROTOCOL_1WIRE) ? bit_mask >> 1 : bit_mask << 1; - } - #ifdef ATCA_HAL_1WIRE - if ((status == ATCA_SUCCESS) && (proto_type == ATCA_PROTOCOL_1WIRE)) - { - (void)read_data_ACK_1wire(cfg, &bit_value); - /* check for ACK/NACK */ - if (bit_value) /* if a NAK is detected */ - { - /* device failed to send ACK */ - status = ATCA_COMM_FAIL; - break; - } - tRCV0_DLY; /* slave recovery time delay (same for logic'0' and logic '1') */ - } - #endif - } - /* Enabling interrupts */ - __enable_irq(); - - return status; -} - -/** \brief Function to send logic bit 1 or 0 over GPIO using 1WIRE - * \param[in] cfg Driver interface configurations - * \param[in] bit_value Logical bit value to be send +/** + * \brief Read the state of the pin + * * \return ATCA_SUCCESS on success, otherwise an error code. */ -static ATCA_STATUS send_logic_bit(ATCAIfaceCfg *cfg, bool bit_value) +ATCA_STATUS hal_gpio_receive( + ATCAIface iface, /**< Interface context */ + uint8_t word_address, /**< Unused parameter */ + uint8_t* pin_state, /**< Pin state to output */ + uint16_t* unused_param /**< Unused parameter */ + ) { - atca_plib_gpio_api_t* plib; - const uint8_t* timings; - const uint8_t logic1_swi_timings[] = { 4, 26 }; - const uint8_t logic1_1wire_timings[] = { 1, 41 }; - const uint8_t logic0_swi_timings[] = { 4, 34, 4, 4 }; - const uint8_t logic0_1wire_timings[] = { 11, 31 }; + (void)word_address; + (void)unused_param; + uint32_t pin_id = *(uint32_t*)atgetifacecfg(iface)->cfg_data; - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_BAD_PARAM; - } - - if (bit_value == ATCA_GPIO_LOGIC_BIT1) - { - timings = (cfg->devtype == ATECC204A) ? logic1_1wire_timings : logic1_swi_timings; - plib->write(cfg->atcaswi.bus, ATCA_GPIO_CLEAR); - atca_delay_us(*timings++); - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - atca_delay_us(*timings++); - } - else - { - timings = (cfg->devtype == ATECC204A) ? logic0_1wire_timings : logic0_swi_timings; - plib->write(cfg->atcaswi.bus, ATCA_GPIO_CLEAR); - atca_delay_us(*timings++); - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - atca_delay_us(*timings++); - #ifdef ATCA_HAL_SWI - if (cfg->devtype != ATECC204A) - { - plib->write(cfg->atcaswi.bus, ATCA_GPIO_CLEAR); - atca_delay_us(*timings++); - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - atca_delay_us(*timings++); - } - #endif - } + *pin_state = PORT_PinRead(pin_id); return ATCA_SUCCESS; } -/** \brief Function to receive the response bytes through GPIO bit banging - * \param[in] cfg Driver interface configurations - * \param[in] rxdata pointer pointing where received bytes to be stored - * \param[in] rxlength number of bytes to receive - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS gpio_receive_bytes(ATCAIfaceCfg *cfg, uint8_t *rxdata, uint16_t rxlength) +ATCA_STATUS hal_gpio_control(ATCAIface iface, uint8_t option, void* param, size_t paramlen) { - uint8_t bit_mask; - uint8_t count; - atca_plib_gpio_api_t* plib; - protocol_type proto_type; - bool bit_value = 1; - - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if ((plib == NULL) || (rxdata == NULL)) - { - return ATCA_BAD_PARAM; - } - - proto_type = (cfg->devtype == ATECC204A) ? ATCA_PROTOCOL_1WIRE : ATCA_PROTOCOL_SWI; + (void)paramlen; - __disable_irq(); - for (count = 0; count < rxlength; count++) + if (iface && iface->mIfaceCFG) { - bit_mask = (cfg->devtype == ATECC204A) ? ATCA_1WIRE_BIT_MASK : ATCA_SWI_BIT_MASK; - while (bit_mask >= 1) + switch (option) { - #ifdef ATCA_HAL_1WIRE - if (proto_type == ATCA_PROTOCOL_1WIRE) - { - plib->write(cfg->atcaswi.bus, ATCA_GPIO_CLEAR); - /* device is set for high-speed communication */ - tHIGH_SPEED_DLY; - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - tSWIN_DLY; /* delay to put master read inside the master sampling window */ - (void)read_logic_bit_1wire(cfg, &bit_value); - } - #endif + case ATCA_HAL_CONTROL_DIRECTION: + { + uint8_t pin_dir = *(uint8_t*)param; + uint32_t pin_id = *(uint32_t*)atgetifacecfg(iface)->cfg_data; - #ifdef ATCA_HAL_SWI - if (proto_type == ATCA_PROTOCOL_SWI) - { - (void)read_logic_bit_swi(cfg, &bit_value); - } - #endif - if (bit_value) /* if a logic '1' is detected; received "one" bit */ + if (pin_dir == 0) { - rxdata[count] |= bit_mask; - } - if (proto_type == ATCA_PROTOCOL_1WIRE) - { - tBIT_DLY;//bit frame duration (tBIT) before reading the next bit - bit_mask >>= 1; + PORT_PinInputEnable(pin_id); } else { - bit_mask <<= 1; + PORT_PinOutputEnable(pin_id); } } - #ifdef ATCA_HAL_1WIRE - /* send ACK except for last byte of read --> GO TO send_ACK() */ - if ((count < (rxlength - 1)) && (proto_type == ATCA_PROTOCOL_1WIRE)) - { - (void)send_ACK_1wire(cfg); + return ATCA_SUCCESS; + default: + return ATCA_UNIMPLEMENTED; } - #endif - } - __enable_irq(); - - return ATCA_SUCCESS; -} - -#ifdef ATCA_HAL_1WIRE -/** \brief Function to generate start or stop condition - * \param[in] cfg Driver interface configurations - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS start_stop_cond_1wire(ATCAIfaceCfg *cfg) -{ - atca_plib_gpio_api_t* plib; - - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib) - { - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - tHTSS_DLY; - return ATCA_SUCCESS; } - return ATCA_BAD_PARAM; } -/** \brief Function to read the data ACK for the transmitted byte - * \param[in] cfg Driver interface configurations - * \param[in] bit_value Contains logical bit value(ACK or NACK) to be received - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS read_data_ACK_1wire(ATCAIfaceCfg *cfg, bool *bit_value) -{ - atca_plib_gpio_api_t* plib; - ATCA_STATUS status = ATCA_BAD_PARAM; - - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - - if (plib) - { - /* this checks for an ACK or NACK from device */ - plib->write(cfg->atcaswi.bus, ATCA_GPIO_CLEAR); - tRD_DLY; - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - tLOW1_DLY; - - status = read_logic_bit_1wire(cfg, bit_value); - } - - return status; -} - -/** \brief Function to discover the available devices in the bus - * \param[in] cfg Driver interface configurations - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS device_discovery_1wire(ATCAIfaceCfg *cfg) -{ - atca_plib_gpio_api_t* plib; - bool bit_value; - ATCA_STATUS status = ATCA_BAD_PARAM; - - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib) - { - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - tRRT_DLY; - plib->write(cfg->atcaswi.bus, ATCA_GPIO_CLEAR); - tDRR_DLY; - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - tDACK_DLY; - - (void)read_logic_bit_1wire(cfg, &bit_value); - status = (bit_value == ((bool)ATCA_GPIO_ACK)) ? ATCA_SUCCESS : ATCA_NO_DEVICES; - } - - return status; -} - -/** \brief Function to generate wake condition - * \param[in] cfg Driver interface configurations - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS generate_wake_condition(ATCAIfaceCfg *cfg) -{ - atca_plib_gpio_api_t* plib; - - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib) - { - plib->write(cfg->atcaswi.bus, ATCA_GPIO_CLEAR); - atca_delay_us(60); - plib->write(cfg->atcaswi.bus, ATCA_GPIO_SET); - atca_delay_us(cfg->wake_delay); - return ATCA_SUCCESS; - } - return ATCA_BAD_PARAM; -} - -/** \brief Function to check wake condition for 1WIRE - * \param[in] cfg Driver interface configurations - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS check_wake_1wire(ATCAIfaceCfg *cfg) -{ - ATCA_STATUS status; - uint8_t dev_addr; - - status = device_discovery_1wire(cfg); - if (status == ATCA_NO_DEVICES) - { - (void)generate_wake_condition(cfg); - status = start_stop_cond_1wire(cfg); - dev_addr = get_slave_addr_1wire(cfg->atcaswi.slave_address, ATCA_GPIO_WRITE); - status = gpio_send_bytes(cfg, &dev_addr, sizeof(dev_addr)); - (void)start_stop_cond_1wire(cfg); - } - - return status; -} - -/** \brief Function to read the data ACK for the transmitted byte - * \param[in] dev_addr 7 bit device address - * \param[in] oper indicates read or write operation - * \return 8 bit device address for write or read operation - */ -static uint8_t get_slave_addr_1wire(uint8_t dev_addr, uint8_t oper) -{ - return (dev_addr << 1) | oper; -} - -/** \brief Function to read the logic bit 1 or 0 - * \param[in] cfg Driver interface configurations - * \param[in] bit_value Contains hogical bit value to be received - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS read_logic_bit_1wire(ATCAIfaceCfg *cfg, bool *bit_value) -{ - atca_plib_gpio_api_t* plib; - - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib) - { - /* Changing the PIN direction as Input */ - plib->pin_setup(cfg->atcaswi.bus, ATCA_GPIO_INPUT_DIR); - *bit_value = plib->read(cfg->atcaswi.bus); - /* Changing the PIN direction as Output */ - plib->pin_setup(cfg->atcaswi.bus, ATCA_GPIO_OUTPUT_DIR); - return ATCA_SUCCESS; - } - - return ATCA_BAD_PARAM; -} -#endif /* End of ATCA_HAL_1WIRE */ - -#ifdef ATCA_HAL_SWI -/** \brief Function to read the logic bit 1 or 0 - * \param[in] cfg Driver interface configurations - * \param[in] bit_value Contains logical bit value to be received - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS read_logic_bit_swi(ATCAIfaceCfg *cfg, bool *bit_value) -{ - atca_plib_gpio_api_t* plib; - int8_t timeout_count; - bool current_state = true, prev_state = true; - uint8_t bit_count = 0; - ATCA_STATUS status = ATCA_BAD_PARAM; - - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return status; - } - - do - { - //wait for start bit - timeout_count = 90 / 2; - while (timeout_count-- >= 0) - { - current_state = plib->read(cfg->atcaswi.bus); - if (current_state != prev_state) - { - prev_state = current_state; - if (!current_state) - { - break; - } - - } - atca_delay_us(2); - } - - if (timeout_count <= 0) - { - status = ATCA_TRACE(ATCA_RX_NO_RESPONSE, "No response is received"); - break; - } - - //Read bit - timeout_count = 40 / 2; - while (timeout_count-- >= 0) - { - current_state = plib->read(cfg->atcaswi.bus); - if (current_state != prev_state) - { - prev_state = current_state; - if (current_state) - { - bit_count++; - } - - } - atca_delay_us(2); - } - - if (bit_count == 2) - { - *bit_value = 0; - } - else if (bit_count == 1) - { - *bit_value = 1; - } - else - { - status = ATCA_TRACE(ATCA_RX_FAIL, "Rx Receive - failed"); - } - } - while (0); - - return status; -} - -/** \brief Function to check wake condition for SWI - * \param[in] cfg Driver interface configurations - * \return ATCA_SUCCESS on success, otherwise an error code. +/** + * \brief Release and clean up the HAL + * + * \param[in] hal_data opaque pointer to hal data structure - known only + * to the HAL implementation + * + * \return ATCA_SUCCESS */ -static ATCA_STATUS check_wake_swi(ATCAIfaceCfg *cfg) +ATCA_STATUS hal_gpio_release(void *hal_data) { - atca_plib_gpio_api_t* plib; - uint8_t data[4] = { 0x00, 0x00, 0x00, 0x00 }; - uint16_t rxlength = sizeof(data); - const uint8_t expected_response[4] = { 0x04, 0x11, 0x33, 0x43 }; - const uint8_t selftest_fail_resp[4] = { 0x04, 0x07, 0xC4, 0x40 }; - - plib = (atca_plib_gpio_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_BAD_PARAM; - } - - if (gpio_receive_bytes(cfg, data, rxlength) == ATCA_SUCCESS) - { - if (memcmp(data, expected_response, 4) == 0) - { - return ATCA_SUCCESS; - } - if (memcmp(data, selftest_fail_resp, 4) == 0) - { - return ATCA_STATUS_SELFTEST_ERROR; - } - } - return ATCA_WAKE_FAILED; + return ATCA_SUCCESS; } -#endif /* ATCA_HAL_SWI */ diff --git a/lib/hal/hal_linux_uart_userspace.c b/lib/hal/hal_linux_uart_userspace.c index 0033dd9c1..3b7afe30b 100644 --- a/lib/hal/hal_linux_uart_userspace.c +++ b/lib/hal/hal_linux_uart_userspace.c @@ -35,36 +35,105 @@ typedef struct atca_uart_host_s { - char uart_file[20]; - int fd_uart; - int uart_baud; - int uart_wordsize; - uint8_t uart_parity; - uint8_t uart_stopbit; - int ref_ct; + char uart_file[20]; + int fd_uart; + int ref_ct; } atca_uart_host_t; +/** + * \brief Convert an numerical value for baud rate into the posix/linux values + * \return baudrate macro value + */ +static speed_t hal_uart_convert_baudrate(uint32_t baudrate) +{ + switch (baudrate) + { + case 0: + return B0; + case 4800: + return B4800; + case 9600: + return B9600; + case 115200: + return B115200; + case 230400: + return B230400; + default: + return B115200; + } +} + +/** + * \brief Convert integer wordsize into posix/linux flags + * \return flag value + */ +static inline tcflag_t hal_uart_convert_wordsize(uint8_t wordsize) +{ + switch (wordsize) + { + case 5: + return CS5; + case 6: + return CS6; + case 7: + return CS7; + default: + return CS8; + } +} + +/** + * \brief Set baudrate default is 115200. + * + * \param[in] baudrate contain new baudrate + * + * \return true on success, otherwise false. + */ +static ATCA_STATUS hal_uart_set_baudrate(ATCAIface iface, uint32_t baudrate) +{ + atca_uart_host_t * hal_data = (atca_uart_host_t*)atgetifacehaldat(iface); + + if (hal_data && hal_data->fd_uart) + { + struct termios tty; + speed_t rate; + + /* Get existing device attributes */ + tcgetattr(hal_data->fd_uart, &tty); + + rate = hal_uart_convert_baudrate(baudrate); + + cfsetispeed(&tty, rate); + cfsetospeed(&tty, rate); + + /* Update settings */ + tcsetattr(hal_data->fd_uart, TCSANOW, &tty); + } + return ATCA_SUCCESS; +} + /** \brief Open and configure serial COM Uart * \param[out] fd resulting file descriptor * * \return ATCA_SUCCESS on success, else an error code */ -ATCA_STATUS hal_uart_open_file(atca_uart_host_t * hal_data) +static ATCA_STATUS hal_uart_open_file(atca_uart_host_t * hal_data, ATCAIfaceCfg *cfg) { ATCA_STATUS status = ATCA_BAD_PARAM; if (hal_data) { - struct termios tty; - hal_data->fd_uart = open(hal_data->uart_file, O_RDWR | O_NOCTTY); if (0 < hal_data->fd_uart) { + struct termios tty; + speed_t rate; + /* Get existing device attributes */ tcgetattr(hal_data->fd_uart, &tty); - /* Raw Mode */ + /* Raw Mode (non-canonical, no echo, etc) */ tty.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /* No flow control */ @@ -73,29 +142,48 @@ ATCA_STATUS hal_uart_open_file(atca_uart_host_t * hal_data) /* No output translation */ tty.c_oflag &= ~OPOST; - //Enable read timeout + /* Enable read timeout */ tty.c_cc[VTIME] = 5; - cfsetispeed(&tty, hal_data->uart_baud); - cfsetospeed(&tty, hal_data->uart_baud); + /* Convert baudrate to posix/linux format */ + rate = hal_uart_convert_baudrate(cfg->atcauart.baud); + cfsetispeed(&tty, rate); + cfsetospeed(&tty, rate); - // set number of stopbits - if (1 < hal_data->uart_stopbit) + /* set number of stopbits */ + if (1 < cfg->atcauart.stopbits) { + /* Two stop bits */ tty.c_cflag |= CSTOPB; } + else + { + /* One Stop Bit */ + tty.c_cflag &= ~CSTOPB; + } - // set parity bits - if (0 == hal_data->uart_parity) // even parity + /* Set the transmission word size */ + tty.c_cflag &= ~CSIZE; + tty.c_cflag |= hal_uart_convert_wordsize(cfg->atcauart.wordsize); + + if (0 == cfg->atcauart.parity) { + /* Set Even Parity */ tty.c_cflag |= PARENB; + tty.c_cflag &= ~PARODD; } - else if (1 == hal_data->uart_parity) // odd parity + else if (1 == cfg->atcauart.parity) { - tty.c_cflag |= PARENB; - tty.c_cflag |= PARODD; + /* Set Odd Parity */ + tty.c_cflag |= (PARENB | PARODD); + } + else + { + /* Disable Parity */ + tty.c_cflag &= ~PARENB; } + /* Configure the port with the configured settings immediately */ if (tcsetattr(hal_data->fd_uart, TCSANOW, &tty)) { close(hal_data->fd_uart); @@ -147,30 +235,9 @@ ATCA_STATUS hal_uart_init(ATCAIface iface, ATCAIfaceCfg *cfg) "/dev/ttyS%d", (uint8_t)cfg->atcauart.port); } - // Set linux uart baudrate mask - switch (cfg->atcauart.baud) - { - case 0: hal_data->uart_baud = B0; break; - case 4800: hal_data->uart_baud = B4800; break; - case 9600: hal_data->uart_baud = B9600; break; - case 115200: hal_data->uart_baud = B115200; break; - default: hal_data->uart_baud = B115200; break; - } - // set linux uart character size - switch (cfg->atcauart.wordsize) - { - case 5: hal_data->uart_wordsize = CS5; break; - case 6: hal_data->uart_wordsize = CS6; break; - case 7: hal_data->uart_wordsize = CS7; break; - case 8: hal_data->uart_wordsize = CS8; break; - default: hal_data->uart_wordsize = CS8; break; - } - - hal_data->uart_parity = iface->mIfaceCFG->atcauart.parity; - hal_data->uart_stopbit = iface->mIfaceCFG->atcauart.stopbits; iface->hal_data = hal_data; - if (ATCA_SUCCESS == (status = hal_uart_open_file(hal_data))) + if (ATCA_SUCCESS == (status = hal_uart_open_file(hal_data, cfg))) { hal_data->ref_ct = 1; } @@ -304,8 +371,20 @@ ATCA_STATUS hal_uart_control(ATCAIface iface, uint8_t option, void* param, size_ if (iface && iface->mIfaceCFG) { - /* This HAL does not support any of the control functions */ - return ATCA_UNIMPLEMENTED; + switch (option) + { + case ATCA_HAL_CHANGE_BAUD: + return hal_uart_set_baudrate(iface, *(uint32_t*)param); + case ATCA_HAL_FLUSH_BUFFER: + /* Using non-canonical mode so there should be no buffering */ + return ATCA_SUCCESS; + case ATCA_HAL_CONTROL_SELECT: + /* fallthrough */ + case ATCA_HAL_CONTROL_DESELECT: + return ATCA_SUCCESS; + default: + return ATCA_UNIMPLEMENTED; + } } return ATCA_BAD_PARAM; } diff --git a/lib/hal/hal_swi_bitbang_harmony.c b/lib/hal/hal_swi_bitbang_harmony.c deleted file mode 100644 index 606c62da5..000000000 --- a/lib/hal/hal_swi_bitbang_harmony.c +++ /dev/null @@ -1,588 +0,0 @@ -/** - * \file - * \brief ATCA Hardware abstraction layer for SWI bit banging. - * - * \copyright (c) 2015-2018 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 "atca_config.h" - -/** - * \defgroup hal_ Hardware abstraction layer (hal_) - * - * \brief These methods define the hardware abstraction layer for - * communicating with a CryptoAuth device using SWI bit banging. - @{ */ - -/** \brief discover swi buses available for this hardware - * this maintains a list of logical to physical bus mappings freeing the application.This function is currently not supported. - * of the a-priori knowledge - * \param[in] swi_buses - an array of logical bus numbers - * \param[in] max_buses - maximum number of buses the app wants to attempt to discover - * \return ATCA_UNIMPLEMENTED - */ -ATCA_STATUS hal_swi_discover_buses(int swi_buses[], int max_buses) -{ - return ATCA_UNIMPLEMENTED; -} - -/** \brief discover any CryptoAuth devices on a given logical bus number.This function is curently not supported. - * \param[in] bus_num - logical bus number on which to look for CryptoAuth devices - * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method - * \param[out] *found - number of devices found on this bus - * \return ATCA_UNIMPLEMENTED - */ -ATCA_STATUS hal_swi_discover_devices(int bus_num, ATCAIfaceCfg cfg[], int *found) -{ - return ATCA_UNIMPLEMENTED; -} - -/** - * \brief Send a Wake Token. - */ -static ATCA_STATUS swi_send_wake_token(atca_plib_swi_bb_api_t* plib, uint8_t pin) -{ - ATCA_STATUS status = ATCA_BAD_PARAM; - - if (plib) - { -#ifdef __arm__ - __disable_irq(); -#else - __builtin_disable_interrupts(); -#endif - - plib->write(pin, false); - atca_delay_us(60); - plib->write(pin, true); - status = ATCA_SUCCESS; - -#ifdef __arm__ - __enable_irq(); -#else - __builtin_enable_interrupts(); -#endif - } - - return status; -} - -/** - * \brief Send a number of bytes.This function should not be called directly ,instead should use hal_swi_send() which call this function. - * - * \param[in] count number of bytes to send. - * \param[in] buffer pointer to buffer containing bytes to send - */ -static ATCA_STATUS swi_send_bytes(atca_plib_swi_bb_api_t* plib, uint8_t pin, uint8_t count, - uint8_t *buffer) -{ - uint8_t i, bit_mask; - - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - //set port direction to output - plib->set_pin_output_dir(pin); - -#ifdef __arm__ - __disable_irq(); -#else - __builtin_disable_interrupts(); -#endif - for (i = 0; i < count; i++) - { - for (bit_mask = 1; bit_mask > 0; bit_mask <<= 1) - { - if (bit_mask & buffer[i]) //!< Send Logic 1 (7F) - { - plib->write(pin, false); - BIT_DELAY_1L; - plib->write(pin, true); - BIT_DELAY_7; - } - else //!< Send Logic 0 (7D) - { - plib->write(pin, false); - BIT_DELAY_1L; - plib->write(pin, true); - BIT_DELAY_1H; - plib->write(pin, false); - BIT_DELAY_1L; - plib->write(pin, true); - BIT_DELAY_5; - } - } - } -#ifdef __arm__ - __enable_irq(); -#else - __builtin_enable_interrupts(); -#endif - - return ATCA_SUCCESS; -} - -/** - * \brief Send one byte. - * - * \param[in] byte byte to send - */ -static ATCA_STATUS swi_send_byte(atca_plib_swi_bb_api_t* plib, uint8_t pin, uint8_t byte) -{ - return swi_send_bytes(plib, pin, 1, &byte); -} - -/** - * \brief Receive one bit as byte using SWI bitbang - * \param[in] bit_data byte equivalent of bit data on SWI - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS swi_receive_bit(atca_plib_swi_bb_api_t* plib, uint8_t pin, uint8_t *bit_data) -{ - int8_t timeout_count; - bool current_state = true, prev_state = true; - uint8_t bit_count = 0; - ATCA_STATUS status = ATCA_SUCCESS; - - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - do - { - //wait for start bit - timeout_count = 90 / 2; - while (timeout_count-- >= 0) - { - current_state = plib->read(pin); - if (current_state != prev_state) - { - prev_state = current_state; - if (!current_state) - { - break; - } - - } - atca_delay_us(2); - } - - if (timeout_count <= 0) - { - status = ATCA_TRACE(ATCA_RX_NO_RESPONSE, "No response is received"); - break; - } - - //Read bit - timeout_count = 40 / 2; - while (timeout_count-- >= 0) - { - current_state = plib->read(pin); - if (current_state != prev_state) - { - prev_state = current_state; - if (current_state) - { - bit_count++; - } - - } - atca_delay_us(2); - } - - if (bit_count == 2) - { - *bit_data = 0; - } - else if (bit_count == 1) - { - *bit_data = 1; - } - else - { - status = ATCA_TRACE(ATCA_RX_FAIL, "Rx Receive - failed"); - } - } - while (0); - - return status; -} - -/** - * \brief Receive a number of bytes.This function should not be called directly ,instead should use hal_swi_receive() which call this function. - * - * \param[in] count number of bytes to receive - * \param[out] buffer pointer to receive buffer - * - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -static ATCA_STATUS swi_receive_bytes(atca_plib_swi_bb_api_t* plib, uint8_t pin, uint8_t count, - uint8_t *buffer) -{ - ATCA_STATUS status = ATCA_SUCCESS; - uint8_t i; - uint8_t bit_mask, bit_data; - - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - //set port direction to input to receive response - plib->set_pin_input_dir(pin); - -#ifdef __arm__ - __disable_irq(); -#else - __builtin_disable_interrupts(); -#endif - //! Receive bits and store in buffer. - for (i = 0; i < count; i++) - { - *buffer = 0; - for (bit_mask = 1; bit_mask > 0; bit_mask <<= 1) - { - bit_data = 0; - if (ATCA_SUCCESS != (status = swi_receive_bit(plib, pin, &bit_data))) - { - break; - } - - - if (bit_data == 1) - { - *buffer |= bit_mask; - } - - } - - if (status != ATCA_SUCCESS) - { - break; - } - - - if (i == 0) - { - if (*buffer < ATCA_RSP_SIZE_MIN) - { - status = ATCA_TRACE(ATCA_RX_FAIL, "packet size is invalid"); - break; - } - else if (*buffer > count) - { - status = ATCA_TRACE(ATCA_SMALL_BUFFER, "rxdata is small buffer"); - break; - } - else - { - count = *buffer; - status = ATCA_SUCCESS; - } - } - buffer++; - } - -#ifdef __arm__ - __enable_irq(); -#else - __builtin_enable_interrupts(); -#endif - RX_TX_DELAY; - - return status; -} - -/** - * \brief hal_swi_init manages requests to initialize a physical - * interface. It manages use counts so when an interface has - * released the physical layer, it will disable the interface for - * some other use. You can have multiple ATCAIFace instances using - * the same bus, and you can have multiple ATCAIFace instances on - * multiple swi buses, so hal_swi_init manages these things and - * ATCAIFace is abstracted from the physical details. - */ - -/** - * \brief Initialize an SWI interface using given config. - * - * \param[in] hal opaque pointer to HAL data - * \param[in] cfg interface configuration - * - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_swi_init(void *hal, ATCAIfaceCfg *cfg) -{ - atca_plib_swi_bb_api_t* plib = NULL; - - if (cfg == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - plib = (atca_plib_swi_bb_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - // Set crypto pin direction as output - plib->set_pin_output_dir(cfg->atcaswi.bus); - - // Set the crypto pin - plib->write(cfg->atcaswi.bus, true); - - return ATCA_SUCCESS; -} - -/** - * \brief HAL implementation of SWI post init. - * - * \param[in] iface ATCAIface instance - * - * \return ATCA_SUCCESS - */ -ATCA_STATUS hal_swi_post_init(ATCAIface iface) -{ - return ATCA_SUCCESS; -} - -/** - * \brief Send byte(s) via SWI. - * - * \param[in] iface interface of the logical device to send data to - * \param[in] word_address device transaction type - * \param[in] txdata pointer to bytes to send - * \param[in] txlength number of bytes to send - * \return ATCA_SUCCESS - */ -ATCA_STATUS hal_swi_send(ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - ATCA_STATUS status = ATCA_COMM_FAIL; - atca_plib_swi_bb_api_t* plib = NULL; - - if ((cfg == NULL) || (txdata == NULL) || (txlength < 1)) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - plib = (atca_plib_swi_bb_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - (void)word_address; - - //! Send Command Flag - if ((status = swi_send_byte(plib, cfg->atcaswi.bus, SWI_FLAG_CMD)) == ATCA_SUCCESS) - { - //! Skip the Word Address data as SWI doesn't use it - txdata++; - - //! Send the remaining bytes - status = swi_send_bytes(plib, cfg->atcaswi.bus, txlength, txdata); - } - - return status; -} - -/** - * \brief Receive byte(s) via SWI. - * \param[in] iface Device to interact with. - * \param[in] word_address device transaction type - * \param[out] rxdata Data received will be returned here. - * \param[in,out] rxlength As input, the size of the rxdata buffer. - * As output, the number of bytes received. - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_swi_receive(ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxlength) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - ATCA_STATUS status = ATCA_COMM_FAIL; - int retries; - uint16_t rxdata_max_size; - atca_plib_swi_bb_api_t* plib = NULL; - - if ((cfg == NULL) || (rxdata == NULL) || (rxlength == NULL) || (*rxlength < 1)) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - plib = (atca_plib_swi_bb_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - (void)word_address; - retries = cfg->rx_retries; - rxdata_max_size = *rxlength; - *rxlength = 0; - do - { - while (retries-- > 0 && status != ATCA_SUCCESS) - { - if ((status = swi_send_byte(plib, cfg->atcaswi.bus, SWI_FLAG_TX)) == ATCA_SUCCESS) - { - status = swi_receive_bytes(plib, cfg->atcaswi.bus, rxdata_max_size, rxdata); - } - } - - if (status != ATCA_SUCCESS) - { - break; - } - - *rxlength = rxdata[0]; - - } - while (0); - - - return status; -} - -/** - * \brief Send Wake flag via SWI. - * - * \param[in] iface interface of the logical device to wake up - * - * \return ATCA_SUCCESS on success, otherwise an error code. - */ -ATCA_STATUS hal_swi_wake(ATCAIface iface) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - ATCA_STATUS status = ATCA_WAKE_FAILED; - uint8_t data[4] = { 0x00, 0x00, 0x00, 0x00 }; - uint16_t rxlength = sizeof(data); - atca_plib_swi_bb_api_t* plib = NULL; - - if (cfg == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - plib = (atca_plib_swi_bb_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - do - { - //! Generate Wake Token - if (ATCA_SUCCESS != (status = swi_send_wake_token(plib, cfg->atcaswi.bus))) - { - break; - } - - //! Wait tWHI + tWLO - atca_delay_us(cfg->wake_delay); - - // Read Wake response - if (ATCA_SUCCESS != (status = hal_swi_receive(iface, 0x00, data, &rxlength))) - { - break; - } - - status = hal_check_wake(data, rxlength); - - } - while (0); - - return status; -} - -/** - * \brief Send Idle flag via SWI. - * - * \param[in] iface interface of the logical device to idle - * - * \return ATCA_SUCCES - */ -ATCA_STATUS hal_swi_idle(ATCAIface iface) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - atca_plib_swi_bb_api_t* plib = NULL; - - if (cfg == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - plib = (atca_plib_swi_bb_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - return swi_send_byte(plib, cfg->atcaswi.bus, SWI_FLAG_IDLE); -} - -/** - * \brief Send Sleep flag via SWI. - * - * \param[in] iface interface of the logical device to sleep - * - * \return ATCA_SUCCESS - */ -ATCA_STATUS hal_swi_sleep(ATCAIface iface) -{ - ATCAIfaceCfg *cfg = atgetifacecfg(iface); - atca_plib_swi_bb_api_t* plib = NULL; - - if (cfg == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - plib = (atca_plib_swi_bb_api_t*)cfg->cfg_data; - if (plib == NULL) - { - return ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer encountered"); - } - - return swi_send_byte(plib, cfg->atcaswi.bus, SWI_FLAG_SLEEP); -} - -/** - * \brief Manages reference count on given bus and releases resource if - * no more reference(s) exist. - * - * \param[in] hal_data opaque pointer to hal data structure - known only - * to the HAL implementation - * - * \return ATCA_SUCCESS - */ -ATCA_STATUS hal_swi_release(void *hal_data) -{ - return ATCA_SUCCESS; -} - -/** @} */ diff --git a/lib/hal/hal_swi_gpio.c b/lib/hal/hal_swi_gpio.c new file mode 100644 index 000000000..1662d8621 --- /dev/null +++ b/lib/hal/hal_swi_gpio.c @@ -0,0 +1,731 @@ +/** + * \file + * \brief ATCA Hardware abstraction layer for 1WIRE or SWI over GPIO. + * + * \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 "hal_swi_gpio.h" + +#if !defined(ATCA_HAL_SWI) && (defined(ATCA_HAL_SWI_GPIO) || defined(ATCA_HAL_SWI_BB)) +#define ATCA_HAL_SWI +#endif + +static ATCA_STATUS hal_swi_gpio_set_bit( + ATCAIface iface, /**< [in] Device context */ + uint8_t pin_state /**< [in] value to write */ + ) +{ + return iface->phy->halsend(iface, 0, &pin_state, 0); +} + +static ATCA_STATUS hal_swi_gpio_read_bit( + ATCAIface iface, /**< [in] Device context */ + uint8_t* pin_state /**< [in] location to store the read state */ + ) +{ + return iface->phy->halreceive(iface, 0, pin_state, NULL); +} + +#ifdef ATCA_HAL_1WIRE +static ATCA_STATUS hal_swi_gpio_set_dir( + ATCAIface iface, /**< [in] Device context */ + uint8_t pin_dir /**< [in] Pin type input/output */ + ) +{ + return iface->phy->halcontrol(iface, ATCA_HAL_CONTROL_DIRECTION, &pin_dir, sizeof(pin_dir)); +} +#endif + +/** \brief Function to send logic bit 1 or 0 over GPIO using 1WIRE + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS send_logic_bit( + ATCAIface iface, /**< [in] Device context */ + bool bit_value /**< [in] Bit value to write */ + ) +{ + ATCA_STATUS status = ATCA_SUCCESS; + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + + const uint8_t* timings; + const uint8_t logic1_swi_timings[] = { 4, 26 }; + const uint8_t logic1_1wire_timings[] = { 1, 7 }; + const uint8_t logic0_swi_timings[] = { 4, 34, 4, 4 }; + const uint8_t logic0_1wire_timings[] = { 6, 2 }; + + if (bit_value == ATCA_GPIO_LOGIC_BIT1) + { + timings = (cfg->devtype == ECC204) ? logic1_1wire_timings : logic1_swi_timings; + + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); + atca_delay_us(*timings++); + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_SET); + atca_delay_us(*timings++); + } + else + { + timings = (cfg->devtype == ECC204) ? logic0_1wire_timings : logic0_swi_timings; + + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); + atca_delay_us(*timings++); + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_SET); + atca_delay_us(*timings++); + + #ifdef ATCA_HAL_SWI + if (cfg->devtype != ECC204) + { + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); + atca_delay_us(*timings++); + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_SET); + atca_delay_us(*timings++); + } + #endif + } + + return status; +} + +#ifdef ATCA_HAL_1WIRE +/** \brief Function to generate start or stop condition + * \return ATCA_SUCCESS + */ +static ATCA_STATUS start_stop_cond_1wire( + ATCAIface iface /**< [in] Device context */ + ) +{ + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_SET); + tHTSS_DLY; + return ATCA_SUCCESS; +} + +/** \brief Function to read the logic bit 1 or 0 + * \return ATCA_SUCCESS + */ +static ATCA_STATUS read_logic_bit_1wire( + ATCAIface iface, /**< [in] Device context */ + uint8_t * bit_value /**< [out] Location to store the read bit value */ + ) +{ + /* Changing the PIN direction as Input */ + (void)hal_swi_gpio_set_dir(iface, ATCA_GPIO_INPUT_DIR); + + /* Read the line state */ + (void)hal_swi_gpio_read_bit(iface, bit_value); + + /* Changing the PIN direction as Output */ + (void)hal_swi_gpio_set_dir(iface, ATCA_GPIO_OUTPUT_DIR); + + return ATCA_SUCCESS; +} + +/** \brief Function to read the data ACK for the transmitted byte + * \param[in] cfg Driver interface configurations + * \param[in] bit_value Contains logical bit value(ACK or NACK) to be received + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS read_data_ACK_1wire(ATCAIface iface, bool *bit_value) +{ + /* this checks for an ACK or NACK from device */ + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); + tRD_DLY; + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_SET); + tLOW1_DLY; + + return read_logic_bit_1wire(iface, (uint8_t*)bit_value); +} +#endif /* ATCA_HAL_1WIRE */ + +/** \brief Function to send the specified number of bytes through GPIO bit banging + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS gpio_send_bytes( + ATCAIface iface, /**< [in] Device context */ + uint8_t * txdata, /**< [in] Data to send */ + uint16_t txlength /**< [in] Number of bytes to send */ + ) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + uint8_t bit_mask; + uint8_t count; + + protocol_type proto_type = (cfg->devtype == ECC204) ? ATCA_PROTOCOL_1WIRE : ATCA_PROTOCOL_SWI; + + if (txdata == NULL) + { + return status; + } + + /* Disabling interrupts */ + __disable_irq(); + for (count = 0; count < txlength; count++) + { + bit_mask = (cfg->devtype == ECC204) ? ATCA_1WIRE_BIT_MASK : ATCA_SWI_BIT_MASK; + while (bit_mask > 0) + { + /* if the next bit transmitted is a logic '1' */ + if (bit_mask & txdata[count]) + { + status = send_logic_bit(iface, ATCA_GPIO_LOGIC_BIT1); + } + /* if the next bit transmitted is a logic '0' */ + else + { + status = send_logic_bit(iface, ATCA_GPIO_LOGIC_BIT0); + } + + bit_mask = (proto_type == ATCA_PROTOCOL_1WIRE) ? bit_mask >> 1 : bit_mask << 1; + } + #ifdef ATCA_HAL_1WIRE + if ((status == ATCA_SUCCESS) && (proto_type == ATCA_PROTOCOL_1WIRE)) + { + bool bit_value; + + (void)read_data_ACK_1wire(iface, &bit_value); + + /* check for ACK/NACK */ + if (bit_value) /* if a NAK is detected */ + { + /* device failed to send ACK */ + status = ATCA_COMM_FAIL; + break; + } + tRCV0_DLY; /* slave recovery time delay (same for logic'0' and logic '1') */ + } + #endif + } + /* Enabling interrupts */ + __enable_irq(); + + return status; +} + +#ifdef ATCA_HAL_SWI +/** \brief Function to read the logic bit 1 or 0 + * \param[in] cfg Driver interface configurations + * \param[in] bit_value Contains logical bit value to be received + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS read_logic_bit_swi( + ATCAIface iface, /**< [in] Device context */ + bool * bit_value + ) +{ + int8_t timeout_count; + uint8_t current_state = true, prev_state = true; + uint8_t bit_count = 0; + ATCA_STATUS status = ATCA_BAD_PARAM; + + do + { + //wait for start bit + timeout_count = 90 / 2; + while (timeout_count-- >= 0) + { + (void)hal_swi_gpio_read_bit(iface, ¤t_state); + if (current_state != prev_state) + { + prev_state = current_state; + if (!current_state) + { + break; + } + + } + atca_delay_us(2); + } + + if (timeout_count <= 0) + { + status = ATCA_TRACE(ATCA_RX_NO_RESPONSE, "No response is received"); + break; + } + + //Read bit + timeout_count = 40 / 2; + while (timeout_count-- >= 0) + { + (void)hal_swi_gpio_read_bit(iface, ¤t_state); + if (current_state != prev_state) + { + prev_state = current_state; + if (current_state) + { + bit_count++; + } + + } + atca_delay_us(2); + } + + if (bit_count == 2) + { + *bit_value = 0; + } + else if (bit_count == 1) + { + *bit_value = 1; + } + else + { + status = ATCA_TRACE(ATCA_RX_FAIL, "Rx Receive - failed"); + } + } + while (0); + + return status; +} +#endif /* ATCA_HAL_SWI */ + +/** \brief Function to receive the response bytes through GPIO bit banging + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS gpio_receive_bytes( + ATCAIface iface, /**< [in] Device context */ + uint8_t * rxdata, /**< [out] Recieved data buffer */ + uint16_t rxlength /**< [in] Size of data buffer */ + ) +{ + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + uint8_t bit_mask; + uint8_t count; + protocol_type proto_type; + bool bit_value = 1; + + if (rxdata == NULL) + { + return ATCA_BAD_PARAM; + } + + proto_type = (cfg->devtype == ECC204) ? 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; + while (bit_mask >= 1) + { + #ifdef ATCA_HAL_1WIRE + if (proto_type == ATCA_PROTOCOL_1WIRE) + { + + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); + /* device is set for high-speed communication */ + tHIGH_SPEED_DLY; + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_SET); + tSWIN_DLY; /* delay to put master read inside the master sampling window */ + (void)read_logic_bit_1wire(iface, (uint8_t*)&bit_value); + rxdata[count] <<= 1; + } + #endif + + #ifdef ATCA_HAL_SWI + if (proto_type == ATCA_PROTOCOL_SWI) + { + (void)read_logic_bit_swi(iface, &bit_value); + } + #endif + + if (bit_value) /* if a logic '1' is detected; received "one" bit */ + { + rxdata[count] |= bit_value; + } + if (proto_type == ATCA_PROTOCOL_1WIRE) + { + tBIT_DLY;//bit frame duration (tBIT) before reading the next bit + bit_mask >>= 1; + } + else + { + bit_mask <<= 1; + } + } + #ifdef ATCA_HAL_1WIRE + /* send ACK except for last byte of read --> GO TO send_ACK() */ + if (((count < (rxlength - 1)) || (ATCA_1WIRE_RESPONSE_LENGTH_SIZE == rxlength)) && (proto_type == ATCA_PROTOCOL_1WIRE)) + { + (void)send_ACK_1wire(iface); + } + #endif + } + __enable_irq(); + + return ATCA_SUCCESS; +} + +/** \brief Function to generate wake condition + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS generate_wake_condition( + ATCAIface iface /**< [in] Device context */ + ) +{ + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); + atca_delay_us(60); + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_SET); + atca_delay_us(cfg->wake_delay); + return ATCA_SUCCESS; +} + +#ifdef ATCA_HAL_1WIRE +/** \brief Function to discover the available devices in the bus + * \param[in] cfg Driver interface configurations + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS device_discovery_1wire(ATCAIface iface) +{ + bool bit_value; + ATCA_STATUS status = ATCA_BAD_PARAM; + + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); + tRESET_DLY; + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_SET); + tRRT_DLY; + (void)hal_swi_gpio_set_bit(iface, ATCA_GPIO_CLEAR); + tDRR_DLY; + + (void)read_logic_bit_1wire(iface, (uint8_t*)&bit_value); + + status = (bit_value == ((bool)ATCA_GPIO_ACK)) ? ATCA_SUCCESS : ATCA_NO_DEVICES; + + return status; +} + +/** \brief Function to read the data ACK for the transmitted byte + * \param[in] dev_addr 7 bit device address + * \param[in] oper indicates read or write operation + * \return 8 bit device address for write or read operation + */ +static uint8_t get_slave_addr_1wire(uint8_t dev_addr, uint8_t oper) +{ + return (dev_addr << 1) | oper; +} + +/** \brief Function to check wake condition for 1WIRE + * \param[in] cfg Driver interface configurations + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS check_wake_1wire(ATCAIface iface) +{ + ATCA_STATUS status; + uint8_t dev_addr; + + status = device_discovery_1wire(iface); + if (status == ATCA_NO_DEVICES) + { + (void)generate_wake_condition(iface); + status = start_stop_cond_1wire(iface); + dev_addr = get_slave_addr_1wire(iface->mIfaceCFG->atcaswi.address, ATCA_GPIO_WRITE); + status = gpio_send_bytes(iface, &dev_addr, sizeof(dev_addr)); + (void)start_stop_cond_1wire(iface); + } + + return status; +} +#endif /* ATCA_HAL_1WIRE */ + +/** \brief initialize an GPIO interface using given config + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_swi_gpio_init(ATCAIface iface, ATCAIfaceCfg* cfg) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + + if (iface && iface->phy) + { + /* GPIO direction as output */ + (void)hal_swi_gpio_set_dir(iface, ATCA_GPIO_OUTPUT_DIR); + + /* by default, driving high */ + uint8_t param = ATCA_GPIO_SET; + iface->phy->halsend(iface, 0xFF, ¶m, sizeof(param)); + status = ATCA_SUCCESS; + } + return status; +} + +/** + * \brief HAL implementation of GPIO post init. + * + * \param[in] iface ATCAIface instance + * + * \return ATCA_SUCCESS + */ +ATCA_STATUS hal_swi_gpio_post_init(ATCAIface iface) +{ + return ATCA_SUCCESS; +} + +/** \brief HAL implementation of bit banging send over Harmony + * \param[in] iface instance + * \param[in] word_address device transaction type + * \param[in] txdata pointer to space to bytes to send + * \param[in] txlength number of bytes to send + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_swi_gpio_send(ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) +{ + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + ATCA_STATUS status = ATCA_BAD_PARAM; + + #ifdef ATCA_HAL_1WIRE + uint8_t dev_write_addr; + #endif + + if (!cfg) + { + return status; + } + + if (cfg->devtype == ECC204) + { + #ifdef ATCA_HAL_1WIRE + if (ATCA_SUCCESS == (status = start_stop_cond_1wire(iface))) + { + dev_write_addr = get_slave_addr_1wire(cfg->atcaswi.address, ATCA_GPIO_WRITE); + if (ATCA_SUCCESS == (status = gpio_send_bytes(iface, &dev_write_addr, sizeof(dev_write_addr)))) + { + status = gpio_send_bytes(iface, txdata, txlength); + } + status = start_stop_cond_1wire(iface); + } + #endif + } + else + { + #ifdef ATCA_HAL_SWI + if (ATCA_SUCCESS == (status = gpio_send_bytes(iface, &word_address, sizeof(word_address)))) + { + status = gpio_send_bytes(iface, txdata, txlength); + } + #endif + } + + return status; +} + +/** \brief HAL implementation of bit banging receive from HARMONY + * \param[in] iface Device to interact with. + * \param[in] word_address device transaction type + * \param[out] rxdata Data received will be returned here. + * \param[in,out] rxlength As input, the size of the rxdata buffer. + * As output, the number of bytes received. + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_swi_gpio_receive(ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxlength) +{ + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + ATCA_STATUS status; + int retries; + + if ((NULL == cfg) || (NULL == rxlength) || (NULL == rxdata)) + { + return ATCA_BAD_PARAM; + } + + if (cfg->devtype == ECC204) + { + #ifdef ATCA_HAL_1WIRE + word_address = get_slave_addr_1wire(cfg->atcaswi.address, ATCA_GPIO_READ); + if (ATCA_SUCCESS != (status = start_stop_cond_1wire(iface))) + { + return status; + } + #endif + } + else + { + word_address = ATCA_SWI_TX_WORD_ADDR; + } + + retries = cfg->rx_retries; + do + { + if (ATCA_SUCCESS == (status = gpio_send_bytes(iface, &word_address, sizeof(word_address)))) + { + /* Reading response */ + status = gpio_receive_bytes(iface, rxdata, *rxlength); + } + } + while ((retries-- > 0) && (status == ATCA_COMM_FAIL)); + + #ifdef ATCA_HAL_1WIRE + if ((cfg->devtype == ECC204) && (*rxlength != ATCA_1WIRE_RESPONSE_LENGTH_SIZE)) + { + (void)send_NACK_1wire(iface); + } + status = start_stop_cond_1wire(iface); + #endif + + return status; +} + +/** \brief Put the device in idle mode + * \param[in] iface interface to logical device to idle + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS hal_swi_gpio_idle(ATCAIface iface) +{ + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + + if (cfg) + { + if (cfg->devtype == ECC204) + { + return ATCA_SUCCESS; + } + else + { + return hal_swi_gpio_send(iface, ATCA_SWI_IDLE_WORD_ADDR, NULL, 0); + } + } + + return ATCA_BAD_PARAM; +} + +/** \brief send sleep command + * \param[in] iface interface to logical device to sleep + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS hal_swi_gpio_sleep(ATCAIface iface) +{ + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + uint8_t word_address; + + if (cfg) + { + word_address = (cfg->devtype == ECC204) ? ATCA_1WIRE_SLEEP_WORD_ADDR : \ + ATCA_SWI_SLEEP_WORD_ADDR; + + return hal_swi_gpio_send(iface, word_address, NULL, 0); + } + + return ATCA_BAD_PARAM; +} + +/** \brief Function to check wake condition for SWI + * \param[in] cfg Driver interface configurations + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS check_wake_swi(ATCAIface iface) +{ + uint8_t data[4] = { 0x00, 0x00, 0x00, 0x00 }; + uint16_t rxlength = sizeof(data); + const uint8_t expected_response[4] = { 0x04, 0x11, 0x33, 0x43 }; + const uint8_t selftest_fail_resp[4] = { 0x04, 0x07, 0xC4, 0x40 }; + + if (gpio_receive_bytes(iface, data, rxlength) == ATCA_SUCCESS) + { + if (memcmp(data, expected_response, 4) == 0) + { + return ATCA_SUCCESS; + } + if (memcmp(data, selftest_fail_resp, 4) == 0) + { + return ATCA_STATUS_SELFTEST_ERROR; + } + } + return ATCA_WAKE_FAILED; +} + +/** \brief send wake token + * \param[in] iface interface to logical device to wakeup + * \return ATCA_WAKE_SUCCESS on success, otherwise an error code. + */ +static ATCA_STATUS hal_swi_gpio_wake(ATCAIface iface) +{ + ATCAIfaceCfg *cfg = atgetifacecfg(iface); + ATCA_STATUS status = ATCA_WAKE_FAILED; + + if (NULL == cfg) + { + return ATCA_BAD_PARAM; + } + + if (cfg->devtype == ECC204) + { + #ifdef ATCA_HAL_1WIRE + status = check_wake_1wire(iface); + #endif + } + else + { + #ifdef ATCA_HAL_SWI + (void)generate_wake_condition(iface); + status = check_wake_swi(iface); + #endif + } + + return status; +} + + +/** \brief Perform control operations + * \param[in] iface Interface to interact with. + * \param[in] option Control parameter identifier + * \param[in] param Optional pointer to parameter value + * \param[in] paramlen Length of the parameter + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_swi_gpio_control(ATCAIface iface, uint8_t option, void* param, size_t paramlen) +{ + (void)param; + (void)paramlen; + + if (iface && iface->mIfaceCFG) + { + switch (option) + { + case ATCA_HAL_CONTROL_WAKE: + return hal_swi_gpio_wake(iface); + case ATCA_HAL_CONTROL_IDLE: + return hal_swi_gpio_idle(iface); + case ATCA_HAL_CONTROL_SLEEP: + return hal_swi_gpio_sleep(iface); + case ATCA_HAL_CONTROL_SELECT: + /* fallthrough */ + case ATCA_HAL_CONTROL_DESELECT: + return ATCA_SUCCESS; + default: + break; + } + } + return ATCA_BAD_PARAM; +} + +/** \brief releases resource if no more communication + * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_swi_gpio_release(void *hal_data) +{ + return ATCA_SUCCESS; +} diff --git a/lib/hal/hal_gpio_harmony.h b/lib/hal/hal_swi_gpio.h similarity index 97% rename from lib/hal/hal_gpio_harmony.h rename to lib/hal/hal_swi_gpio.h index 4583fe24a..8e04de701 100644 --- a/lib/hal/hal_gpio_harmony.h +++ b/lib/hal/hal_swi_gpio.h @@ -114,6 +114,8 @@ #define ATCA_GPIO_SET 1 #define ATCA_MIN_RESPONSE_LENGTH 4 +#define PIN_INPUT_DIR(pin) PORT_GroupInputEnable(GET_PORT_GROUP(pin), GET_PIN_MASK(pin)) +#define PIN_OUTPUT_DIR(pin) PORT_GroupOutputEnable(GET_PORT_GROUP(pin), GET_PIN_MASK(pin)) /** * \name Macros for Bit-Banged SWI Timing diff --git a/lib/hal/hal_swi_uart.h b/lib/hal/hal_swi_uart.h deleted file mode 100644 index 480d2ce3d..000000000 --- a/lib/hal/hal_swi_uart.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * \file - * \brief ATCA Hardware abstraction layer for SWI over UART drivers. - * - * \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. - */ - -#ifndef HAL_SWI_UART_H_ -#define HAL_SWI_UART_H_ - -#ifdef ATMEL_START - #include "swi_uart_start.h" -#elif defined (SAMD21_ASF) - #include "swi_uart_samd21_asf.h" -#elif defined (XMEGA_ASF) - #include "swi_uart_xmega_a3bu_asf.h" -#elif defined (AT90USB_ASF) - #include "swi_uart_at90usb1287_asf.h" -#endif - - -/** \defgroup hal_ Hardware abstraction layer (hal_) - * - * \brief - * These methods define the hardware abstraction layer for communicating with a CryptoAuth device - * using SWI interface. - * - @{ */ -#define SWI_WAKE_TOKEN ((uint8_t)0x00) //!< flag preceding a command -#define SWI_FLAG_CMD ((uint8_t)0x77) //!< flag preceding a command -#define SWI_FLAG_TX ((uint8_t)0x88) //!< flag requesting a response -#define SWI_FLAG_IDLE ((uint8_t)0xBB) //!< flag requesting to go into Idle mode -#define SWI_FLAG_SLEEP ((uint8_t)0xCC) //!< flag requesting to go into Sleep mode - -ATCA_STATUS hal_swi_send_flag(ATCAIface iface, uint8_t flag); - -/** @} */ -#endif /* HAL_SWI_UART_H_ */ \ No newline at end of file diff --git a/lib/hal/hal_windows.c b/lib/hal/hal_windows.c index 796bd4590..88be58c80 100644 --- a/lib/hal/hal_windows.c +++ b/lib/hal/hal_windows.c @@ -25,9 +25,10 @@ * THIS SOFTWARE. */ +#include "atca_hal.h" #include #include -#include "atca_hal.h" + /** \defgroup hal_ Hardware abstraction layer (hal_) * diff --git a/lib/hal/hal_windows_kit_uart.c b/lib/hal/hal_windows_kit_uart.c index 4b434de85..fe0265871 100644 --- a/lib/hal/hal_windows_kit_uart.c +++ b/lib/hal/hal_windows_kit_uart.c @@ -25,15 +25,15 @@ * THIS SOFTWARE. */ +#include "cryptoauthlib.h" +#include "atca_hal.h" + #include #include #include #include #include -#include "cryptoauthlib.h" -#include "atca_hal.h" - typedef struct atca_uart_host_s { char uart_file[20]; @@ -100,6 +100,7 @@ static ATCA_STATUS hal_uart_open_file(ATCAIface iface) dcbSerialParams.BaudRate = cfg->atcauart.baud; // baud rate dcbSerialParams.ByteSize = cfg->atcauart.wordsize; // data size, xmit and rcv dcbSerialParams.StopBits = cfg->atcauart.stopbits; // stop bit + dcbSerialParams.fDtrControl = DTR_CONTROL_ENABLE; if (!SetCommState(hal_data->hSerial, &dcbSerialParams)) { diff --git a/lib/hal/kit_phy.h b/lib/hal/kit_phy.h deleted file mode 100644 index 8f046d2c3..000000000 --- a/lib/hal/kit_phy.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * \file - * \brief ATCA Hardware abstraction layer physical send & receive function definitions. - * - * This is included for kit protocol implementations. - * It is included in the kit protocol callback to actually send and recieve bytes. - * - * \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. - */ - -#ifndef KIT_PHY_H_ -#define KIT_PHY_H_ - -#include "cryptoauthlib.h" - - -/** \defgroup hal_ Hardware abstraction layer (hal_) - * - * \brief - * These methods define the hardware abstraction layer for communicating with a CryptoAuth device - * - @{ */ - -#ifdef __cplusplus -extern "C" { -#endif - -ATCA_STATUS kit_phy_num_found(int8_t* num_found); -ATCA_STATUS kit_phy_send(ATCAIface iface, const char *txdata, int txlength); -ATCA_STATUS kit_phy_receive(ATCAIface iface, char* rxdata, int* rxlength); - -#ifdef __cplusplus -} -#endif - -/** @} */ - -#endif /* ATCA_HAL_PHY_H_ */ diff --git a/lib/hal/kit_protocol.c b/lib/hal/kit_protocol.c index 115518f00..798346faf 100644 --- a/lib/hal/kit_protocol.c +++ b/lib/hal/kit_protocol.c @@ -40,7 +40,7 @@ @{ */ /* Constants */ -#define KIT_MAX_SCAN_COUNT 4 +#define KIT_MAX_SCAN_COUNT 8 #define KIT_MAX_TX_BUF 32 #ifndef strnchr @@ -102,6 +102,22 @@ const char * kit_interface_from_kittype(ATCAKitType kittype) } } +/** Kit parser physical interface string */ +const char* kit_interface(ATCAKitType kittype) +{ + switch (kittype) + { + case ATCA_KIT_I2C_IFACE: + return "i2c"; + case ATCA_KIT_SWI_IFACE: + return "swi"; + case ATCA_KIT_SPI_IFACE: + return "spi"; + default: + return "unknown"; + } +} + #if defined(ATCA_HAL_KIT_HID) || defined(ATCA_HAL_KIT_UART) /** \brief HAL implementation of send over USB HID @@ -276,12 +292,13 @@ ATCA_STATUS kit_init(ATCAIface iface, ATCAIfaceCfg* cfg) { ATCA_STATUS status = ATCA_SUCCESS; const char kit_device[] = "board:device(%02X)\n"; + const char kit_interface_select[] = "%c:physical:interface:%s\n"; const char kit_device_select[] = "%c:physical:select(%02X)\n"; char txbuf[KIT_MAX_TX_BUF]; int txlen; char rxbuf[KIT_RX_WRAP_SIZE + 4]; int rxlen; - const char* device_match, *interface_match; + const char* device_match, *interface_match, *interface; char *dev_type, *dev_interface; char delim[] = " "; char *token; /* string token */ @@ -359,7 +376,7 @@ ATCA_STATUS kit_init(ATCAIface iface, ATCAIfaceCfg* cfg) } /*Selects the first device type if both device interface and device identity is not defined*/ - if (iface_type == ATCA_KIT_AUTO_IFACE && dev_identity == 0 && (strncmp(device_match, dev_type, 3) == 0)) + if (iface_type == ATCA_KIT_AUTO_IFACE && (dev_identity == 0 || dev_identity == address) && (strncmp(device_match, dev_type, 4) == 0)) { txlen = snprintf(txbuf, sizeof(txbuf) - 1, kit_device_select, device_match[0], address); @@ -382,9 +399,26 @@ ATCA_STATUS kit_init(ATCAIface iface, ATCAIfaceCfg* cfg) else { - if ((strncmp(device_match, dev_type, 4) == 0) && (dev_identity == address) && (strcmp(interface_match, dev_interface) == 0)) + if ((strncmp(device_match, dev_type, 4) == 0) && (dev_identity == 0 || dev_identity == address) && (strcmp(interface_match, dev_interface) == 0)) { + interface = kit_interface(iface_type); + txlen = snprintf(txbuf, sizeof(txbuf) - 1, kit_interface_select, device_match[0], interface); + txbuf[sizeof(txbuf) - 1] = '\0'; + if (txlen < 0) + { + status = ATCA_INVALID_SIZE; + break; + } + + if (ATCA_SUCCESS != (status = kit_phy_send(iface, txbuf, txlen))) + { + break; + } + + rxlen = sizeof(rxbuf); + // Ignoring the response to support earlier versions + (void)kit_phy_receive(iface, rxbuf, &rxlen); txlen = snprintf(txbuf, sizeof(txbuf) - 1, kit_device_select, device_match[0], address); txbuf[sizeof(txbuf) - 1] = '\0'; diff --git a/lib/hal/kit_protocol.h b/lib/hal/kit_protocol.h index 6bd18cd94..c4485376b 100644 --- a/lib/hal/kit_protocol.h +++ b/lib/hal/kit_protocol.h @@ -69,6 +69,7 @@ ATCA_STATUS kit_sleep(ATCAIface iface); const char* kit_id_from_devtype(ATCADeviceType devtype); const char* kit_interface_from_kittype(ATCAKitType kittype); +const char * kit_interface(ATCAKitType kittype); #ifdef __cplusplus } diff --git a/lib/jwt/atca_jwt.c b/lib/jwt/atca_jwt.c index 370b7cc2e..378c8111d 100644 --- a/lib/jwt/atca_jwt.c +++ b/lib/jwt/atca_jwt.c @@ -226,7 +226,7 @@ ATCA_STATUS atca_jwt_add_claim_string( atca_jwt_check_payload_start(jwt); remaining = jwt->buflen - jwt->cur; - written = snprintf(&jwt->buf[jwt->cur], remaining, "\"%s\":\"%s\"", claim, value); + written = snprintf(&jwt->buf[jwt->cur], (size_t)remaining, "\"%s\":\"%s\"", claim, value); if (0 < written && written < remaining) { jwt->cur += written; @@ -262,7 +262,7 @@ ATCA_STATUS atca_jwt_add_claim_numeric( atca_jwt_check_payload_start(jwt); remaining = jwt->buflen - jwt->cur; - written = snprintf(&jwt->buf[jwt->cur], remaining, "\"%s\":%ld", claim, (long)value); + written = snprintf(&jwt->buf[jwt->cur], (size_t)remaining, "\"%s\":%ld", claim, (long)value); if (0 < written && written < remaining) { jwt->cur += written; @@ -325,7 +325,7 @@ ATCA_STATUS atca_jwt_verify( } /* Digest the token */ - if (ATCA_SUCCESS != (status = (ATCA_STATUS)atcac_sw_sha2_256((const uint8_t*)buf, pStr - buf - 1, digest))) + if (ATCA_SUCCESS != (status = (ATCA_STATUS)atcac_sw_sha2_256((const uint8_t*)buf, (size_t)(pStr - buf - 1), digest))) { break; } diff --git a/lib/openssl/atca_openssl_interface.c b/lib/openssl/atca_openssl_interface.c index bc9817303..560ad70e3 100644 --- a/lib/openssl/atca_openssl_interface.c +++ b/lib/openssl/atca_openssl_interface.c @@ -37,6 +37,23 @@ #include #include #include +#include + +/** \brief Return Random Bytes + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +int atcac_sw_random(uint8_t* data, size_t data_size) +{ + if (1 == RAND_bytes(data, data_size)) + { + return ATCA_SUCCESS; + } + else + { + return ATCA_GEN_FAIL; + } +} /** \brief Update the GCM context with additional authentication data (AAD) * @@ -811,8 +828,6 @@ ATCA_STATUS atcac_pk_verify( ret = ECDSA_do_verify(digest, dig_len, ec_sig, EVP_PKEY_get0_EC_KEY((EVP_PKEY*)ctx->ptr)); ECDSA_SIG_free(ec_sig); - BN_free(r); - BN_free(s); } else { diff --git a/lib/pkcs11/pkcs11_cert.c b/lib/pkcs11/pkcs11_cert.c index 2030222aa..659a4c001 100644 --- a/lib/pkcs11/pkcs11_cert.c +++ b/lib/pkcs11/pkcs11_cert.c @@ -377,62 +377,62 @@ CK_RV pkcs11_cert_get_trusted_flag(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAttrib */ const pkcs11_attrib_model pkcs11_cert_x509public_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_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 certificate */ - { CKA_CERTIFICATE_TYPE, pkcs11_cert_get_type }, + { CKA_CERTIFICATE_TYPE, pkcs11_cert_get_type }, /** The certificate can be trusted for the application that it was created. */ - { CKA_TRUSTED, pkcs11_cert_get_trusted_flag }, + { CKA_TRUSTED, pkcs11_cert_get_trusted_flag }, /** Default CK_CERTIFICATE_CATEGORY_UNSPECIFIED) */ - { CKA_CERTIFICATE_CATEGORY, pkcs11_object_get_type }, + { CKA_CERTIFICATE_CATEGORY, pkcs11_object_get_type }, /** Checksum */ - { CKA_CHECK_VALUE, NULL_PTR }, + { CKA_CHECK_VALUE, NULL_PTR }, /** Start date for the certificate (default empty) */ - { CKA_START_DATE, pkcs11_attrib_empty }, + { CKA_START_DATE, pkcs11_attrib_empty }, /** End date for the certificate (default empty) */ - { CKA_END_DATE, pkcs11_attrib_empty }, + { CKA_END_DATE, pkcs11_attrib_empty }, /** ALL: DER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate (default empty) SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT_STRING } */ - { CKA_PUBLIC_KEY_INFO, pkcs11_attrib_empty }, + { CKA_PUBLIC_KEY_INFO, pkcs11_attrib_empty }, /** DER-encoded Certificate subject name */ - { CKA_SUBJECT, pkcs11_cert_get_subject }, + { CKA_SUBJECT, pkcs11_cert_get_subject }, /** Key identifier for public/private key pair (default empty) */ - { CKA_ID, pkcs11_attrib_empty }, + { CKA_ID, pkcs11_attrib_empty }, /** DER-encoded Certificate issuer name (default empty)*/ - { CKA_ISSUER, pkcs11_attrib_empty }, + { CKA_ISSUER, pkcs11_attrib_empty }, /** DER-encoding of the certificate serial number (default empty) */ - { CKA_SERIAL_NUMBER, pkcs11_attrib_empty }, + { CKA_SERIAL_NUMBER, pkcs11_attrib_empty }, /** BER-encoded Complete Certificate */ - { CKA_VALUE, pkcs11_cert_get_encoded }, + { CKA_VALUE, pkcs11_cert_get_encoded }, /** If not empty this attribute gives the URL where the complete certificate can be obtained (default empty) */ - { CKA_URL, pkcs11_attrib_empty }, + { CKA_URL, pkcs11_attrib_empty }, /** Hash of the subject public key (default empty). Hash algorithm is defined by CKA_NAME_HASH_ALGORITHM */ - { CKA_HASH_OF_SUBJECT_PUBLIC_KEY, pkcs11_cert_get_subject_key_id }, + { CKA_HASH_OF_SUBJECT_PUBLIC_KEY, pkcs11_cert_get_subject_key_id }, /** Hash of the issuer public key (default empty). Hash algorithm is defined by CKA_NAME_HASH_ALGORITHM */ - { CKA_HASH_OF_ISSUER_PUBLIC_KEY, pkcs11_cert_get_authority_key_id }, + { CKA_HASH_OF_ISSUER_PUBLIC_KEY, pkcs11_cert_get_authority_key_id }, /** Java MIDP security domain. (default CK_SECURITY_DOMAIN_UNSPECIFIED) */ - { CKA_JAVA_MIDP_SECURITY_DOMAIN, NULL_PTR }, + { CKA_JAVA_MIDP_SECURITY_DOMAIN, NULL_PTR }, /** Defines the mechanism used to calculate CKA_HASH_OF_SUBJECT_PUBLIC_KEY and CKA_HASH_OF_ISSUER_PUBLIC_KEY. If the attribute is not present then the type defaults to SHA-1. */ - { CKA_NAME_HASH_ALGORITHM, pkcs11_attrib_empty }, + { CKA_NAME_HASH_ALGORITHM, pkcs11_attrib_empty }, }; const CK_ULONG pkcs11_cert_x509public_attributes_count = PKCS11_UTIL_ARRAY_SIZE(pkcs11_cert_x509public_attributes); @@ -442,56 +442,56 @@ const CK_ULONG pkcs11_cert_x509public_attributes_count = PKCS11_UTIL_ARRAY_SIZE( */ const pkcs11_attrib_model pkcs11_cert_wtlspublic_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_token_get_access_type }, + { CKA_PRIVATE, pkcs11_token_get_access_type }, /** CK_TRUE if object can be modified. Default is CK_TRUE. */ - { CKA_MODIFIABLE, NULL_PTR }, + { CKA_MODIFIABLE, NULL_PTR }, /** 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 certificate */ - { CKA_CERTIFICATE_TYPE, pkcs11_cert_get_type }, + { CKA_CERTIFICATE_TYPE, pkcs11_cert_get_type }, /** The certificate can be trusted for the application that it was created. */ - { CKA_TRUSTED, NULL_PTR }, + { CKA_TRUSTED, NULL_PTR }, /** Default CK_CERTIFICATE_CATEGORY_UNSPECIFIED) */ - { CKA_CERTIFICATE_CATEGORY, pkcs11_object_get_type }, + { CKA_CERTIFICATE_CATEGORY, pkcs11_object_get_type }, /** Checksum */ - { CKA_CHECK_VALUE, NULL_PTR }, + { CKA_CHECK_VALUE, NULL_PTR }, /** Start date for the certificate (default empty) */ - { CKA_START_DATE, pkcs11_attrib_empty }, + { CKA_START_DATE, pkcs11_attrib_empty }, /** End date for the certificate (default empty) */ - { CKA_END_DATE, pkcs11_attrib_empty }, + { CKA_END_DATE, pkcs11_attrib_empty }, /** ALL: DER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate (default empty) SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT_STRING } */ - { CKA_PUBLIC_KEY_INFO, pkcs11_attrib_empty }, + { CKA_PUBLIC_KEY_INFO, pkcs11_attrib_empty }, /** WTLS-encoded Certificate subject name */ - { CKA_SUBJECT, pkcs11_attrib_empty }, + { CKA_SUBJECT, pkcs11_attrib_empty }, /** WTLS-encoded Certificate issuer name (default empty)*/ - { CKA_ISSUER, pkcs11_attrib_empty }, + { CKA_ISSUER, pkcs11_attrib_empty }, /** WTLS-encoded Complete Certificate */ - { CKA_VALUE, pkcs11_cert_get_encoded }, + { CKA_VALUE, pkcs11_cert_get_encoded }, /** If not empty this attribute gives the URL where the complete certificate can be obtained (default empty) */ - { CKA_URL, pkcs11_attrib_empty }, + { CKA_URL, pkcs11_attrib_empty }, /** Hash of the subject public key (default empty). Hash algorithm is defined by CKA_NAME_HASH_ALGORITHM */ - { CKA_HASH_OF_SUBJECT_PUBLIC_KEY, pkcs11_cert_get_subject_key_id }, + { CKA_HASH_OF_SUBJECT_PUBLIC_KEY, pkcs11_cert_get_subject_key_id }, /** Hash of the issuer public key (default empty). Hash algorithm is defined by CKA_NAME_HASH_ALGORITHM */ - { CKA_HASH_OF_ISSUER_PUBLIC_KEY, pkcs11_attrib_empty }, + { CKA_HASH_OF_ISSUER_PUBLIC_KEY, pkcs11_attrib_empty }, /** Defines the mechanism used to calculate CKA_HASH_OF_SUBJECT_PUBLIC_KEY and CKA_HASH_OF_ISSUER_PUBLIC_KEY. If the attribute is not present then the type defaults to SHA-1. */ - { CKA_NAME_HASH_ALGORITHM, pkcs11_attrib_empty }, + { CKA_NAME_HASH_ALGORITHM, pkcs11_attrib_empty }, }; const CK_ULONG pkcs11_cert_wtlspublic_attributes_count = PKCS11_UTIL_ARRAY_SIZE(pkcs11_cert_wtlspublic_attributes); @@ -501,56 +501,56 @@ const CK_ULONG pkcs11_cert_wtlspublic_attributes_count = PKCS11_UTIL_ARRAY_SIZE( */ const pkcs11_attrib_model pkcs11_cert_x509_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_token_get_access_type }, + { CKA_PRIVATE, pkcs11_token_get_access_type }, /** CK_TRUE if object can be modified. Default is CK_TRUE. */ - { CKA_MODIFIABLE, NULL_PTR }, + { CKA_MODIFIABLE, NULL_PTR }, /** 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 certificate */ - { CKA_CERTIFICATE_TYPE, pkcs11_cert_get_type }, + { CKA_CERTIFICATE_TYPE, pkcs11_cert_get_type }, /** The certificate can be trusted for the application that it was created. */ - { CKA_TRUSTED, NULL_PTR }, + { CKA_TRUSTED, NULL_PTR }, /** Default CK_CERTIFICATE_CATEGORY_UNSPECIFIED) */ - { CKA_CERTIFICATE_CATEGORY, pkcs11_object_get_type }, + { CKA_CERTIFICATE_CATEGORY, pkcs11_object_get_type }, /** Checksum */ - { CKA_CHECK_VALUE, NULL_PTR }, + { CKA_CHECK_VALUE, NULL_PTR }, /** Start date for the certificate (default empty) */ - { CKA_START_DATE, pkcs11_attrib_empty }, + { CKA_START_DATE, pkcs11_attrib_empty }, /** End date for the certificate (default empty) */ - { CKA_END_DATE, pkcs11_attrib_empty }, + { CKA_END_DATE, pkcs11_attrib_empty }, /** ALL: DER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate (default empty) SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT_STRING } */ - { CKA_PUBLIC_KEY_INFO, pkcs11_attrib_empty }, + { CKA_PUBLIC_KEY_INFO, pkcs11_attrib_empty }, /** X509: DER-encoding of the attribute certificate's subject field. This is distinct from the CKA_SUBJECT attribute contained in CKC_X_509 certificates because the ASN.1 syntax and encoding are different. */ - { CKA_OWNER, pkcs11_attrib_empty }, + { CKA_OWNER, pkcs11_attrib_empty }, /** X509: DER-encoding of the attribute certificate's issuer field. This is distinct from the CKA_ISSUER attribute contained in CKC_X_509 certificates because the ASN.1 syntax and encoding are different. (default empty) */ - { CKA_AC_ISSUER, pkcs11_attrib_empty }, + { CKA_AC_ISSUER, pkcs11_attrib_empty }, /** DER-encoding of the certificate serial number (default empty) */ - { CKA_SERIAL_NUMBER, pkcs11_attrib_empty }, + { CKA_SERIAL_NUMBER, pkcs11_attrib_empty }, /** X509: BER-encoding of a sequence of object identifier values corresponding to the attribute types contained in the certificate. When present, this field offers an opportunity for applications to search for a particular attribute certificate without fetching and parsing the certificate itself. (default empty) */ - { CKA_ATTR_TYPES, pkcs11_attrib_empty }, + { CKA_ATTR_TYPES, pkcs11_attrib_empty }, /** BER-encoded Complete Certificate */ - { CKA_VALUE, pkcs11_cert_get_encoded }, + { CKA_VALUE, pkcs11_cert_get_encoded }, }; const CK_ULONG pkcs11_cert_x509_attributes_count = PKCS11_UTIL_ARRAY_SIZE(pkcs11_cert_x509_attributes); diff --git a/lib/pkcs11/pkcs11_config.c b/lib/pkcs11/pkcs11_config.c index dab15b3d3..00460cad9 100644 --- a/lib/pkcs11/pkcs11_config.c +++ b/lib/pkcs11/pkcs11_config.c @@ -314,7 +314,7 @@ static CK_RV pkcs11_config_parse_interface(pkcs11_slot_ctx_ptr slot_ctx, char* c } if (argc > 3) { - slot_ctx->interface_config.atcai2c.baud = (uint8_t)strtol(argv[3], NULL, 10); + slot_ctx->interface_config.atcai2c.baud = (uint32_t)strtol(argv[3], NULL, 10); } rv = CKR_OK; #endif @@ -418,8 +418,8 @@ static CK_RV pkcs11_config_parse_freeslots(pkcs11_slot_ctx_ptr slot_ctx, char* c static CK_RV pkcs11_config_parse_object(pkcs11_slot_ctx_ptr slot_ctx, char* cfgstr) { - int argc = 3; - char * argv[3]; + char * argv[5]; + int argc = (int)sizeof(argv); CK_RV rv = CKR_GENERAL_ERROR; pkcs11_object_ptr pObject; diff --git a/lib/pkcs11/pkcs11_key.c b/lib/pkcs11/pkcs11_key.c index 4b75b82cc..21b03347c 100644 --- a/lib/pkcs11/pkcs11_key.c +++ b/lib/pkcs11/pkcs11_key.c @@ -378,73 +378,73 @@ static CK_RV pkcs11_key_auth_required(CK_VOID_PTR pObject, CK_ATTRIBUTE_PTR pAtt */ 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_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_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); @@ -458,9 +458,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 }, }; /** @@ -468,81 +468,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_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_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 }, + { CKA_UNWRAP, NULL_PTR }, /** CK_TRUE if key is extractable and can be wrapped 9 */ - { CKA_EXTRACTABLE, NULL_PTR }, + { CKA_EXTRACTABLE, NULL_PTR }, /** 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, NULL_PTR }, + { CKA_NEVER_EXTRACTABLE, NULL_PTR }, /** 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); @@ -552,21 +552,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 }, }; /** @@ -578,9 +578,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 }, }; @@ -589,82 +589,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, NULL_PTR }, + { CKA_EXTRACTABLE, NULL_PTR }, /** 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, NULL_PTR }, + { CKA_NEVER_EXTRACTABLE, NULL_PTR }, /** 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); @@ -679,6 +679,7 @@ static CK_RV pkcs11_key_privwrite_ca(CK_VOID_PTR pSession, pkcs11_object_ptr pOb { pkcs11_session_ctx_ptr session_ctx = (pkcs11_session_ctx_ptr)pSession; uint8_t key_buf[36] = { 0, 0, 0, 0 }; + uint8_t num_in[32] = { 0, 1, 2, 3 }; atecc508a_config_t* cfg_ptr = (atecc508a_config_t*)pObject->config; uint16_t write_key_id = cfg_ptr->SlotConfig[pObject->slot]; @@ -690,7 +691,7 @@ static CK_RV pkcs11_key_privwrite_ca(CK_VOID_PTR pSession, pkcs11_object_ptr pOb /* Requires the io protection secret to be configured previously and for the configuration to support this - should only be enabled for testing purposes. Production devices should never have this feature enabled. */ - rv = pkcs11_util_convert_rv(atcab_priv_write(pObject->slot, key_buf, write_key_id, session_ctx->slot->read_key, NULL)); + rv = pkcs11_util_convert_rv(atcab_priv_write(pObject->slot, key_buf, write_key_id, session_ctx->slot->read_key, num_in)); } return rv; @@ -1084,10 +1085,11 @@ static CK_RV pkcs11_key_derive_ca(pkcs11_session_ctx_ptr pSession, pkcs11_object { 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, NULL); + 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) && diff --git a/lib/pkcs11/pkcs11_mech.c b/lib/pkcs11/pkcs11_mech.c index 96dac65da..952e557e4 100644 --- a/lib/pkcs11/pkcs11_mech.c +++ b/lib/pkcs11/pkcs11_mech.c @@ -48,25 +48,25 @@ typedef struct _pcks11_mech_table_e static pcks11_mech_table_e pkcs11_mech_list_ecc508[] = { //CKM_DH_PKCS_KEY_PAIR_GEN, //CKM_DH_PKCS_DERIVE, - { CKM_SHA256, { 256, 256, CKF_HW | CKF_DIGEST } }, - { CKM_SHA256_HMAC, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY } }, - { CKM_SHA256_HMAC_GENERAL, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY } }, - { CKM_GENERIC_SECRET_KEY_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } }, - { CKM_CONCATENATE_BASE_AND_KEY, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_CONCATENATE_BASE_AND_DATA, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_CONCATENATE_DATA_AND_BASE, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_XOR_BASE_AND_DATA, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_EXTRACT_KEY_FROM_KEY, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_SSL3_PRE_MASTER_KEY_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } }, - { CKM_SSL3_MASTER_KEY_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_SSL3_KEY_AND_MAC_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_SSL3_MASTER_KEY_DERIVE_DH, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_TLS_PRE_MASTER_KEY_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } }, - { CKM_TLS_MASTER_KEY_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_TLS_KEY_AND_MAC_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_TLS_MASTER_KEY_DERIVE_DH, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_TLS_PRF, { 0, 0, CKF_HW | CKF_DERIVE } }, - { CKM_SHA256_KEY_DERIVATION, { 256, 256, CKF_HW | CKF_DERIVE } }, + { CKM_SHA256, { 256, 256, CKF_HW | CKF_DIGEST } }, + { CKM_SHA256_HMAC, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY } }, + { CKM_SHA256_HMAC_GENERAL, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY } }, + { CKM_GENERIC_SECRET_KEY_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } }, + { CKM_CONCATENATE_BASE_AND_KEY, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_CONCATENATE_BASE_AND_DATA, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_CONCATENATE_DATA_AND_BASE, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_XOR_BASE_AND_DATA, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_EXTRACT_KEY_FROM_KEY, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_SSL3_PRE_MASTER_KEY_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } }, + { CKM_SSL3_MASTER_KEY_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_SSL3_KEY_AND_MAC_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_SSL3_MASTER_KEY_DERIVE_DH, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_TLS_PRE_MASTER_KEY_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } }, + { CKM_TLS_MASTER_KEY_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_TLS_KEY_AND_MAC_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_TLS_MASTER_KEY_DERIVE_DH, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_TLS_PRF, { 0, 0, CKF_HW | CKF_DERIVE } }, + { CKM_SHA256_KEY_DERIVATION, { 256, 256, CKF_HW | CKF_DERIVE } }, //CKM_WTLS_PRE_MASTER_KEY_GEN, //CKM_WTLS_MASTER_KEY_DERIVE, //CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC, @@ -97,13 +97,13 @@ static pcks11_mech_table_e pkcs11_mech_list_ecc508[] = { //CKM_SEED_CBC_PAD, //CKM_SEED_ECB_ENCRYPT_DATA, //CKM_SEED_CBC_ENCRYPT_DATA, - { CKM_EC_KEY_PAIR_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR | PCKS11_MECH_ECC508_EC_CAPABILITY } }, - { CKM_ECDSA, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY | PCKS11_MECH_ECC508_EC_CAPABILITY } }, - { CKM_ECDSA_SHA256, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY | PCKS11_MECH_ECC508_EC_CAPABILITY } }, - { CKM_ECDH1_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE | PCKS11_MECH_ECC508_EC_CAPABILITY } }, - { CKM_ECDH1_COFACTOR_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE | PCKS11_MECH_ECC508_EC_CAPABILITY } }, - { CKM_ECMQV_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE | PCKS11_MECH_ECC508_EC_CAPABILITY } }, - { CKM_ECDH_AES_KEY_WRAP, { 0, 0, CKF_HW | CKF_WRAP | CKF_UNWRAP | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_EC_KEY_PAIR_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_ECDSA, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_ECDSA_SHA256, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_ECDH1_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_ECDH1_COFACTOR_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_ECMQV_DERIVE, { 0, 0, CKF_HW | CKF_DERIVE | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_ECDH_AES_KEY_WRAP, { 0, 0, CKF_HW | CKF_WRAP | CKF_UNWRAP | PCKS11_MECH_ECC508_EC_CAPABILITY } }, //CKM_FASTHASH, //CKM_AES_KEY_GEN, //CKM_AES_ECB, @@ -122,7 +122,7 @@ static pcks11_mech_table_e pkcs11_mech_list_ecc508[] = { //{CKM_AES_GMAC, //CKM_AES_ECB_ENCRYPT_DATA, //CKM_AES_CBC_ENCRYPT_DATA, - { CKM_DH_PKCS_PARAMETER_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } } + { CKM_DH_PKCS_PARAMETER_GEN, { 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } } //CKM_AES_OFB, //CKM_AES_CFB64, //CKM_AES_CFB8, @@ -136,9 +136,9 @@ static pcks11_mech_table_e pkcs11_mech_list_ecc508[] = { static pcks11_mech_table_e pkcs11_mech_list_ecc608[] = { //CKM_DH_PKCS_KEY_PAIR_GEN, //CKM_DH_PKCS_DERIVE, - { CKM_SHA256, { 256, 256, CKF_HW | CKF_DIGEST } }, - { CKM_SHA256_HMAC, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY } }, - { CKM_SHA256_HMAC_GENERAL, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY } }, + { CKM_SHA256, { 256, 256, CKF_HW | CKF_DIGEST } }, + { CKM_SHA256_HMAC, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY } }, + { CKM_SHA256_HMAC_GENERAL, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY } }, //{ CKM_GENERIC_SECRET_KEY_GEN,{ 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } }, //{ CKM_CONCATENATE_BASE_AND_KEY,{ 0, 0, CKF_HW | CKF_DERIVE } }, //{ CKM_CONCATENATE_BASE_AND_DATA,{ 0, 0, CKF_HW | CKF_DERIVE } }, @@ -185,8 +185,8 @@ static pcks11_mech_table_e pkcs11_mech_list_ecc608[] = { //CKM_SEED_CBC_PAD, //CKM_SEED_ECB_ENCRYPT_DATA, //CKM_SEED_CBC_ENCRYPT_DATA, - { CKM_EC_KEY_PAIR_GEN, { 256, 256, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR | PCKS11_MECH_ECC508_EC_CAPABILITY } }, - { CKM_ECDSA, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_EC_KEY_PAIR_GEN, { 256, 256, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR | PCKS11_MECH_ECC508_EC_CAPABILITY } }, + { CKM_ECDSA, { 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY | PCKS11_MECH_ECC508_EC_CAPABILITY } }, //{ CKM_ECDSA_SHA256,{ 256, 256, CKF_HW | CKF_SIGN | CKF_VERIFY | PCKS11_MECH_ECC508_EC_CAPABILITY } }, //{ CKM_ECDH1_DERIVE,{ 0, 0, CKF_HW | CKF_DERIVE | PCKS11_MECH_ECC508_EC_CAPABILITY } }, //{ CKM_ECDH1_COFACTOR_DERIVE,{ 0, 0, CKF_HW | CKF_DERIVE | PCKS11_MECH_ECC508_EC_CAPABILITY } }, @@ -194,22 +194,22 @@ static pcks11_mech_table_e pkcs11_mech_list_ecc608[] = { //{ CKM_ECDH_AES_KEY_WRAP,{ 0, 0, CKF_HW | CKF_WRAP | CKF_UNWRAP | PCKS11_MECH_ECC508_EC_CAPABILITY } }, //CKM_FASTHASH, //CKM_AES_KEY_GEN, - { CKM_AES_ECB, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, - { CKM_AES_CBC, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_ECB, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_CBC, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, //{CKM_AES_MAC, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT} }, //{CKM_AES_MAC_GENERAL, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT} }, //CKM_AES_CBC_PAD, - { CKM_AES_CTR, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, - { CKM_AES_GCM, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, - { CKM_AES_CCM, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_CTR, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_GCM, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_CCM, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, //CKM_AES_CTS, - { CKM_AES_CMAC, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, - { CKM_AES_CMAC_GENERAL, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_CMAC, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_CMAC_GENERAL, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, //CKM_AES_XCBC_MAC, //CKM_AES_XCBC_MAC_96, //{CKM_AES_GMAC, - { CKM_AES_ECB_ENCRYPT_DATA, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, - { CKM_AES_CBC_ENCRYPT_DATA, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_ECB_ENCRYPT_DATA, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, + { CKM_AES_CBC_ENCRYPT_DATA, { 128, 128, CKF_HW | CKF_ENCRYPT | CKF_DECRYPT } }, //{ CKM_DH_PKCS_PARAMETER_GEN,{ 0, 0, CKF_HW | CKF_GENERATE | CKF_GENERATE_KEY_PAIR } } //CKM_AES_OFB, //CKM_AES_CFB64, diff --git a/lib/pkcs11/pkcs11_object.c b/lib/pkcs11/pkcs11_object.c index 44ab9aeb6..fdb66dfde 100644 --- a/lib/pkcs11/pkcs11_object.c +++ b/lib/pkcs11/pkcs11_object.c @@ -68,16 +68,16 @@ static CK_OBJECT_HANDLE pkcs11_object_alloc_handle(void) */ const pkcs11_attrib_model pkcs11_object_monotonic_attributes[] = { /** Object Class - CK_OBJECT_CLASS */ - { CKA_CLASS, pkcs11_object_get_class }, + { CKA_CLASS, pkcs11_object_get_class }, /** Hardware Feature Type - CK_HW_FEATURE_TYPE */ - { CKA_HW_FEATURE_TYPE, pkcs11_object_get_type }, + { CKA_HW_FEATURE_TYPE, pkcs11_object_get_type }, /** Counter will reset to a previously returned value if the token is initialized using C_InitToken. */ - { CKA_RESET_ON_INIT, pkcs11_attrib_false }, + { CKA_RESET_ON_INIT, pkcs11_attrib_false }, /** Counter has been reset at least once at some point in time. */ - { CKA_HAS_RESET, pkcs11_attrib_false }, + { CKA_HAS_RESET, pkcs11_attrib_false }, /** Current value of the monotonic counter. Big endian order. */ - { CKA_VALUE, NULL_PTR }, + { CKA_VALUE, NULL_PTR }, }; const CK_ULONG pkcs11_object_monotonic_attributes_count = PKCS11_UTIL_ARRAY_SIZE(pkcs11_object_monotonic_attributes); @@ -463,6 +463,7 @@ CK_RV pkcs11_object_create return rv; } } + else { return CKR_ARGUMENTS_BAD; } diff --git a/lib/pkcs11/pkcs11_slot.c b/lib/pkcs11/pkcs11_slot.c index 25eef4925..94a965fdc 100644 --- a/lib/pkcs11/pkcs11_slot.c +++ b/lib/pkcs11/pkcs11_slot.c @@ -119,7 +119,7 @@ CK_RV pkcs11_slot_config(CK_SLOT_ID slotID) return rv; } -#if 0 +#if PKCS11_508_SUPPORT && PKCS11_608_SUPPORT static ATCA_STATUS pkcs11_slot_check_device_type(ATCAIfaceCfg * ifacecfg) { uint8_t info[4] = { 0 }; diff --git a/lib/pkcs11/pkcs11_token.c b/lib/pkcs11/pkcs11_token.c index e96e88928..8d09cbb37 100644 --- a/lib/pkcs11/pkcs11_token.c +++ b/lib/pkcs11/pkcs11_token.c @@ -243,10 +243,9 @@ CK_RV pkcs11_token_init(CK_SLOT_ID slotID, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinL { if (64 != ulPinLen) { - if (CKR_OK == (rv = pkcs11_lock_context(pLibCtx))) + if (CKR_OK == rv) { rv = pkcs11_util_convert_rv(atcab_read_serial_number(buf)); - (void)pkcs11_unlock_context(pLibCtx); } if (CKR_OK == rv) diff --git a/lib/pkcs11/pkcs11f.h b/lib/pkcs11/pkcs11f.h index 5d2ed0b05..b3c69b066 100644 --- a/lib/pkcs11/pkcs11f.h +++ b/lib/pkcs11/pkcs11f.h @@ -936,4 +936,3 @@ CK_PKCS11_FUNCTION_INFO(C_WaitForSlotEvent) CK_VOID_PTR pRserved /* reserved. Should be NULL_PTR */ ); #endif - diff --git a/lib/pkcs11/pkcs11t.h b/lib/pkcs11/pkcs11t.h index 97297515c..6cb48c425 100644 --- a/lib/pkcs11/pkcs11t.h +++ b/lib/pkcs11/pkcs11t.h @@ -2066,4 +2066,3 @@ typedef CK_SEED_CBC_ENCRYPT_DATA_PARAMS CK_PTR \ CK_SEED_CBC_ENCRYPT_DATA_PARAMS_PTR; #endif /* _PKCS11T_H_ */ - diff --git a/lib/wolfssl/atca_wolfssl_interface.c b/lib/wolfssl/atca_wolfssl_interface.c index 4beb2cc08..49e607fa3 100644 --- a/lib/wolfssl/atca_wolfssl_interface.c +++ b/lib/wolfssl/atca_wolfssl_interface.c @@ -31,6 +31,27 @@ #ifdef ATCA_WOLFSSL +/** \brief Return Random Bytes + * + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +int atcac_sw_random(uint8_t* data, size_t data_size) +{ + RNG rng; + int ret = wc_InitRng(&rng); + + if (ret != 0) + { + return ATCA_GEN_FAIL; + } + ret = wc_RNG_GenerateBlock(&rng, data, data_size); + if (ret != 0) + { + return ATCA_GEN_FAIL; + } + return ATCA_SUCCESS; +} + /** \brief Initialize an AES-GCM context * * \return ATCA_SUCCESS on success, otherwise an error code. @@ -330,7 +351,7 @@ ATCA_STATUS atcac_pk_init( { if (!key_type) { - (ecc_key*)ctx->ptr = wc_ecc_key_new(NULL); + ctx->ptr = wc_ecc_key_new(NULL); if (ctx->ptr) { @@ -392,11 +413,11 @@ ATCA_STATUS atcac_pk_init_pem( type = ECC_PUBLICKEY_TYPE; } - ret = PemToDer((char*)buf, (long)buflen, type, &der, NULL, NULL, &ecckey); + ret = PemToDer((unsigned char*)buf, (long)buflen, type, &der, NULL, NULL, &ecckey); if ((ret >= 0) && (der != NULL)) { - (ecc_key*)ctx->ptr = wc_ecc_key_new(NULL); + ctx->ptr = wc_ecc_key_new(NULL); if (ctx->ptr) { diff --git a/module.xml b/module.xml index 3326a34d0..a087fce5e 100644 --- a/module.xml +++ b/module.xml @@ -1,4 +1,4 @@ - + diff --git a/package.xml b/package.xml index 3a9b4067f..d8ac32ac4 100644 --- a/package.xml +++ b/package.xml @@ -1,6 +1,6 @@ - + diff --git a/python/cryptoauthlib/cryptoauth.json b/python/cryptoauthlib/cryptoauth.json index b9b01d753..fec496477 100644 --- a/python/cryptoauthlib/cryptoauth.json +++ b/python/cryptoauthlib/cryptoauth.json @@ -618,7 +618,7 @@ "ctypes.c_uint16", "ctypes.c_uint16", "ctypes.POINTER(ta_element_attributes_t)", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes Create command to create elements on shared data or volatile register. This cannot create Secure_boot special handles. ", "parameters": [ @@ -653,7 +653,7 @@ "argtypes": [ "ctypes.c_void_p", "ctypes.POINTER(ta_element_attributes_t)", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes Create command to create elements on TA100 shared data memory. The handle is created by vega and handle value is copied into output buffer. This function wont create handle for ephemeral or HMAC symmetric key. This cannot create Secure_boot special handles. ", "parameters": [ @@ -728,7 +728,7 @@ "ctypes.c_void_p", "ctypes.c_size_t", "ctypes.POINTER(ta_element_attributes_t)", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes Create command to create HMAC symmetric elements on shared data. The handle is created by vega and handle value is copied into output buffer. This cannot create Secure_boot special handles. ", "parameters": [ @@ -784,7 +784,7 @@ "ctypes.c_void_p", "ctypes.c_uint16", "ctypes.POINTER(ta_element_attributes_t)", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA-API Execute the create command to create handle by TA100 in linked shared data. ", "parameters": [ @@ -940,7 +940,7 @@ "ctypes.c_void_p", "ctypes.c_void_p", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes devupdate command to Update the subsequent block (image) of the nonvolatile operating code within the Vega device. ", "parameters": [ @@ -1185,7 +1185,7 @@ "ctypes.c_void_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes the Export command, which exports the contents of a key/data element in the shared data memory. ", "parameters": [ @@ -1497,7 +1497,7 @@ "restype": "ctypes.c_uint8", "argtypes": [ "ctypes.c_void_p", - "ctypes.c_uint16_p", + "ctypes.POINTER(ctypes.c_uint16)", "ctypes.POINTER(ctypes.c_size_t)" ], "docstring": "TA API - Issues an Info command to return handles list. ", @@ -1720,7 +1720,7 @@ "restype": "ctypes.c_uint8", "argtypes": [ "ctypes.c_void_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Issues an Info command to get ROM ID. ", "parameters": [ @@ -1994,7 +1994,7 @@ "ctypes.c_char_p", "ctypes.c_char_p", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes HKDF operation using KDF command. Extract_key = HMAC(Salt, Key_Handle) Out_Handle[0-31] = HMAC(Key_ Extract_key, Info | 1) Out_Handle[32-63] = HMAC(Key_ Extract_key, Out_Handle[0-31] | Info | 2) Out_Handle[64-95] = HMAC(Key_ Extract_key, Out_Handle[32-63] | Info | 3) Out_Handle[96-127] = HMAC(Key_ Extract_key, Out_Handle[64-95] | Info | 4) ", "parameters": [ @@ -2046,7 +2046,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes HKDF operation using KDF command, result in IO buffer. ", "parameters": [ @@ -2094,7 +2094,7 @@ "ctypes.c_char_p", "ctypes.c_size_t", "ctypes.c_uint16", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes HKDF operation using KDF command, result is stored inside device either in shared data memory or volatile register. ", "parameters": [ @@ -2141,7 +2141,7 @@ "ctypes.c_uint16", "ctypes.c_char_p", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes PRF operation using KDF command. A1 = HMAC(Key_Handle, Input_Data) Out_Handle[0-31] = HMAC(Key_Handle, A1 | Input_Data) A2 = HMAC(Key_Handle, A1) Out_Handle[32-63] = HMAC(Key_Handle, A2 | Input_Data) A3 = HMAC(Key_Handle, A2) Out_Handle[64-95] = HMAC(Key_Handle, A3 | Input_Data) A4 = HMAC(Key_Handle, A3) Out_Handle[96-127] = HMAC(Key_Handle, A4 | Input_Data) ", "parameters": [ @@ -2184,7 +2184,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes PRF operation using KDF command, result in IO buffer. ", "parameters": [ @@ -2227,7 +2227,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_uint16", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes PRF operation using KDF command, result is stored inside device either in shared data memory or volatile register. ", "parameters": [ @@ -2272,7 +2272,7 @@ "ctypes.c_char_p", "ctypes.c_char_p", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes HMAC-Counter operation using KDF command. Bytes 0-31: HMAC(key_handle, 1 | Label | 0 | Context | Length) Bytes 32-63: HMAC(key_handle, 2 | Label | 0 | Context | Length) Bytes 64-95: HMAC(key_handle, 3 | Label | 0 | Context | Length) Bytes 95-127: HMAC(key_handle, 4 | Label | 0 | Context | Length) ", "parameters": [ @@ -2324,7 +2324,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes HMAC-Counter operation using KDF command, result is in IO buffer. ", "parameters": [ @@ -2372,7 +2372,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_uint16", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes HMAC-Counter operation using KDF command, result is stored inside device either in shared data memory or volatile register. ", "parameters": [ @@ -2421,7 +2421,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes SHA256 operation using KDF command. Bytes 0-31: SHA256(Pre_pad | key_handle | Post_pad) ", "parameters": [ @@ -2473,7 +2473,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes SHA256 operation using KDF command, result in IO buffer. ", "parameters": [ @@ -2521,7 +2521,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_uint16", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes SHA256 operation using KDF command, result is stored inside device either in shared data memory or volatile register. ", "parameters": [ @@ -2819,7 +2819,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes MAC command for CMAC and HMAC calculations. ", "parameters": [ @@ -3220,7 +3220,7 @@ "ctypes.c_uint16", "ctypes.c_uint16", "ctypes.c_uint16", - "ctypes.c_uint16_p", + "ctypes.POINTER(ctypes.c_uint16)", "ctypes.c_char_p", "ctypes.c_char_p" ], @@ -3265,7 +3265,7 @@ "argtypes": [ "ctypes.c_void_p", "ctypes.c_uint16", - "ctypes.c_uint16_p", + "ctypes.POINTER(ctypes.c_uint16)", "ctypes.c_char_p" ], "docstring": "TA API - Executes Read command to read complete element from shared data memory. Restrictions apply based on attributes of the element. Volatile registers can never be read. ", @@ -3294,7 +3294,7 @@ "ctypes.c_void_p", "ctypes.c_uint16", "ctypes.c_uint16", - "ctypes.c_uint16_p", + "ctypes.POINTER(ctypes.c_uint16)", "ctypes.c_char_p" ], "docstring": "TA API - Executes Read command to read partial element from shared date memory. Restrictions apply based on attributes of the element. Volatile registers can never be read. ", @@ -3507,7 +3507,7 @@ "ctypes.c_char_p", "ctypes.c_char_p", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes RSAEnc command to perform RSA Encryption and Decryption operations Maximum number of bytes that can be encrypted or decrypted is 62. This is available only for RSA-1024 bit keys. ", "parameters": [ @@ -4228,7 +4228,7 @@ "ctypes.c_uint16", "ctypes.c_char_p", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes SHA command, which computes a SHA-256 digest for general purpose use by the host system. ", "parameters": [ @@ -4270,7 +4270,7 @@ "ctypes.c_uint16", "ctypes.c_char_p", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes SHA command, which computes a SHA-256 digest for general purpose use by the host system. ", "parameters": [ @@ -4535,7 +4535,7 @@ "argtypes": [ "ctypes.c_void_p", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": null, "parameters": [ @@ -4559,7 +4559,7 @@ "ctypes.c_void_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "Executes Read command to read the SHA-256 context from given input handle. ", "parameters": [ @@ -4641,7 +4641,7 @@ "ctypes.c_uint16", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes the Sign command for sign internally generated messages using ECDSA or RSA algorithm. ", "parameters": [ @@ -4685,7 +4685,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - Executes the Sign command for sign the external messages using ECDSA or RSA algorithm. ", "parameters": [ @@ -5523,7 +5523,7 @@ "ctypes.c_char_p", "ctypes.c_uint16", "ctypes.c_char_p", - "ctypes.c_uint16_p" + "ctypes.POINTER(ctypes.c_uint16)" ], "docstring": "TA API - To pass data from host to TA100 or TA100 to host for sequence calculation. ", "parameters": [ @@ -5762,4 +5762,4 @@ ] ] } -} \ No newline at end of file +} diff --git a/python/cryptoauthlib/iface.py b/python/cryptoauthlib/iface.py index 130bf37c5..4474ac5c9 100644 --- a/python/cryptoauthlib/iface.py +++ b/python/cryptoauthlib/iface.py @@ -103,7 +103,9 @@ class _ATCASPI(Structure): class _ATCAUART(Structure): """Generic UART HAL configuration""" - _fields_ = [('port', c_int), + _fields_ = [('dev_interface', get_ctype_by_name('ATCAKitType')), + ('dev_identity', c_uint8), + ('port', c_uint8), ('baud', c_uint32), ('wordsize', c_uint8), ('parity', c_uint8), diff --git a/python/setup.py b/python/setup.py index 272be081e..ea5f2db3e 100644 --- a/python/setup.py +++ b/python/setup.py @@ -135,10 +135,11 @@ def build_extension(self, ext): else: build_args = [] - cmake_args = ['-DATCA_HAL_CUSTOM=ON', '-DATCA_TNGTLS_SUPPORT=ON', + cmake_args = ['-DATCA_HAL_CUSTOM=ON', '-DATCA_HAL_KIT_UART=ON', '-DATCA_ATSHA206A_SUPPORT=ON', - '-DATCA_TNGLORA_SUPPORT=ON', '-DATCA_TFLEX_SUPPORT=ON', - '-DATCA_TNG_LEGACY_SUPPORT=ON', '-DATCA_USE_ATCAB_FUNCTIONS=ON'] + '-DATCA_TNGTLS_SUPPORT=ON', '-DATCA_TFLEX_SUPPORT=ON', + '-DATCA_TNGLORA_SUPPORT=ON', '-DATCA_TNG_LEGACY_SUPPORT=ON', + '-DATCA_USE_ATCAB_FUNCTIONS=ON'] if os.path.exists('../lib/talib' if not _sdist_build else 'lib/talib'): cmake_args += ['-DATCA_TA100_SUPPORT=ON'] diff --git a/release_notes.md b/release_notes.md index 3a402dfc1..472c5985b 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,8 +1,30 @@ # Microchip Cryptoauthlib Release Notes -## Release v3.3.2 (06/20/2021) +## Release v3.3.3 (10/06/2021) + +### New features + - Added Zephyr support and zephyr driver api HALs for I2C & SPI. Adding cryptoauthlib + to a zephyr project CMakeLists.txt is now possible - use subdirectory(cryptoauthlib/lib). + One can also include the repo in the west manifest + - Added SWI device support for linux platforms using hardware uarts + - Added contributing guidelines and PR process documentation + - SWI bitbang driver for harmony - supports Atmel SWI and ECC204 protocols + +### Fixes + - Wolfssl build errors when generating MHC projects containing wolfssl + - Removed zero length aad limitation in CCM implementation + - Changed ECC204 zone identifiers and slot types to align with cryptoauthlib + standard forms + - XC8/XC16 build warnings + - Several pkcs11 fixes - token_init deadlock, null num_in for private key writes, + fsecret key length parsing, object_create failing, etc + - Null pointer access violation in atcab_release when using a native hal and double + free in openssl implementation of atcac_pk_verify + + +## Release v3.3.2 (06/20/2021) ### New features - All memory allocations now go through the hal_ platform definitions. diff --git a/test/api_atcab/atca_tests_aes_ccm.c b/test/api_atcab/atca_tests_aes_ccm.c index 38e50fa52..38ba671bf 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), 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) }, #endif { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; diff --git a/test/api_atcab/atca_tests_derivekey.c b/test/api_atcab/atca_tests_derivekey.c index 7289fd691..46add2f1d 100644 --- a/test/api_atcab/atca_tests_derivekey.c +++ b/test/api_atcab/atca_tests_derivekey.c @@ -240,4 +240,3 @@ t_test_case_info derivekey_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, }; #endif - diff --git a/test/api_atcab/atca_tests_genkey.c b/test/api_atcab/atca_tests_genkey.c index 0e77e8cbd..f59bfedbc 100644 --- a/test/api_atcab/atca_tests_genkey.c +++ b/test/api_atcab/atca_tests_genkey.c @@ -83,4 +83,3 @@ t_test_case_info genkey_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_info.c b/test/api_atcab/atca_tests_info.c index 8f7031152..094ca79ef 100644 --- a/test/api_atcab/atca_tests_info.c +++ b/test/api_atcab/atca_tests_info.c @@ -44,4 +44,3 @@ t_test_case_info info_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_lock.c b/test/api_atcab/atca_tests_lock.c index bff78eaeb..81a33e37f 100644 --- a/test/api_atcab/atca_tests_lock.c +++ b/test/api_atcab/atca_tests_lock.c @@ -93,4 +93,3 @@ t_test_case_info lock_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_nonce.c b/test/api_atcab/atca_tests_nonce.c index 4204a789a..cbe964bc0 100644 --- a/test/api_atcab/atca_tests_nonce.c +++ b/test/api_atcab/atca_tests_nonce.c @@ -47,4 +47,3 @@ t_test_case_info nonce_basic_test_info[] = }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_privwrite.c b/test/api_atcab/atca_tests_privwrite.c index 0f35eb82e..111805492 100644 --- a/test/api_atcab/atca_tests_privwrite.c +++ b/test/api_atcab/atca_tests_privwrite.c @@ -107,4 +107,3 @@ t_test_case_info privwrite_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_random.c b/test/api_atcab/atca_tests_random.c index bde927b14..5b5830fef 100644 --- a/test/api_atcab/atca_tests_random.c +++ b/test/api_atcab/atca_tests_random.c @@ -43,4 +43,3 @@ t_test_case_info random_basic_test_info[] = { (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 ec4380073..cbaf45218 100644 --- a/test/api_atcab/atca_tests_read.c +++ b/test/api_atcab/atca_tests_read.c @@ -168,4 +168,3 @@ t_test_case_info read_basic_test_info[] = { (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 eb1ba5375..22bca876f 100644 --- a/test/api_atcab/atca_tests_secureboot.c +++ b/test/api_atcab/atca_tests_secureboot.c @@ -185,4 +185,3 @@ t_test_case_info sboot_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_selftest.c b/test/api_atcab/atca_tests_selftest.c index 648507bdf..5b4e3367d 100644 --- a/test/api_atcab/atca_tests_selftest.c +++ b/test/api_atcab/atca_tests_selftest.c @@ -71,5 +71,3 @@ t_test_case_info selftest_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - - diff --git a/test/api_atcab/atca_tests_sha.c b/test/api_atcab/atca_tests_sha.c index f4fb49436..d5eeeff09 100644 --- a/test/api_atcab/atca_tests_sha.c +++ b/test/api_atcab/atca_tests_sha.c @@ -622,4 +622,3 @@ t_test_case_info sha_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_startup.c b/test/api_atcab/atca_tests_startup.c index caae71a0d..d643921ee 100644 --- a/test/api_atcab/atca_tests_startup.c +++ b/test/api_atcab/atca_tests_startup.c @@ -76,4 +76,3 @@ t_test_case_info startup_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 },/* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_updateextra.c b/test/api_atcab/atca_tests_updateextra.c index d71d2780f..8bdcbd814 100644 --- a/test/api_atcab/atca_tests_updateextra.c +++ b/test/api_atcab/atca_tests_updateextra.c @@ -39,4 +39,3 @@ t_test_case_info updateextra_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_verify.c b/test/api_atcab/atca_tests_verify.c index 414272def..9c7298bd9 100644 --- a/test/api_atcab/atca_tests_verify.c +++ b/test/api_atcab/atca_tests_verify.c @@ -510,4 +510,3 @@ t_test_case_info verify_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_atcab/atca_tests_write.c b/test/api_atcab/atca_tests_write.c index f39ba3f0c..189ef85f8 100644 --- a/test/api_atcab/atca_tests_write.c +++ b/test/api_atcab/atca_tests_write.c @@ -648,4 +648,3 @@ t_test_case_info write_basic_test_info[] = { (fp_test_case)NULL, (uint8_t)0 }, /* Array Termination element*/ }; // *INDENT-ON* - diff --git a/test/api_calib/test_calib_config.c b/test/api_calib/test_calib_config.c index eeffd05c3..4ea1f79c8 100644 --- a/test/api_calib/test_calib_config.c +++ b/test/api_calib/test_calib_config.c @@ -62,14 +62,14 @@ const uint8_t test_ecc_configdata[ATCA_ECC_CONFIG_SIZE] = { static device_object_meta_t calib_config_object_data[] = { - { TEST_TYPE_ECC_SIGN, 2, NULL }, - { TEST_TYPE_ECC_VERIFY, 15, NULL }, - { TEST_TYPE_ECC_GENKEY, 2, NULL }, - { TEST_TYPE_ECDH, 0, NULL }, - { TEST_TYPE_AES, 10, NULL }, - { TEST_TYPE_HMAC, 4, NULL }, - { TEST_TYPE_DATA, 11, NULL }, - { 0, 0, NULL } + { TEST_TYPE_ECC_SIGN, 2, NULL }, + { TEST_TYPE_ECC_VERIFY, 15, NULL }, + { TEST_TYPE_ECC_GENKEY, 2, NULL }, + { TEST_TYPE_ECDH, 0, NULL }, + { TEST_TYPE_AES, 10, NULL }, + { TEST_TYPE_HMAC, 4, NULL }, + { TEST_TYPE_DATA, 11, NULL }, + { 0, 0, NULL } }; ATCA_STATUS calib_config_get_slot_by_test(uint8_t test_type, uint16_t* handle) @@ -89,4 +89,3 @@ ATCA_STATUS calib_config_get_slot_by_test(uint8_t test_type, uint16_t* handle) return status; } #endif - diff --git a/test/api_crypto/test_crypto_pbkdf2.c b/test/api_crypto/test_crypto_pbkdf2.c index ca98a48ce..202f3376e 100644 --- a/test/api_crypto/test_crypto_pbkdf2.c +++ b/test/api_crypto/test_crypto_pbkdf2.c @@ -75,10 +75,8 @@ TEST(atca_cmd_basic_test, pdkdf2_hw_vectors) t_test_case_info test_crypto_pbkdf2_info[] = { - { REGISTER_TEST_CASE(atca_crypto_pbkdf2_sw, vectors), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, pdkdf2_hw_vectors), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_crypto_pbkdf2_sw, vectors), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, pdkdf2_hw_vectors), DEVICE_MASK(ATSHA204A) | DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, /* Array Termination element*/ { (fp_test_case)NULL, (uint8_t)0 }, }; - - diff --git a/test/atca_test.c b/test/atca_test.c index 1fd38050c..b43a1709e 100644 --- a/test/atca_test.c +++ b/test/atca_test.c @@ -228,7 +228,7 @@ void RunTNGTests(void) RunAllTests(tng_tests); } -#if defined(ATCA_MBEDTLS) || defined(ATCA_WOLFSSL) || defined(ATCA_OPENSSL) +#if defined(ATCA_MBEDTLS) void RunCryptoIntegrationTests(void) { RunAllTests(crypto_integration_tests); diff --git a/test/atca_test_config.c b/test/atca_test_config.c index 0933dc1e2..6950e6f51 100644 --- a/test/atca_test_config.c +++ b/test/atca_test_config.c @@ -251,10 +251,10 @@ static int opt_iface_type(int argc, char* argv[]) { gCfg->atcahid.dev_interface = ATCA_KIT_SWI_IFACE; } - //else if (0 == strcmp("spi", argv[2])) - //{ - // gCfg->atcahid.dev_interface = ATCA_KIT_SPI_IFACE; - //} + else if (0 == strcmp("spi", argv[2])) + { + gCfg->atcahid.dev_interface = ATCA_KIT_SPI_IFACE; + } } else { diff --git a/test/atca_test_console.c b/test/atca_test_console.c index 15004f7c7..73db0ebbd 100644 --- a/test/atca_test_console.c +++ b/test/atca_test_console.c @@ -64,6 +64,7 @@ int read_config(int argc, char* argv[]) uint8_t config[200]; size_t config_size = 0; size_t i = 0; + uint8_t zone = ATCA_ZONE_CONFIG; ((void)argc); ((void)argv); @@ -77,7 +78,7 @@ int read_config(int argc, char* argv[]) do { - status = atcab_get_zone_size(ATCA_ZONE_CONFIG, 0, &config_size); + status = atcab_get_zone_size(zone, 0, &config_size); if (status != ATCA_SUCCESS) { printf("atcab_get_zone_size() failed: %02x\r\n", status); @@ -611,7 +612,7 @@ int run_tng_tests(int argc, char* argv[]) return 0; } -#if defined(ATCA_MBEDTLS) || defined(ATCA_WOLFSSL) || defined(ATCA_OPENSSL) +#if defined(ATCA_MBEDTLS) int run_crypto_integration_tests(int argc, char* argv[]) { return run_test(argc, argv, RunCryptoIntegrationTests); diff --git a/test/mbedtls/test_mbedtls_ecdsa.c b/test/mbedtls/test_mbedtls_ecdsa.c index d2c4f17d9..d241c9412 100644 --- a/test/mbedtls/test_mbedtls_ecdsa.c +++ b/test/mbedtls/test_mbedtls_ecdsa.c @@ -192,9 +192,9 @@ TEST(atca_cmd_basic_test, mbedtls_ecdsa_sign) t_test_case_info test_mbedtls_ecdsa_info[] = { - { REGISTER_TEST_CASE(atca_cmd_basic_test, mbedtls_ecdsa_verify_nist), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, mbedtls_ecdsa_verify_nist_stored_key), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, - { REGISTER_TEST_CASE(atca_cmd_basic_test, mbedtls_ecdsa_sign), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, mbedtls_ecdsa_verify_nist), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, mbedtls_ecdsa_verify_nist_stored_key), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, + { REGISTER_TEST_CASE(atca_cmd_basic_test, mbedtls_ecdsa_sign), DEVICE_MASK_ECC | DEVICE_MASK(TA100) }, /* Array Termination element*/ { (fp_test_case)NULL, (uint8_t)0 }, }; diff --git a/test/vectors/aes_gcm_nist_vectors.h b/test/vectors/aes_gcm_nist_vectors.h index 3552c63a6..258985137 100644 --- a/test/vectors/aes_gcm_nist_vectors.h +++ b/test/vectors/aes_gcm_nist_vectors.h @@ -1,5 +1,3 @@ - - #ifndef AES_GCM_NIST_VECTORS_H #define AES_GCM_NIST_VECTORS_H diff --git a/test/vectors/ecdh_nist_vectors.c b/test/vectors/ecdh_nist_vectors.c index cc24c4eed..d88a013bb 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, 0xb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xe8, 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, 0xd3, 0xa6, 0xf2, 0xd6, 0xb0, 0x5b, 0x80, 0xb2, 0xff, 0x2a, 0xee, 0x4e, 0x77, }, - { 0x43, 0xe0, 0xe9, 0xd9, 0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 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, 0xa7, 0xea, 0x73, 0xea, 0x08, 0xd0, }, + { 0x4d, 0xfa, 0x12, 0xde, 0xfc, 0x60, 0x31, 0x90, 0x21, 0xb6, 0x81, 0xb3, 0x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15, 0xb8, 0x92, 0xc0, 0xf5, 0xd2, 0x65, 0x61, 0xf9, 0x7f, 0xa0, 0x4d, 0x1a, }, - { 0xdd, 0x5e, 0x9f, 0x70, 0xae, 0x74, 0x00, 0x73, 0xca, 0x02, 0x04, 0xdf, 0x60, 0x76, 0x3f, 0xb6,0x03, 0x6c, 0x45, 0x70, 0x9b, 0xf4, 0xa7, 0xbb, 0x4e, 0x67, 0x14, 0x12, 0xfa, 0xd6, 0x5d, 0xa3, }, - { 0x43, 0x0e, 0x6a, 0x4f, 0xba, 0x44, 0x49, 0xd7, 0x00, 0xd2, 0x73, 0x3e, 0x55, 0x7f, 0x66, 0xa3,0xbf, 0x3d, 0x50, 0x51, 0x7c, 0x12, 0x71, 0xb1, 0xdd, 0xae, 0x11, 0x61, 0xb7, 0xac, 0x79, 0x8c, }, + { 0xa2, 0xef, 0x85, 0x7a, 0x08, 0x1f, 0x9d, 0x6e, 0xb2, 0x06, 0xa8, 0x1c, 0x4c, 0xf7, 0x8a, 0x80,0x2b, 0xdf, 0x59, 0x8a, 0xe3, 0x80, 0xc8, 0x88, 0x6e, 0xcd, 0x85, 0xfd, 0xc1, 0xed, 0x76, 0x44, }, + { 0x56, 0x3c, 0x4c, 0x20, 0x41, 0x9f, 0x07, 0xbc, 0x17, 0xd0, 0x53, 0x9f, 0xad, 0xe1, 0x85, 0x5e,0x34, 0x83, 0x95, 0x15, 0xb8, 0x92, 0xc0, 0xf5, 0xd2, 0x65, 0x61, 0xf9, 0x7f, 0xa0, 0x4d, 0x1a, }, + { 0xdd, 0x5e, 0x9f, 0x70, 0xae, 0x74, 0x00, 0x73, 0xca, 0x02, 0x04, 0xdf, 0x60, 0x76, 0x3f, 0xb6,0x03, 0x6c, 0x45, 0x70, 0x9b, 0xf4, 0xa7, 0xbb, 0x4e, 0x67, 0x14, 0x12, 0xfa, 0xd6, 0x5d, 0xa3, }, + { 0x43, 0x0e, 0x6a, 0x4f, 0xba, 0x44, 0x49, 0xd7, 0x00, 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4c, 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 9a11ff581..e44b2229a 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, 0xf6, 0xef, 0x69, 0x97, 0xcd, 0x80, 0xdd, 0x21,0x82, 0xc3, 0x66, 0x53, 0xce, 0xf1, 0x0c, 0x65, 0x5d, 0x52, 0x45, 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xa6, 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, 0x7f, 0xca, 0xda, 0x0e, 0xcc, 0x46, 0x61, 0xd3, 0x57, 0x82, 0x30, 0xf2, 0x25, 0xa8, 0x75, 0xe6, 0x9a, 0xaa, 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, 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, 0xb7, 0x66, 0x70, 0x56, 0xe1, 0xe1, 0x1d, 0x6c, 0xaf, 0x6e, 0x45, 0x64, 0x3f, 0x8b, 0x21,0xe7, 0xa4, 0xbe, 0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5e, 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, }, - { 0x06, 0x9b, 0xa6, 0xcb, 0x06, 0xb4, 0x9d, 0x60, 0x81, 0x20, 0x66, 0xaf, 0xa1, 0x6e, 0xcf, 0x7b,0x51,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f6, 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, 0xaf, 0x19, 0x9d, 0xc9, 0x17, 0xf7, 0xb0, 0x66, 0xad, 0x65, 0x50, 0x5d, 0xab, 0x0e, 0x11, 0xe6, 0x94, 0x85, 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, 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, 0xe2, 0xbf, 0x3e, 0xd7, 0x42, 0xae, 0x11, 0x0b, 0x04, 0xad, 0xe8, 0x3a, 0x5d, 0xbd, 0x73, 0x58, 0xf2, 0x9a, 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0x5e, 0x4e, 0xb8, 0x69, 0x6c, 0xb2, 0x76, 0xe5, 0x16, 0x5b, 0x6a,0x9d, 0x48, 0x63, 0x45, 0xde, 0xdf, 0xb0, 0x94, 0xa7, 0x6e, 0x84, 0x42, 0xd0, 0x26, 0x37, 0x8d, }, false, "4 - Q changed" }, { - { 0x76, 0xf9, 0x87, 0xec, 0x54, 0x48, 0xdd, 0x72, 0x21, 0x9b, 0xd3, 0x0b, 0xf6, 0xb6, 0x6b, 0x07,0x75, 0xc8, 0x0b, 0x39, 0x48, 0x51, 0xa4, 0x3f, 0xf1, 0xf5, 0x37, 0xf1, 0x40, 0xa6, 0xe7, 0x22, 0x9e, 0xf8, 0xcd, 0x72, 0xad, 0x58, 0xb1, 0xd2, 0xd2, 0x02, 0x98, 0x53, 0x9d, 0x63, 0x47, 0xdd, 0x55, 0x98, 0x81, 0x2b, 0xc6, 0x53, 0x23, 0xac, 0xea, 0xf0, 0x52, 0x28, 0xf7, 0x38, 0xb5, 0xad, 0x3e, 0x8d, 0x9f, 0xe4, 0x10, 0x0f, 0xd7, 0x67, 0xc2, 0xf0, 0x98, 0xc7, 0x7c, 0xb9, 0x9c, 0x29, 0x92, 0x84, 0x3b, 0xa3, 0xee, 0xd9, 0x1d, 0x32, 0x44, 0x4f, 0x3b, 0x6d, 0xb6, 0xcd, 0x21, 0x2d, 0xd4, 0xe5, 0x60, 0x95, 0x48, 0xf4, 0xbb, 0x62, 0x81, 0x2a, 0x92, 0x0f, 0x6e, 0x2b, 0xf1, 0x58, 0x1b, 0xe1, 0xeb, 0xee, 0xbd, 0xd0, 0x6e, 0xc4, 0xe9, 0x71, 0x86, 0x2c, 0xc4, 0x20, 0x55, 0xca, }, - { 0x09, 0x30, 0x8e, 0xa5, 0xbf, 0xad, 0x6e, 0x5a, 0xdf, 0x40, 0x86, 0x34, 0xb3, 0xd5, 0xce, 0x92,0x40, 0xd3, 0x54, 0x42, 0xf7, 0xfe, 0x11, 0x64, 0x52, 0xaa, 0x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 0x92, 0x84, 0x3b, 0xa3, 0xee, 0xd9, 0x1d, 0x32, 0x44, 0x4f, 0x3b, 0x6d, 0xb6, 0xcd, 0x21, 0x2d, 0xd4, 0xe5, 0x60, 0x95, 0x48, 0xf4, 0xbb, 0x62, 0x81, 0x2a, 0x92, 0x0f, 0x6e, 0x2b, 0xf1, 0x58, 0x1b, 0xe1, 0xeb, 0xee, 0xbd, 0xd0, 0x6e, 0xc4, 0xe9, 0x71, 0x86, 0x2c, 0xc4, 0x20, 0x55, 0xca, }, + { 0x09, 0x30, 0x8e, 0xa5, 0xbf, 0xad, 0x6e, 0x5a, 0xdf, 0x40, 0x86, 0x34, 0xb3, 0xd5, 0xce, 0x92,0x40, 0xd3, 0x54, 0x42, 0xf7, 0xfe, 0x11, 0x64, 0x52, 0xaa, 0xec, 0x0d, 0x25, 0xbe, 0x8c, 0x24, }, + { 0xf4, 0x0c, 0x93, 0xe0, 0x23, 0xef, 0x49, 0x4b, 0x1c, 0x30, 0x79, 0xb2, 0xd1, 0x0e, 0xf6, 0x7f,0x31, 0x70, 0x74, 0x04, 0x95, 0xce, 0x2c, 0xc5, 0x7f, 0x8e, 0xe4, 0xb0, 0x61, 0x8b, 0x8e, 0xe5, }, + { 0x5c, 0xc8, 0xaa, 0x7c, 0x35, 0x74, 0x3e, 0xc0, 0xc2, 0x3d, 0xde, 0x88, 0xda, 0xbd, 0x5e, 0x4f,0xcd, 0x01, 0x92, 0xd2, 0x11, 0x6f, 0x69, 0x26, 0xfe, 0xf7, 0x88, 0xcd, 0xdb, 0x75, 0x4e, 0x73, }, + { 0x9c, 0x9c, 0x04, 0x5e, 0xba, 0xa1, 0xb8, 0x28, 0xc3, 0x2f, 0x82, 0xac, 0xe0, 0xd1, 0x8d, 0xae,0xbf, 0x5e, 0x15, 0x6e, 0xb7, 0xcb, 0xfd, 0xc1, 0xef, 0xf4, 0x39, 0x9a, 0x8a, 0x90, 0x0a, 0xe7, }, false, "1 - Message changed" }, { - { 0x60, 0xcd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 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" } diff --git a/test/vectors/pbkdf2_sha256_vectors.c b/test/vectors/pbkdf2_sha256_vectors.c index 3f67d1cbb..a36976c14 100644 --- a/test/vectors/pbkdf2_sha256_vectors.c +++ b/test/vectors/pbkdf2_sha256_vectors.c @@ -120,4 +120,3 @@ const pbkdf2_sha256_fixed_size_test_vector pbkdf2_sha256_fixed_size_test_vectors }; const size_t pbkdf2_sha256_fixed_size_test_vectors_count = sizeof(pbkdf2_sha256_fixed_size_test_vectors) / sizeof(pbkdf2_sha256_fixed_size_test_vector); - diff --git a/third_party/hal/zephyr/hal_zephyr.c b/third_party/hal/zephyr/hal_zephyr.c new file mode 100644 index 000000000..8a4f355eb --- /dev/null +++ b/third_party/hal/zephyr/hal_zephyr.c @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2020 Microchip Technology Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "hal/atca_hal.h" + +#include +#include + + +#ifndef ATCA_MUTEX_TIMEOUT +#define ATCA_MUTEX_TIMEOUT K_FOREVER +#endif + +/** + * \defgroup hal_ Hardware abstraction layer (hal_) + * + * \brief + * These methods define the hardware abstraction layer for communicating with a CryptoAuth device + * + @{ */ + +#if !defined(ATCA_PLATFORM_MALLOC) +void* hal_malloc(size_t size) +{ + return k_malloc(size); +} +#endif + +#if !defined(ATCA_PLATFORM_FREE) +void hal_free(void* ptr) +{ + k_free(ptr); +} +#endif + +/** \brief This function delays for a number of microseconds. + * + * \param[in] delay number of microseconds to delay + */ +void hal_delay_us(uint32_t delay) +{ + k_busy_wait(delay); +} + +/** \brief This function delays for a number of tens of microseconds. + * + * \param[in] delay number of 0.01 milliseconds to delay + */ +void hal_delay_10us(uint32_t delay) +{ + k_usleep(delay * 10); +} + + +/** \brief This function delays for a number of milliseconds. + * + * You can override this function if you like to do + * something else in your system while delaying. + * \param[in] delay number of milliseconds to delay + */ + +/* ASF already has delay_ms - see delay.h */ +void hal_delay_ms(uint32_t delay) +{ + hal_delay_us(delay * 1000); +} + + +ATCA_STATUS hal_create_mutex(void ** ppMutex, char* pName) +{ + (void)pName; + + if (!ppMutex) + { + return ATCA_BAD_PARAM; + } + + (*ppMutex) = (struct k_mutex*)k_malloc(sizeof(struct k_mutex)); + + if (!*ppMutex) + { + return ATCA_FUNC_FAIL; + } + + k_mutex_init((struct k_mutex*)(*ppMutex)); + + return ATCA_SUCCESS; +} + +ATCA_STATUS hal_destroy_mutex(void * pMutex) +{ + if (!pMutex) + { + return ATCA_BAD_PARAM; + } + + k_free(pMutex); + + return ATCA_SUCCESS; +} + +ATCA_STATUS hal_lock_mutex(void * pMutex) +{ + if (!pMutex) + { + return ATCA_BAD_PARAM; + } + + if (k_mutex_lock((struct k_mutex*)pMutex, ATCA_MUTEX_TIMEOUT)) + { + return ATCA_GEN_FAIL; + } + else + { + return ATCA_SUCCESS; + } +} + +ATCA_STATUS hal_unlock_mutex(void * pMutex) +{ + if (!pMutex) + { + return ATCA_BAD_PARAM; + } + + k_mutex_unlock((struct k_mutex*)pMutex); + + return ATCA_SUCCESS; +} + + +/** @} */ diff --git a/third_party/hal/zephyr/hal_zephyr_i2c.c b/third_party/hal/zephyr/hal_zephyr_i2c.c new file mode 100644 index 000000000..f7877aa3a --- /dev/null +++ b/third_party/hal/zephyr/hal_zephyr_i2c.c @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2020 Microchip Technology Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include "hal/atca_hal.h" + +/** \defgroup hal_ Hardware abstraction layer (hal_) + * + * \brief + * These methods define the hardware abstraction layer for communicating with a CryptoAuth device + * + @{ */ + + +/** \brief The function return pre defined macro value for corrsponding i2c speed + * + * \param[in] speed As input, i2c clock speed in HZ + * + * \return Zephyr I2C speed constant + */ +static uint32_t hal_zephyr_i2c_convert_speed(const uint32_t speed) +{ + if (400000 < speed) + { + return I2C_SPEED_FAST_PLUS; + } + else if (100000 < speed) + { + return I2C_SPEED_FAST; + } + else + { + return I2C_SPEED_STANDARD; + } +} + +/** \brief Configure the zephyr i2c peripheral + * \return ATCA_SUCCESS otherwise an error + */ +static ATCA_STATUS hal_zephyr_i2c_configure( + const struct device * zdev, /**< Zephyr device to configure */ + const uint32_t speed /**< baud rate (typically 100000 or 400000) */ +) +{ + uint32_t i2c_cfg = I2C_MODE_MASTER | I2C_SPEED_SET(hal_zephyr_i2c_convert_speed(speed)); + + if (i2c_configure(zdev, i2c_cfg)) + { + return ATCA_GEN_FAIL; + } + else + { + return ATCA_SUCCESS; + } +} + + +/** \brief HAL implementation of I2C init + * + * this implementation assumes I2C peripheral has been enabled by user. It only initialize an + * I2C interface using given config. + * + * \param[in] hal pointer to HAL specific data that is maintained by this HAL + * \param[in] cfg pointer to HAL specific configuration data that is used to initialize this HAL + * \return ATCA_SUCCESS on success, otherwise an error code. + */ + +ATCA_STATUS hal_i2c_init(ATCAIface iface, ATCAIfaceCfg* cfg) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + + if (iface && cfg && cfg->cfg_data) + { + if (!iface->hal_data) + { + const struct device * zdev = device_get_binding(cfg->cfg_data); + + if (ATCA_SUCCESS == (status = hal_zephyr_i2c_configure(zdev, cfg->atcai2c.baud))) + { + iface->hal_data = (void*)zdev; + } + } + else + { + status = ATCA_SUCCESS; + } + } + + return status; +} + +/** \brief HAL implementation of I2C post init + * \param[in] iface instance + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_i2c_post_init(ATCAIface iface) +{ + ((void)iface); + return ATCA_SUCCESS; +} + +/** \brief HAL implementation of I2C send + * \param[in] iface instance + * \param[in] word_address device transaction type + * \param[in] txdata pointer to space to bytes to send + * \param[in] txlength number of bytes to send + * \return ATCA_SUCCESS on success, otherwise an error code. + */ + +ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t address, uint8_t *txdata, int txlength) +{ + struct device * zdev = (struct device *)atgetifacehaldat(iface); + + if (!zdev || (0 == txlength) || (NULL == txdata)) + { + return ATCA_BAD_PARAM; + } + if (i2c_write(zdev, txdata, txlength, (address >> 0x1))) + { + return ATCA_TX_FAIL; + } + + return ATCA_SUCCESS; +} + +/** \brief HAL implementation of I2C receive function + * \param[in] iface Device to interact with. + * \param[in] address device address + * \param[out] rxdata Data received will be returned here. + * \param[in,out] rxlength As input, the size of the rxdata buffer. + * As output, the number of bytes received. + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t address, uint8_t *rxdata, uint16_t *rxlength) +{ + struct device * zdev = (struct device *)atgetifacehaldat(iface); + + if (!zdev || (NULL == rxlength) || (NULL == rxdata)) + { + return ATCA_BAD_PARAM; + } + + if (i2c_read(zdev, rxdata, *rxlength, (address >> 0x1))) + { + return ATCA_RX_FAIL; + } + + return ATCA_SUCCESS; +} + +/** \brief Perform control operations for the kit protocol + * \param[in] iface Interface to interact with. + * \param[in] option Control parameter identifier + * \param[in] param Optional pointer to parameter value + * \param[in] paramlen Length of the parameter + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_i2c_control(ATCAIface iface, uint8_t option, void* param, size_t paramlen) +{ + (void)param; + (void)paramlen; + + struct device * zdev = (struct device *)atgetifacehaldat(iface); + + if (zdev) + { + if (ATCA_HAL_CHANGE_BAUD == option && sizeof(uint32_t) == paramlen) + { + return hal_zephyr_i2c_configure(zdev, *(uint32_t*)param); + } + else + { + return ATCA_UNIMPLEMENTED; + } + } + return ATCA_BAD_PARAM; +} + +/** \brief manages reference count on given bus and releases resource if no more refences exist + * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation + * \return ATCA_SUCCESS on success, otherwise an error code. + */ + +ATCA_STATUS hal_i2c_release(void *hal_data) +{ + return ATCA_SUCCESS; +} + +/** @} */ diff --git a/third_party/hal/zephyr/hal_zephyr_spi.c b/third_party/hal/zephyr/hal_zephyr_spi.c new file mode 100644 index 000000000..6665d6324 --- /dev/null +++ b/third_party/hal/zephyr/hal_zephyr_spi.c @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2020 Microchip Technology Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + + +#include "hal/atca_hal.h" +#include "hal_zephyr_spi.h" + +/** \defgroup hal_ Hardware abstraction layer (hal_) + * + * \brief + * These methods define the hardware abstraction layer for communicating with a CryptoAuth device + * + @{ */ + +typedef struct atca_spi_host_s +{ + struct device * dev; + struct spi_cs_control cs; + struct spi_config cfg; +} atca_spi_host_t; + +/** \brief HAL implementation of SPI init + * + * this implementation assumes SPI peripheral has been enabled by user . It only initialize an + * SPI interface using given config. + * + * \param[in] hal pointer to HAL specific data that is maintained by this HAL + * \param[in] cfg pointer to HAL specific configuration data that is used to initialize this HAL + * \return ATCA_SUCCESS on success, otherwise an error code. + */ + +ATCA_STATUS hal_spi_init(ATCAIface iface, ATCAIfaceCfg *cfg) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + + if (iface && cfg && cfg->cfg_data) + { + if (!iface->hal_data) + { + atca_spi_host_t * hal_data = malloc(sizeof(atca_spi_host_t)); + atca_spi_host_config_t * cfg_data = (atca_spi_host_config_t*)cfg->cfg_data; + + if (hal_data) + { + memset(hal_data, 0, sizeof(hal_data)); + + hal_data->cfg.operation = SPI_OP_MODE_MASTER | SPI_MODE_CPOL | SPI_MODE_CPHA | SPI_TRANSFER_MSB | + SPI_WORD_SET(8); + hal_data->cfg.frequency = cfg->atcaspi.baud; + + hal_data->dev = device_get_binding(cfg_data->device_name); + + hal_data->cs.gpio_dev = device_get_binding(cfg_data->gpio_name); + hal_data->cs.gpio_pin = cfg->atcaspi.select_pin; + hal_data->cs.gpio_dt_flags = GPIO_ACTIVE_LOW; + + hal_data->cfg.cs = &hal_data->cs; + + iface->hal_data = hal_data; + status = ATCA_SUCCESS; + } + else + { + status = ATCA_ALLOC_FAILURE; + } + } + } + printf("hal_spi_init: %d\n", status); + return status; +} + +ATCA_STATUS hal_spi_post_init(ATCAIface iface) +{ + return ATCA_SUCCESS; +} + + +/** \brief HAL implementation to assert the device chip select + * \param[in] iface Device to interact with. + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_spi_select(ATCAIface iface) +{ + atca_spi_host_t * hal_data = (atca_spi_host_t *)atgetifacehaldat(iface); + + if (hal_data) + { + hal_data->cfg.operation |= SPI_HOLD_ON_CS | SPI_LOCK_ON; + return ATCA_SUCCESS; + } + else + { + return ATCA_BAD_PARAM; + } +} + + +/** \brief HAL implementation to deassert the device chip select + * \param[in] iface Device to interact with. + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_spi_deselect(ATCAIface iface) +{ + atca_spi_host_t * hal_data = (atca_spi_host_t *)atgetifacehaldat(iface); + + if (hal_data) + { + hal_data->cfg.operation &= ~(SPI_HOLD_ON_CS | SPI_LOCK_ON); + spi_release(hal_data->dev, &hal_data->cfg); + return ATCA_SUCCESS; + } + else + { + return ATCA_BAD_PARAM; + } +} + + +/** \brief HAL implementation of SPI receive function + * \param[in] iface Device to interact with. + * \param[in] word_address device transaction type + * \param[out] rxdata Data received will be returned here. + * \param[in,out] len As input, the size of the rxdata buffer. + * As output, the number of bytes received. + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_spi_receive(ATCAIface iface, uint8_t flags, uint8_t *rxdata, uint16_t *rxlength) +{ + ATCA_STATUS status = ATCA_BAD_PARAM; + atca_spi_host_t * hal_data = (atca_spi_host_t *)atgetifacehaldat(iface); + + if (hal_data) + { + struct spi_buf rxbuf = { rxdata, *rxlength }; + struct spi_buf_set rxbufs = { &rxbuf, 1 }; + + if (!spi_read(hal_data->dev, &hal_data->cfg, &rxbufs)) + { + status = ATCA_SUCCESS; + } + else + { + status = ATCA_COMM_FAIL; + } + } + return status; +} + + +/** \brief HAL implementation of SPI send + * \param[in] iface instance + * \param[in] word_address transaction type + * \param[in] txdata data to be send to device + * \param[in] txdata pointer to space to bytes to send + * \param[in] len number of bytes to send + * \return ATCA_SUCCESS on success, otherwise an error code. + */ + +ATCA_STATUS hal_spi_send(ATCAIface iface, uint8_t flags, uint8_t *txdata, int txlen) +{ + ATCA_STATUS status = ATCA_SUCCESS; + atca_spi_host_t * hal_data = (atca_spi_host_t *)atgetifacehaldat(iface); + + if (hal_data) + { + struct spi_buf txbuf = { txdata, txlen }; + struct spi_buf_set txbufs = { &txbuf, 1 }; + + if(!spi_write(hal_data->dev, &hal_data->cfg, &txbufs)) + { + status = ATCA_SUCCESS; + } + else + { + status = ATCA_COMM_FAIL; + } + + } + + return status; +} + + +/** \brief Perform control operations for the kit protocol + * \param[in] iface Interface to interact with. + * \param[in] option Control parameter identifier + * \param[in] param Optional pointer to parameter value + * \param[in] paramlen Length of the parameter + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_spi_control(ATCAIface iface, uint8_t option, void* param, size_t paramlen) +{ + (void)param; + (void)paramlen; + + if (iface && iface->mIfaceCFG) + { + switch (option) + { + case ATCA_HAL_CONTROL_SELECT: + return hal_spi_select(iface); + case ATCA_HAL_CONTROL_DESELECT: + return hal_spi_deselect(iface); + default: + printf("hal_spi_control: %d, %lu\n", option, paramlen); + return ATCA_UNIMPLEMENTED; + } + } + return ATCA_BAD_PARAM; +} + +/** \brief manages reference count on given bus and releases resource if no more refences exist + * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation + * \return ATCA_SUCCESS on success, otherwise an error code. + */ +ATCA_STATUS hal_spi_release(void *hal_data) +{ + return ATCA_SUCCESS; +} + +/** @} */ diff --git a/third_party/hal/zephyr/hal_zephyr_spi.h b/third_party/hal/zephyr/hal_zephyr_spi.h new file mode 100644 index 000000000..bdf71b4f9 --- /dev/null +++ b/third_party/hal/zephyr/hal_zephyr_spi.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2020 Microchip Technology Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef HAL_ZEPHYR_SPI_H_ +#define HAL_ZEPHYR_SPI_H_ + +typedef struct atca_spi_host_config_s +{ + const char * device_name; + const char * gpio_name; +} atca_spi_host_config_t; + +#endif diff --git a/third_party/wolfssl_settings.h.in b/third_party/wolfssl_settings.h.in new file mode 100644 index 000000000..b2e63c664 --- /dev/null +++ b/third_party/wolfssl_settings.h.in @@ -0,0 +1,40 @@ +/* user_settings.h */ + +/* Place OS specific preprocessor flags, defines, includes here, will be + included into every file because types.h includes it */ + +#ifndef USER_SETTINGS_H +#define USER_SETTINGS_H + +#ifdef __cplusplus + extern "C" { +#endif + +#define WC_NO_HARDEN + +#define HAVE_ECC + +#define HAVE_ALL_CURVES + +#define WOLFCRYPT_ONLY + +#define WOLFSSL_PEM_TO_DER + +#define WOLFSSL_VALIDATE_ECC_IMPORT + +#define WOLFSSL_AES_DIRECT + +#define HAVE_AESGCM + +#define WOLFSSL_CMAC + +#define NO_OLD_TLS + +#define NO_MD5 + + +#ifdef __cplusplus + } /* extern "C" */ +#endif + +#endif