Browse Source

Improve stub_keystore configuration

It is possible to either set the keyfile locations in board configuration or
with the same environment variables as before.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
master
Jukka Laitinen 3 years ago committed by Daniel Agar
parent
commit
c2cbab1e98
  1. 5
      boards/px4/fmu-v5/cryptotest.px4board
  2. 47
      src/drivers/stub_keystore/CMakeLists.txt
  3. 20
      src/drivers/stub_keystore/Kconfig

5
boards/px4/fmu-v5/cryptotest.px4board

@ -0,0 +1,5 @@
CONFIG_BOARD_CRYPTO=y
CONFIG_DRIVERS_SW_CRYPTO=y
CONFIG_DRIVERS_STUB_KEYSTORE=y
CONFIG_PUBLIC_KEY0="../../../Tools/test_keys/key0.pub"
CONFIG_PUBLIC_KEY1="../../../Tools/test_keys/rsa2048.pub"

47
src/drivers/stub_keystore/CMakeLists.txt

@ -36,34 +36,33 @@ px4_add_library(keystore_backend stub_keystore.c)
target_include_directories(keystore_backend PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(keystore_backend PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(DEFINED ENV{PUBLIC_KEY0}) # Parse keyfile locations from boardconfig
add_definitions(-DPUBLIC_KEY0=$ENV{PUBLIC_KEY0})
endif()
if(DEFINED ENV{PUBLIC_KEY1}) # If the key file path is defined in environment variable, use it from there
add_definitions(-DPUBLIC_KEY1=$ENV{PUBLIC_KEY1}) # else, if it is hardcoded in CONFIG_PUBLIC_KEYx, use that
endif()
if(DEFINED ENV{PUBLIC_KEY2}) file(STRINGS ${BOARD_CONFIG} ConfigContents)
add_definitions(-DPUBLIC_KEY2=$ENV{PUBLIC_KEY2}) foreach(NameAndValue ${ConfigContents})
endif() # Strip leading spaces
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
if(DEFINED ENV{PUBLIC_KEY3}) # Find variable name
add_definitions(-DPUBLIC_KEY3=$ENV{PUBLIC_KEY3}) string(REGEX MATCH "^CONFIG_PUBLIC_KEY[^=]+" Name ${NameAndValue})
endif()
if(DEFINED ENV{PUBLIC_KEY4}) if(Name)
add_definitions(-DPUBLIC_KEY4=$ENV{PUBLIC_KEY4}) string(REPLACE "${Name}=" "" Value ${NameAndValue})
endif() string(REPLACE "\"" "" Value ${Value})
if(DEFINED ENV{PUBLIC_KEY5}) # Strip CONFIG_
add_definitions(-DPUBLIC_KEY5=$ENV{PUBLIC_KEY5}) string(REPLACE "CONFIG_" "" Name ${Name})
endif()
if(DEFINED ENV{PUBLIC_KEY6}) # Get the value from env variable, if set
add_definitions(-DPUBLIC_KEY6=$ENV{PUBLIC_KEY6}) if(DEFINED ENV{${Name}})
endif() set(Value $ENV{${Name}})
endif()
if(DEFINED ENV{PUBLIC_KEY7}) if(NOT Value STREQUAL "")
add_definitions(-DPUBLIC_KEY7=$ENV{PUBLIC_KEY7}) add_definitions(-D${Name}=${Value})
endif() endif()
endif()
endforeach()

20
src/drivers/stub_keystore/Kconfig

@ -1,6 +1,24 @@
menuconfig DRIVERS_STUB_KEYSTORE menu "stub_keystore configuration"
menuconfig DRIVERS_STUB_KEYSTORE
bool "stub_keystore" bool "stub_keystore"
depends on DRIVERS_SW_CRYPTO depends on DRIVERS_SW_CRYPTO
default n default n
---help--- ---help---
Enable support for stub_keystore Enable support for stub_keystore
menuconfig PUBLIC_KEY0
string "Path to public key 0"
depends on DRIVERS_STUB_KEYSTORE
menuconfig PUBLIC_KEY1
string "Path to public key 1"
depends on DRIVERS_STUB_KEYSTORE
menuconfig PUBLIC_KEY2
string "Path to public key 2"
depends on DRIVERS_STUB_KEYSTORE
menuconfig PUBLIC_KEY3
string "Path to public key 3"
depends on DRIVERS_STUB_KEYSTORE
endmenu

Loading…
Cancel
Save