[FL-1490] FuriHal: crypto api. Crypto cli tool. (#702)

* FuriHal: crypto layer
* Furi: add crash routine.
* FuriHal: crypto api. Crypto: cli command to manipulate secure enclave and encrypt/decrypt plain text.
* DeviceInfo: secure enclave verification.
* Rename original to enclave_valid
* Update expected enclave signature to match production keys
* F7: remove unused files
This commit is contained in:
あく
2021-09-15 12:59:49 +03:00
committed by GitHub
parent 95d9140d24
commit 66f9d946ae
52 changed files with 1056 additions and 1609 deletions

View File

@@ -3,10 +3,7 @@
#include <furi-hal-console.h>
#include <stdio.h>
void __furi_abort(void);
void __furi_print_name(void) {
furi_hal_console_puts("\r\n\033[0;31m[E]");
if(task_is_isr_context()) {
furi_hal_console_puts("[ISR] ");
} else {
@@ -19,13 +16,6 @@ void __furi_print_name(void) {
furi_hal_console_puts("] ");
}
}
furi_hal_console_puts("\033[0m");
}
void __furi_check(void) {
__furi_print_name();
furi_hal_console_puts("assertion failed\r\n");
__furi_abort();
}
void __furi_abort(void) {
@@ -33,4 +23,13 @@ void __furi_abort(void) {
asm("bkpt 1");
while(1) {
}
}
}
void furi_crash(const char* message) {
furi_hal_console_puts("\r\n\033[0;31m[CRASH]");
__furi_print_name();
furi_hal_console_puts(message ? message : "Programming Error");
furi_hal_console_puts("\r\nSystem halted. Connect debugger for more info\r\n");
furi_hal_console_puts("\033[0m\r\n");
__furi_abort();
}

View File

@@ -4,40 +4,18 @@
extern "C" {
#endif
// Find how to how get function's pretty name
#ifndef __FURI_CHECK_FUNC
// Use g++'s demangled names in C++
#if defined __cplusplus && defined __GNUC__
#define __FURI_CHECK_FUNC __PRETTY_FUNCTION__
// C99 requires the use of __func__
#elif __STDC_VERSION__ >= 199901L
#define __FURI_CHECK_FUNC __func__
// Older versions of gcc don't have __func__ but can use __FUNCTION__
#elif __GNUC__ >= 2
#define __FURI_CHECK_FUNC __FUNCTION__
// failed to detect __func__ support
#else
#define __FURI_CHECK_FUNC ((char*)0)
#endif
#endif
// !__FURI_CHECK_FUNC
// We have two levels of assertion
// One - furi_check, which always runs, the only difference is in the level of debug information
// The second is furi_assert, which doesn't compile in release mode
#define furi_check(__e) ((__e) ? (void)0 : __furi_check())
/** Check condition and crash if check failed */
#define furi_check(__e) ((__e) ? (void)0 : furi_crash("fury_check failed\r\n"))
/** Only in debug build: Assert condition and crash if assert failed */
#ifdef NDEBUG
#define furi_assert(__e) ((void)0)
#else
#define furi_assert(__e) ((__e) ? (void)0 : __furi_check())
#define furi_assert(__e) ((__e) ? (void)0 : furi_crash("furi_assert failed\r\n"))
#endif
// !NDEBUG
void __furi_check(void);
/** Crash system */
void furi_crash(const char* message);
#ifdef __cplusplus
}