Replace proprietary libAccess
This commit is contained in:
+3
-4
@@ -2,7 +2,6 @@
|
|||||||
path = radio/src/thirdparty/libopenui
|
path = radio/src/thirdparty/libopenui
|
||||||
url = https://github.com/EdgeTX/libopenui.git
|
url = https://github.com/EdgeTX/libopenui.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "libACCESS"]
|
[submodule "radio/src/thirdparty/AccessDenied"]
|
||||||
path = radio/src/thirdparty/libACCESS
|
path = radio/src/thirdparty/AccessDenied
|
||||||
url = https://github.com/FrSkyRC/libACCESS.git
|
url = https://github.com/raphaelcoeffic/AccessDenied.git
|
||||||
branch = master
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ set(FIRMWARE_CXX_COMPILER "${GCC_ARM_PATH}arm-none-eabi-g++" CACHE STRING "Speci
|
|||||||
set(FIRMWARE_ASM_COMPILER "${GCC_ARM_PATH}arm-none-eabi-as" CACHE STRING "Specific assembler for firmware target.")
|
set(FIRMWARE_ASM_COMPILER "${GCC_ARM_PATH}arm-none-eabi-as" CACHE STRING "Specific assembler for firmware target.")
|
||||||
set(FIRMWARE_OBJCOPY "${GCC_ARM_PATH}arm-none-eabi-objcopy" CACHE STRING "Specific objcopy for firmware target.")
|
set(FIRMWARE_OBJCOPY "${GCC_ARM_PATH}arm-none-eabi-objcopy" CACHE STRING "Specific objcopy for firmware target.")
|
||||||
set(FIRMWARE_SIZE "${GCC_ARM_PATH}arm-none-eabi-size" CACHE STRING "Specific size for firmware target.")
|
set(FIRMWARE_SIZE "${GCC_ARM_PATH}arm-none-eabi-size" CACHE STRING "Specific size for firmware target.")
|
||||||
|
set(FIRMWARE_RANLIB "${GCC_ARM_PATH}arm-none-eabi-ranlib" CACHE STRING "Specific ranlib for firmware target.")
|
||||||
|
|
||||||
set(THIRDPARTY_DIR thirdparty)
|
set(THIRDPARTY_DIR thirdparty)
|
||||||
set(LUA_DIR ${THIRDPARTY_DIR}/Lua/src)
|
set(LUA_DIR ${THIRDPARTY_DIR}/Lua/src)
|
||||||
@@ -499,8 +500,8 @@ set(CMAKE_CXX_FLAGS_MINSIZEREL "")
|
|||||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "")
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "")
|
||||||
# customize linker command
|
# customize linker command
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "")
|
set(CMAKE_EXE_LINKER_FLAGS "")
|
||||||
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET>")
|
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||||
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET>")
|
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||||
|
|
||||||
use_cxx11() # ensure gnu++11 in CXX_FLAGS with CMake < 3.1
|
use_cxx11() # ensure gnu++11 in CXX_FLAGS with CMake < 3.1
|
||||||
|
|
||||||
@@ -514,6 +515,7 @@ if(NOT MSVC)
|
|||||||
set(CMAKE_C_COMPILER ${FIRMWARE_C_COMPILER})
|
set(CMAKE_C_COMPILER ${FIRMWARE_C_COMPILER})
|
||||||
set(CMAKE_CXX_COMPILER ${FIRMWARE_CXX_COMPILER})
|
set(CMAKE_CXX_COMPILER ${FIRMWARE_CXX_COMPILER})
|
||||||
set(CMAKE_ASM_COMPILER ${FIRMWARE_ASM_COMPILER})
|
set(CMAKE_ASM_COMPILER ${FIRMWARE_ASM_COMPILER})
|
||||||
|
set(CMAKE_RANLIB ${FIRMWARE_RANLIB})
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
set(CMAKE_SYSTEM_VERSION 1)
|
set(CMAKE_SYSTEM_VERSION 1)
|
||||||
@@ -528,10 +530,6 @@ if(NOT MSVC)
|
|||||||
# these are in addition to CMAKE_CXX_FLAGS
|
# these are in addition to CMAKE_CXX_FLAGS
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-lm -T${RADIO_SRC_DIR}/${LINKER_SCRIPT} -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections")
|
set(CMAKE_EXE_LINKER_FLAGS "-lm -T${RADIO_SRC_DIR}/${LINKER_SCRIPT} -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections")
|
||||||
|
|
||||||
if(ACCESS_LIB)
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--whole-archive ${RADIO_SRC_DIR}/${THIRDPARTY_DIR}/libACCESS/libAccess.a -Wl,--no-whole-archive")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SEMIHOSTING)
|
if(SEMIHOSTING)
|
||||||
add_definitions(-DSEMIHOSTING)
|
add_definitions(-DSEMIHOSTING)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=rdimon.specs")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=rdimon.specs")
|
||||||
@@ -577,6 +575,12 @@ if(NOT MSVC)
|
|||||||
add_dependencies(firmware ${RADIO_DEPENDENCIES} ${FIRMWARE_DEPENDENCIES})
|
add_dependencies(firmware ${RADIO_DEPENDENCIES} ${FIRMWARE_DEPENDENCIES})
|
||||||
set_target_properties(firmware PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
set_target_properties(firmware PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||||
|
|
||||||
|
if(ACCESS_DENIED)
|
||||||
|
add_subdirectory(thirdparty/AccessDenied)
|
||||||
|
include_directories(thirdparty/AccessDenied)
|
||||||
|
target_link_libraries(firmware AccessDenied)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET firmware POST_BUILD
|
TARGET firmware POST_BUILD
|
||||||
COMMAND ${FIRMWARE_OBJCOPY} -O binary firmware.elf firmware.bin
|
COMMAND ${FIRMWARE_OBJCOPY} -O binary firmware.elf firmware.bin
|
||||||
|
|||||||
@@ -1091,6 +1091,10 @@ int cliDebugVars(const char ** argv)
|
|||||||
serialPrint("ioMutexReq=%d", ioMutexReq);
|
serialPrint("ioMutexReq=%d", ioMutexReq);
|
||||||
serialPrint("ioMutexRel=%d", ioMutexRel);
|
serialPrint("ioMutexRel=%d", ioMutexRel);
|
||||||
serialPrint("sdReadRetries=%d", sdReadRetries);
|
serialPrint("sdReadRetries=%d", sdReadRetries);
|
||||||
|
#if defined(ACCESS_DENIED)
|
||||||
|
extern volatile int32_t authenticateFrames;
|
||||||
|
serialPrint("authenticateFrames=%d", authenticateFrames);
|
||||||
|
#endif
|
||||||
#elif defined(PCBTARANIS)
|
#elif defined(PCBTARANIS)
|
||||||
serialPrint("telemetryErrors=%d", telemetryErrors);
|
serialPrint("telemetryErrors=%d", telemetryErrors);
|
||||||
#endif
|
#endif
|
||||||
@@ -1189,6 +1193,57 @@ int cliBlueTooth(const char ** argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ACCESS_DENIED)
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "AccessDenied/access_denied.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t cryptInput[16];
|
||||||
|
static uint8_t cryptOutput[16];
|
||||||
|
|
||||||
|
static void testAccessDenied(uint32_t runs)
|
||||||
|
{
|
||||||
|
while(runs--)
|
||||||
|
access_denied(0, cryptInput, cryptOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
int cliCrypt(const char ** argv)
|
||||||
|
{
|
||||||
|
if (argv[1][0] == '\0')
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
strncpy((char*)cryptInput, argv[1], sizeof(cryptInput));
|
||||||
|
serialPrint("Input:");
|
||||||
|
dumpBody(cryptInput, sizeof(cryptInput));
|
||||||
|
dumpEnd();
|
||||||
|
|
||||||
|
watchdogSuspend(2000/* 20s */);
|
||||||
|
if (pulsesStarted()) {
|
||||||
|
pausePulses();
|
||||||
|
}
|
||||||
|
pauseMixerCalculations();
|
||||||
|
perMainEnabled = false;
|
||||||
|
|
||||||
|
uint32_t startMs = RTOS_GET_MS();
|
||||||
|
testAccessDenied(100000);
|
||||||
|
serialPrintf("access_denied: %f us/run\r\n", (RTOS_GET_MS() - startMs)*1000.0f / 100000.0f);
|
||||||
|
|
||||||
|
serialPrint("Decrypted (SW):");
|
||||||
|
dumpBody(cryptOutput, sizeof(cryptOutput));
|
||||||
|
dumpEnd();
|
||||||
|
|
||||||
|
perMainEnabled = true;
|
||||||
|
if (pulsesStarted()) {
|
||||||
|
resumePulses();
|
||||||
|
}
|
||||||
|
resumeMixerCalculations();
|
||||||
|
watchdogSuspend(0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const CliCommand cliCommands[] = {
|
const CliCommand cliCommands[] = {
|
||||||
{ "beep", cliBeep, "[<frequency>] [<duration>]" },
|
{ "beep", cliBeep, "[<frequency>] [<duration>]" },
|
||||||
{ "ls", cliLs, "<directory>" },
|
{ "ls", cliLs, "<directory>" },
|
||||||
@@ -1217,6 +1272,9 @@ const CliCommand cliCommands[] = {
|
|||||||
#endif
|
#endif
|
||||||
#if defined(BLUETOOTH)
|
#if defined(BLUETOOTH)
|
||||||
{ "bt", cliBlueTooth, "<baudrate>|<command>" },
|
{ "bt", cliBlueTooth, "<baudrate>|<command>" },
|
||||||
|
#endif
|
||||||
|
#if defined(ACCESS_DENIED)
|
||||||
|
{ "crypt", cliCrypt, "<string to be encrypted>" },
|
||||||
#endif
|
#endif
|
||||||
{ nullptr, nullptr, nullptr } /* sentinel */
|
{ nullptr, nullptr, nullptr } /* sentinel */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1328,9 +1328,3 @@ inline bool isAsteriskDisplayed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
||||||
#if defined(ACCESS_LIB)
|
|
||||||
// TODO should be inside module.h
|
|
||||||
#include "thirdparty/libACCESS/libAccess.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|||||||
@@ -202,8 +202,8 @@ if(INTERNAL_MODULE_PXX2)
|
|||||||
add_definitions(-DHARDWARE_INTERNAL_MODULE)
|
add_definitions(-DHARDWARE_INTERNAL_MODULE)
|
||||||
add_definitions(-DINTERNAL_MODULE_PXX2)
|
add_definitions(-DINTERNAL_MODULE_PXX2)
|
||||||
if (NOT PCBREV STREQUAL EXPRESS)
|
if (NOT PCBREV STREQUAL EXPRESS)
|
||||||
set(ACCESS_LIB ON)
|
set(ACCESS_DENIED ON)
|
||||||
add_definitions(-DACCESS_LIB)
|
add_definitions(-DACCESS_DENIED)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,14 @@ void processTelemetryFrame(uint8_t module, const uint8_t * frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ACCESS_LIB) && !defined(SIMU)
|
#if defined(INTERNAL_MODULE_PXX2) && defined(ACCESS_DENIED) && !defined(SIMU)
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "AccessDenied/access_denied.h"
|
||||||
|
};
|
||||||
|
|
||||||
|
volatile int16_t authenticateFrames = 0;
|
||||||
|
|
||||||
void processAuthenticationFrame(uint8_t module, const uint8_t * frame)
|
void processAuthenticationFrame(uint8_t module, const uint8_t * frame)
|
||||||
{
|
{
|
||||||
uint8_t cryptoType = frame[3];
|
uint8_t cryptoType = frame[3];
|
||||||
@@ -231,12 +238,14 @@ void processAuthenticationFrame(uint8_t module, const uint8_t * frame)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (INTERNAL_MODULE == module && accessCRL(cryptoType, frame+4, messageDigest)) {
|
if (INTERNAL_MODULE == module && access_denied(cryptoType, frame+4, messageDigest)) {
|
||||||
moduleState[module].mode = MODULE_MODE_AUTHENTICATION;
|
moduleState[module].mode = MODULE_MODE_AUTHENTICATION;
|
||||||
Pxx2Pulses & pxx2 = intmodulePulsesData.pxx2;
|
Pxx2Pulses & pxx2 = intmodulePulsesData.pxx2;
|
||||||
pxx2.setupAuthenticationFrame(module, cryptoType, (const uint8_t *)messageDigest);
|
pxx2.setupAuthenticationFrame(module, cryptoType, (const uint8_t *)messageDigest);
|
||||||
intmoduleSendBuffer(pxx2.getData(), pxx2.getSize());
|
intmoduleSendBuffer(pxx2.getData(), pxx2.getSize());
|
||||||
// we remain in AUTHENTICATION mode to avoid a CHANNELS frame is sent at the end of the mixing process
|
// we remain in AUTHENTICATION mode to avoid a CHANNELS frame is sent at the end of the mixing process
|
||||||
|
authenticateFrames++;
|
||||||
|
serialPrint("[authFrame %d]\r\n", authenticateFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!globalData.upgradeModulePopup) {
|
if (!globalData.upgradeModulePopup) {
|
||||||
@@ -249,6 +258,7 @@ void processAuthenticationFrame(uint8_t module, const uint8_t * frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define processAuthenticationFrame(module, frame)
|
#define processAuthenticationFrame(module, frame)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
Submodule radio/src/thirdparty/AccessDenied added at 6b04dfe4d9
Vendored
-1
Submodule radio/src/thirdparty/libACCESS deleted from 63802e6d50
Reference in New Issue
Block a user