mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +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:
committed by
Daniel Agar
parent
929820136a
commit
c2cbab1e98
@@ -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})
|
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})
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
file(STRINGS ${BOARD_CONFIG} ConfigContents)
|
||||||
|
foreach(NameAndValue ${ConfigContents})
|
||||||
|
# Strip leading spaces
|
||||||
|
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
|
||||||
|
|
||||||
|
# Find variable name
|
||||||
|
string(REGEX MATCH "^CONFIG_PUBLIC_KEY[^=]+" Name ${NameAndValue})
|
||||||
|
|
||||||
|
if(Name)
|
||||||
|
string(REPLACE "${Name}=" "" Value ${NameAndValue})
|
||||||
|
string(REPLACE "\"" "" Value ${Value})
|
||||||
|
|
||||||
|
# Strip CONFIG_
|
||||||
|
string(REPLACE "CONFIG_" "" Name ${Name})
|
||||||
|
|
||||||
|
# Get the value from env variable, if set
|
||||||
|
if(DEFINED ENV{${Name}})
|
||||||
|
set(Value $ENV{${Name}})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEFINED ENV{PUBLIC_KEY1})
|
if(NOT Value STREQUAL "")
|
||||||
add_definitions(-DPUBLIC_KEY1=$ENV{PUBLIC_KEY1})
|
add_definitions(-D${Name}=${Value})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEFINED ENV{PUBLIC_KEY2})
|
|
||||||
add_definitions(-DPUBLIC_KEY2=$ENV{PUBLIC_KEY2})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DEFINED ENV{PUBLIC_KEY3})
|
|
||||||
add_definitions(-DPUBLIC_KEY3=$ENV{PUBLIC_KEY3})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DEFINED ENV{PUBLIC_KEY4})
|
|
||||||
add_definitions(-DPUBLIC_KEY4=$ENV{PUBLIC_KEY4})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DEFINED ENV{PUBLIC_KEY5})
|
|
||||||
add_definitions(-DPUBLIC_KEY5=$ENV{PUBLIC_KEY5})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DEFINED ENV{PUBLIC_KEY6})
|
|
||||||
add_definitions(-DPUBLIC_KEY6=$ENV{PUBLIC_KEY6})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DEFINED ENV{PUBLIC_KEY7})
|
|
||||||
add_definitions(-DPUBLIC_KEY7=$ENV{PUBLIC_KEY7})
|
|
||||||
endif()
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|||||||
@@ -1,6 +1,24 @@
|
|||||||
|
menu "stub_keystore configuration"
|
||||||
menuconfig DRIVERS_STUB_KEYSTORE
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user