diff --git a/CMakeLists.txt b/CMakeLists.txt index cfc144c..50d172c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ # # CMakeLists.txt file for cryptoauthlib # -cmake_minimum_required(VERSION 3.5) -set(CRYPTOAUTHLIB_DIR "cryptoauthlib/lib" ) -set(COMPONENT_SRCDIRS "${CRYPTOAUTHLIB_DIR}/atcacert" +cmake_minimum_required( VERSION 3.5 ) +set( CRYPTOAUTHLIB_DIR "cryptoauthlib/lib" ) +set( COMPONENT_SRCDIRS "${CRYPTOAUTHLIB_DIR}/atcacert" "${CRYPTOAUTHLIB_DIR}/calib" "${CRYPTOAUTHLIB_DIR}/crypto" "${CRYPTOAUTHLIB_DIR}/crypto/hashes" @@ -14,26 +14,26 @@ set(COMPONENT_SRCDIRS "${CRYPTOAUTHLIB_DIR}/atcacert" "port" ) -set(COMPONENT_SRCS "${CRYPTOAUTHLIB_DIR}/hal/atca_hal.c" +set( COMPONENT_SRCS "${CRYPTOAUTHLIB_DIR}/hal/atca_hal.c" "${CRYPTOAUTHLIB_DIR}/hal/hal_freertos.c" "${CRYPTOAUTHLIB_DIR}/hal/hal_esp32_timer.c" "${CRYPTOAUTHLIB_DIR}/../third_party/atca_mbedtls_patch.c" ) -set(COMPONENT_INCLUDEDIRS "${CRYPTOAUTHLIB_DIR}/" +set( COMPONENT_INCLUDEDIRS "${CRYPTOAUTHLIB_DIR}/" "${CRYPTOAUTHLIB_DIR}/hal" "${CRYPTOAUTHLIB_DIR}/../app/tng" "${CRYPTOAUTHLIB_DIR}/../third_party" "port" ) -set(COMPONENT_PRIV_INCLUDEDIRS "port/include") +set( COMPONENT_PRIV_INCLUDEDIRS "port/include" ) -set(COMPONENT_REQUIRES "mbedtls" "freertos" "driver" "Core2-for-AWS-IoT-EduKit") +set( COMPONENT_REQUIRES "mbedtls" "freertos" "driver" "Core2-for-AWS-IoT-EduKit" ) # Don't include the default interface configurations from cryptoauthlib -set(COMPONENT_EXCLUDE_SRCS "${CRYPTOAUTHLIB_DIR}/atca_cfgs.c") -set(COMPONENT_CFLAGS "ESP32") +set( COMPONENT_EXCLUDE_SRCS "${CRYPTOAUTHLIB_DIR}/atca_cfgs.c" ) +set( COMPONENT_CFLAGS "ESP32" ) idf_component_register( SRC_DIRS "${COMPONENT_SRCDIRS}" INCLUDE_DIRS "${COMPONENT_INCLUDEDIRS}" @@ -43,11 +43,10 @@ idf_component_register( SRC_DIRS "${COMPONENT_SRCDIRS}" EXCLUDE_SRCS "${COMPONENT_EXCLUDE_SRCS}" ) -if ( IDF_VERSION_MAJOR EQUAL 4 AND IDF_VERSION_MINOR LESS_EQUAL 3 AND IDF_VERSION_PATCH LESS 1 AND CONFIG_SOFTWARE_CRYPTO_SUPPORT ) +if( IDF_VERSION_MAJOR EQUAL 4 AND IDF_VERSION_MINOR LESS_EQUAL 3 AND IDF_VERSION_PATCH LESS 1 ) target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DATCA_ENABLE_DEPRECATED" ) - message( FATAL_ERROR "Major: ${IDF_VERSION_MAJOR} Min: ${IDF_VERSION_MINOR} Patch: ${IDF_VERSION_PATCH}" ) endif() -target_sources(${COMPONENT_LIB} PRIVATE ${COMPONENT_SRCS}) -target_compile_definitions(${COMPONENT_LIB} PRIVATE ${COMPONENT_CFLAGS}) -target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-pointer-sign) +target_sources( ${COMPONENT_LIB} PRIVATE ${COMPONENT_SRCS} ) +target_compile_definitions( ${COMPONENT_LIB} PRIVATE ${COMPONENT_CFLAGS} ) +target_compile_options( ${COMPONENT_LIB} PRIVATE -Wno-pointer-sign ) diff --git a/Kconfig b/Kconfig index fe873c0..b9bfd51 100644 --- a/Kconfig +++ b/Kconfig @@ -1,18 +1,18 @@ menu "esp-cryptoauthlib" choice ATECC608A_TYPE - prompt "Choose the type of ATECC608A chip" + prompt "Choose the type of ATECC608 chip" default ATECC608A_TNG help - There are three types of ATECC608A ( Secure Element) chips, which are + There are three types of ATECC608 ( Secure Element) chips, which are Trust & GO, TrustFLex and Trust Custom. For more details consult README file of esp_cryptoauth_utility which is part of esp-cryptoauthlib component. config ATECC608A_TNG - bool "ATECC608A chip type Trust & GO" + bool "ATECC608 chip type Trust & GO" config ATECC608A_TFLEX - bool "ATECC608A chip type TrustFlex" + bool "ATECC608 chip type TrustFlex" config ATECC608A_TCUSTOM - bool "ATECC608A chip type TrustCustom" + bool "ATECC608 chip type TrustCustom" endchoice config ATCA_MBEDTLS_ECDSA @@ -22,27 +22,27 @@ menu "esp-cryptoauthlib" Enable Hardware ECDSA config ATCA_MBEDTLS_ECDSA_SIGN - bool "Enable ATECC608A sign operations in mbedTLS" + bool "Enable ATECC608 sign operations in mbedTLS" depends on ATCA_MBEDTLS_ECDSA select MBEDTLS_ATCA_HW_ECDSA_SIGN select MBEDTLS_ECP_DP_SECP256R1_ENABLED config ATCA_MBEDTLS_ECDSA_VERIFY - bool "Enable ATECC608A verify operations in mbedTLS" + bool "Enable ATECC608 verify operations in mbedTLS" depends on ATCA_MBEDTLS_ECDSA select MBEDTLS_ATCA_HW_ECDSA_VERIFY select MBEDTLS_ECP_DP_SECP256R1_ENABLED config ATCA_I2C_SDA_PIN - int "I2C SDA pin used to communicate with the ATECC608A" + int "I2C SDA pin used to communicate with the ATECC608" default 21 config ATCA_I2C_SCL_PIN - int "I2C SCL pin used to communicate with the ATECC608A" + int "I2C SCL pin used to communicate with the ATECC608" default 22 config ATCA_I2C_ADDRESS - hex "I2C device address of the ATECC608A" + hex "I2C device address of the ATECC608" default 0xC0 if ATECC608A_TCUSTOM default 0x6C if ATECC608A_TFLEX default 0x6A if ATECC608A_TNG diff --git a/README.md b/README.md index 47bde66..c0c7fd6 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # ESP-CRYPTOAUTHLIB -This is a port of Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib) to work on the [M5Stack Core2 for AWS IoT EduKit](https://aws.amazon.com/iot/edukit/#Get_started_with_AWS_IoT_EduKit) using the ESP-IDF. It contains necessary build support to use cryptoauthlib with ESP-IDF as well as `esp_cryptoauthlib_utility` for configuring and provisiong ATECC608 chip integrated with the Core2 for AWS. The cryptoauthlib folder is a submodule of Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib). This ported library requires the [Core2 for AWS IoT EduKit board support package](https://github.com/m5stack/Core2-for-AWS-IoT-EduKit) (BSP) to be included as well for thread-safe access to the I2C bus using Rop Gonggrijp's I2C Manager and power using the ported Mika Tuupola's AXP192 driver. +This is a port of Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib) to work on the [M5Stack Core2 for AWS IoT EduKit](https://aws.amazon.com/iot/edukit/#Get_started_with_AWS_IoT_EduKit). It contains necessary build support to use cryptoauthlib with ESP-IDF as well as `esp_cryptoauthlib_utility` for configuring and provisiong ATECC608 chip integrated with the Core2 for AWS. The cryptoauthlib folder is a submodule of Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib). This ported library requires the [Core2 for AWS IoT EduKit board support package](https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/tree/BSP-dev) (BSP) to be included for thread-safe access to the I2C bus using Rop Gonggrijp's I2C Manager, and power to the chip using the ported Mika Tuupola's AXP192 driver. ## Requirements -* [ESP-IDF](https://github.com/espressif/esp-idf) version should be `release/v4.3` or newer. +* Core2 for AWS IoT EduKit BSP(https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/tree/BSP-dev) +* Configuration in [sdkconfig.defaults](https://github.com/aws-iot-edukit/Project_Template-Core2_for_AWS/blob/main/sdkconfig.defaults) +* Preferred [ESP-IDF](https://github.com/espressif/esp-idf) tag `release/v4.3` or newer OR use PlatformIO with [Espressif32 platform](https://github.com/platformio/platform-espressif32/) v3.3.1+. * Environment variable `IDF_PATH` should be set ## How to use esp-cryptoauthlib with ESP-IDF @@ -17,9 +19,6 @@ There are two ways to use **esp-cryptoauthlib** and the Core2 for AWS BSP in you ``` mkdir components cd components - git clone https://github.com/espressif/esp-cryptoauthlib.git --recurse-submodules - git clone https://github.com/m5stack/Core2-for-AWS-IoT-EduKit.git --recurse-submodules - ``` 2) Add **esp-cryptoauthlib** as an extra component in your project. @@ -28,6 +27,11 @@ There are two ways to use **esp-cryptoauthlib** and the Core2 for AWS BSP in you git clone https://github.com/espressif/esp-cryptoauthlib.git --recurse-submodules git clone https://github.com/m5stack/Core2-for-AWS-IoT-EduKit.git --recurse-submodules ``` +3) Enable the correct configurations for ESP-IDF using KConfig menu: +``` + idf.py menuconfig +``` + If you have downloaded the repos without using the --recurse-submodules argument, you need to run this command in each repo: ``` @@ -36,8 +40,14 @@ git submodule update --init --recursive * Include `esp-cryptoauthlib` in `ESP-IDF` with setting `EXTRA_COMPONENT_DIRS` in CMakeLists.txt/Makefile of your project.For reference see [Optional Project Variables](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#optional-project-variables) - - -## How to configure and provision ATECC608A on Core2 for AWS +## How to configure and provision ATECC608 on Core2 for AWS The python utilty `esp_cryptoauth_utility` helps to configure, generate resources as well as provision ATECC608 chip integrated with the Core2 for AWS. For detailed instructions on how to use the utility please refer utility [README.md](esp_cryptoauth_utility/README.md) + +## Security + +See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. + +## License + +This library is licensed under the MIT-0 License. See the LICENSE file. diff --git a/idf_component.yml b/idf_component.yml index 7e512cd..7d1e201 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -3,4 +3,4 @@ description: "esp-cryptoauthlib: The port of Microchip CryptoAuthentication Libr url: https://github.com/espressif/esp-cryptoauthlib dependencies: idf: - version: ">=4.3" + version: ">=4.3.1"