From 57e8d689fc234f1907b71fba8d9b7a27b1b28dd4 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Mon, 30 Sep 2024 19:26:26 +0200 Subject: [PATCH 1/3] Add sdkdefaults for esp32 Signed-off-by: Pol Henarejos --- sdkconfig.defaults | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sdkconfig.defaults diff --git a/sdkconfig.defaults b/sdkconfig.defaults new file mode 100644 index 0000000..a7833a5 --- /dev/null +++ b/sdkconfig.defaults @@ -0,0 +1,54 @@ +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration +# +IGNORE_UNKNOWN_FILES_FOR_MANAGED_COMPONENTS=1 + +CONFIG_TINYUSB=y + +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="pico-keys-sdk/config/esp32/partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="pico-keys-sdk/config/esp32/partitions.csv" +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_WL_SECTOR_SIZE_512=y +CONFIG_WL_SECTOR_MODE_PERF=y + +CONFIG_MBEDTLS_CMAC_C=y +CONFIG_MBEDTLS_CHACHA20_C=y +CONFIG_MBEDTLS_POLY1305_C=y +CONFIG_MBEDTLS_CHACHAPOLY_C=y +CONFIG_MBEDTLS_HKDF_C=y +CONFIG_MBEDTLS_HARDWARE_ECC=y +CONFIG_MBEDTLS_HARDWARE_GCM=y +CONFIG_MBEDTLS_DES_C=y +# CONFIG_MBEDTLS_HARDWARE_MPI is not set +CONFIG_MBEDTLS_HARDWARE_SHA=y +CONFIG_MBEDTLS_HARDWARE_AES=y +# CONFIG_MBEDTLS_ROM_MD5 is not set +CONFIG_MBEDTLS_SHA512_C=y +CONFIG_MBEDTLS_TLS_DISABLED=y +# CONFIG_MBEDTLS_TLS_ENABLED is not set +# CONFIG_ESP_TLS_USE_DS_PERIPHERAL is not set +# CONFIG_ESP_WIFI_ENABLED is not set +# CONFIG_ESP_WIFI_MBEDTLS_CRYPTO is not set +# CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT is not set +# CONFIG_WPA_MBEDTLS_CRYPTO is not set +# CONFIG_MBEDTLS_PSK_MODES is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_RSA is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA is not set +# CONFIG_MBEDTLS_SSL_RENEGOTIATION is not set +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 is not set +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +# CONFIG_MBEDTLS_SSL_ALPN is not set +# CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set +# CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS is not set +# CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set +# CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA is not set +# CONFIG_ESP_WIFI_ENABLE_WPA3_SAE is not set +# CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA is not set + +CONFIG_ESP_COREDUMP_ENABLE_TO_UART=y From 20b5084eee04372cedb069e4668af33e2e5835a8 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Mon, 30 Sep 2024 19:42:44 +0200 Subject: [PATCH 2/3] Fix build Signed-off-by: Pol Henarejos --- CMakeLists.txt | 139 +++++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 67 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0464422..f4bfd13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,43 +1,43 @@ - # - # This file is part of the Pico OpenPGP distribution (https://github.com/polhenarejos/pico-openpgp). - # Copyright (c) 2022 Pol Henarejos. - # - # This program is free software: you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation, version 3. - # - # This program is distributed in the hope that it will be useful, but - # WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - # General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program. If not, see . - # +# +# This file is part of the Pico OpenPGP distribution (https://github.com/polhenarejos/pico-openpgp). +# Copyright (c) 2022 Pol Henarejos. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# cmake_minimum_required(VERSION 3.13) if(ESP_PLATFORM) -set(EXTRA_COMPONENT_DIRS src pico-keys-sdk/src) -include($ENV{IDF_PATH}/tools/cmake/project.cmake) + set(EXTRA_COMPONENT_DIRS src pico-keys-sdk/src) + include($ENV{IDF_PATH}/tools/cmake/project.cmake) else() -if(ENABLE_EMULATION) -else() -include(pico_sdk_import.cmake) -endif() + if(ENABLE_EMULATION) + else() + include(pico_sdk_import.cmake) + endif() -project(pico_openpgp C CXX ASM) + project(pico_openpgp C CXX ASM) -set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 17) + set(CMAKE_C_STANDARD 11) + set(CMAKE_CXX_STANDARD 17) -if(ENABLE_EMULATION) -else() -pico_sdk_init() -endif() + if(ENABLE_EMULATION) + else() + pico_sdk_init() + endif() -add_executable(pico_openpgp) + add_executable(pico_openpgp) endif() set(SOURCES ${SOURCES} @@ -45,49 +45,54 @@ set(SOURCES ${SOURCES} ${CMAKE_CURRENT_LIST_DIR}/src/openpgp/files.c ${CMAKE_CURRENT_LIST_DIR}/src/openpgp/piv.c ${CMAKE_CURRENT_LIST_DIR}/src/openpgp/management.c - ) +) + +set(USB_ITF_CCID 1) +set(USB_ITF_WCID 1) +include(pico-keys-sdk/pico_keys_sdk_import.cmake) +if(ESP_PLATFORM) + project(pico_openpgp) +endif() set(INCLUDES ${INCLUDES} ${CMAKE_CURRENT_LIST_DIR}/src/openpgp - ) - -set(USB_ITF_CCID 1) -include(pico-keys-sdk/pico_keys_sdk_import.cmake) -if(ESP_PLATFORM) - project(pico_fido) -endif() - -if(NOT ESP_PLATFORM) -target_sources(pico_openpgp PUBLIC ${SOURCES}) -target_include_directories(pico_openpgp PUBLIC ${INCLUDES}) - -target_compile_options(pico_openpgp PUBLIC - -Wall - -Werror ) +if(NOT ESP_PLATFORM) + target_sources(pico_openpgp PUBLIC ${SOURCES}) + target_include_directories(pico_openpgp PUBLIC ${INCLUDES}) -if(ENABLE_EMULATION) - -target_compile_options(pico_openpgp PUBLIC - -fdata-sections - -ffunction-sections + target_compile_options(pico_openpgp PUBLIC + -Wall ) -if(APPLE) -target_link_options(pico_openpgp PUBLIC - -Wl,-dead_strip - ) -else() -target_link_options(pico_openpgp PUBLIC - -Wl,--gc-sections - ) -endif (APPLE) -target_link_libraries(pico_openpgp PRIVATE pthread m) -else() + if(NOT MSVC) + target_compile_options(pico_openpgp PUBLIC + -Werror + ) + endif() -pico_add_extra_outputs(pico_openpgp) + if(ENABLE_EMULATION) + if(NOT MSVC) + target_compile_options(pico_openpgp PUBLIC + -fdata-sections + -ffunction-sections + ) + endif() + if(APPLE) + target_link_options(pico_openpgp PUBLIC + -Wl,-dead_strip + ) + elseif(MSVC) + target_compile_options(pico_openpgp PUBLIC + -WX + ) -#target_compile_definitions(pico_openpgp PRIVATE MBEDTLS_ECDSA_DETERMINISTIC=1) - -target_link_libraries(pico_openpgp PRIVATE pico_keys_sdk pico_stdlib tinyusb_device tinyusb_board pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id pico_aon_timer) -endif() + target_link_libraries(pico_openpgp PUBLIC wsock32 ws2_32 Bcrypt) + else() + target_link_options(pico_openpgp PUBLIC + -Wl,--gc-sections + ) + endif(APPLE) + target_link_libraries(pico_openpgp PRIVATE pthread m) + endif() endif() + From f1f6800b6030a89b76e6572dde0dcb557268277f Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Mon, 30 Sep 2024 19:42:52 +0200 Subject: [PATCH 3/3] Fix ESP32 support. Signed-off-by: Pol Henarejos --- pico-keys-sdk | 2 +- src/openpgp/CMakeLists.txt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/openpgp/CMakeLists.txt diff --git a/pico-keys-sdk b/pico-keys-sdk index 739e9f1..e2b3eac 160000 --- a/pico-keys-sdk +++ b/pico-keys-sdk @@ -1 +1 @@ -Subproject commit 739e9f1b98c4f8aacedfa67a11df87d773ebf776 +Subproject commit e2b3eacd89a0e857ef5c6b56ff4661fa0fba7242 diff --git a/src/openpgp/CMakeLists.txt b/src/openpgp/CMakeLists.txt new file mode 100644 index 0000000..31d66c9 --- /dev/null +++ b/src/openpgp/CMakeLists.txt @@ -0,0 +1,6 @@ +idf_component_register( + SRCS ${SOURCES} + INCLUDE_DIRS . ../../pico-keys-sdk/src ../../pico-keys-sdk/src/fs ../../pico-keys-sdk/src/rng ../../pico-keys-sdk/src/usb + REQUIRES bootloader_support esp_partition esp_tinyusb zorxx__neopixel mbedtls efuse +) +idf_component_set_property(${COMPONENT_NAME} WHOLE_ARCHIVE ON)