mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
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>
This commit is contained in:
parent
929820136a
commit
c2cbab1e98
5
boards/px4/fmu-v5/cryptotest.px4board
Normal file
5
boards/px4/fmu-v5/cryptotest.px4board
Normal file
@ -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"
|
||||
@ -36,34 +36,33 @@ px4_add_library(keystore_backend stub_keystore.c)
|
||||
|
||||
target_include_directories(keystore_backend PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(DEFINED ENV{PUBLIC_KEY0})
|
||||
add_definitions(-DPUBLIC_KEY0=$ENV{PUBLIC_KEY0})
|
||||
endif()
|
||||
# Parse keyfile locations from boardconfig
|
||||
|
||||
if(DEFINED ENV{PUBLIC_KEY1})
|
||||
add_definitions(-DPUBLIC_KEY1=$ENV{PUBLIC_KEY1})
|
||||
endif()
|
||||
# If the key file path is defined in environment variable, use it from there
|
||||
# else, if it is hardcoded in CONFIG_PUBLIC_KEYx, use that
|
||||
|
||||
if(DEFINED ENV{PUBLIC_KEY2})
|
||||
add_definitions(-DPUBLIC_KEY2=$ENV{PUBLIC_KEY2})
|
||||
endif()
|
||||
file(STRINGS ${BOARD_CONFIG} ConfigContents)
|
||||
foreach(NameAndValue ${ConfigContents})
|
||||
# Strip leading spaces
|
||||
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
|
||||
|
||||
if(DEFINED ENV{PUBLIC_KEY3})
|
||||
add_definitions(-DPUBLIC_KEY3=$ENV{PUBLIC_KEY3})
|
||||
endif()
|
||||
# Find variable name
|
||||
string(REGEX MATCH "^CONFIG_PUBLIC_KEY[^=]+" Name ${NameAndValue})
|
||||
|
||||
if(DEFINED ENV{PUBLIC_KEY4})
|
||||
add_definitions(-DPUBLIC_KEY4=$ENV{PUBLIC_KEY4})
|
||||
endif()
|
||||
if(Name)
|
||||
string(REPLACE "${Name}=" "" Value ${NameAndValue})
|
||||
string(REPLACE "\"" "" Value ${Value})
|
||||
|
||||
if(DEFINED ENV{PUBLIC_KEY5})
|
||||
add_definitions(-DPUBLIC_KEY5=$ENV{PUBLIC_KEY5})
|
||||
endif()
|
||||
# Strip CONFIG_
|
||||
string(REPLACE "CONFIG_" "" Name ${Name})
|
||||
|
||||
if(DEFINED ENV{PUBLIC_KEY6})
|
||||
add_definitions(-DPUBLIC_KEY6=$ENV{PUBLIC_KEY6})
|
||||
endif()
|
||||
# Get the value from env variable, if set
|
||||
if(DEFINED ENV{${Name}})
|
||||
set(Value $ENV{${Name}})
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{PUBLIC_KEY7})
|
||||
add_definitions(-DPUBLIC_KEY7=$ENV{PUBLIC_KEY7})
|
||||
endif()
|
||||
if(NOT Value STREQUAL "")
|
||||
add_definitions(-D${Name}=${Value})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@ -1,6 +1,24 @@
|
||||
menuconfig DRIVERS_STUB_KEYSTORE
|
||||
menu "stub_keystore configuration"
|
||||
menuconfig DRIVERS_STUB_KEYSTORE
|
||||
bool "stub_keystore"
|
||||
depends on DRIVERS_SW_CRYPTO
|
||||
default n
|
||||
---help---
|
||||
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…
x
Reference in New Issue
Block a user