mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-05-05 07:25:00 -04:00
fw: Add checksum to partition table
Refuse to boot if blake2s digest over the partition table does not match digest stored on flash
This commit is contained in:
parent
7d9aa7c647
commit
469546ff33
11 changed files with 207 additions and 73 deletions
|
@ -23,7 +23,7 @@ static volatile uint32_t *udi = (volatile uint32_t *)TK1_MMIO_TK1_UDI_F
|
|||
static volatile uint8_t *resetinfo = (volatile uint8_t *) TK1_MMIO_RESETINFO_BASE;
|
||||
// clang-format on
|
||||
|
||||
extern struct partition_table part_table;
|
||||
extern struct partition_table_storage part_table_storage;
|
||||
|
||||
int32_t syscall_handler(uint32_t number, uint32_t arg1, uint32_t arg2,
|
||||
uint32_t arg3)
|
||||
|
@ -36,21 +36,21 @@ int32_t syscall_handler(uint32_t number, uint32_t arg1, uint32_t arg2,
|
|||
|
||||
return 0;
|
||||
case TK1_SYSCALL_ALLOC_AREA:
|
||||
if (storage_allocate_area(&part_table) < 0) {
|
||||
if (storage_allocate_area(&part_table_storage) < 0) {
|
||||
debug_puts("couldn't allocate storage area\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
case TK1_SYSCALL_DEALLOC_AREA:
|
||||
if (storage_deallocate_area(&part_table) < 0) {
|
||||
if (storage_deallocate_area(&part_table_storage) < 0) {
|
||||
debug_puts("couldn't deallocate storage area\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
case TK1_SYSCALL_WRITE_DATA:
|
||||
if (storage_write_data(&part_table, arg1, (uint8_t *)arg2,
|
||||
if (storage_write_data(&part_table_storage.table, arg1, (uint8_t *)arg2,
|
||||
arg3) < 0) {
|
||||
debug_puts("couldn't write storage area\n");
|
||||
return -1;
|
||||
|
@ -58,7 +58,7 @@ int32_t syscall_handler(uint32_t number, uint32_t arg1, uint32_t arg2,
|
|||
|
||||
return 0;
|
||||
case TK1_SYSCALL_READ_DATA:
|
||||
if (storage_read_data(&part_table, arg1, (uint8_t *)arg2,
|
||||
if (storage_read_data(&part_table_storage.table, arg1, (uint8_t *)arg2,
|
||||
arg3) < 0) {
|
||||
debug_puts("couldn't read storage area\n");
|
||||
return -1;
|
||||
|
@ -75,24 +75,24 @@ int32_t syscall_handler(uint32_t number, uint32_t arg1, uint32_t arg2,
|
|||
return udi[0];
|
||||
|
||||
case TK1_SYSCALL_PRELOAD_DELETE:
|
||||
return preload_delete(&part_table, 1);
|
||||
return preload_delete(&part_table_storage, 1);
|
||||
|
||||
case TK1_SYSCALL_PRELOAD_STORE:
|
||||
// arg1 offset
|
||||
// arg2 data
|
||||
// arg3 size
|
||||
// always using slot 1
|
||||
return preload_store(&part_table, arg1, (uint8_t *)arg2, arg3, 1);
|
||||
return preload_store(&part_table_storage.table, arg1, (uint8_t *)arg2, arg3, 1);
|
||||
|
||||
case TK1_SYSCALL_PRELOAD_STORE_FIN:
|
||||
// arg1 app_size
|
||||
// arg2 app_digest
|
||||
// arg3 app_signature
|
||||
// always using slot 1
|
||||
return preload_store_finalize(&part_table, arg1, (uint8_t *)arg2, (uint8_t *)arg3, 1);
|
||||
return preload_store_finalize(&part_table_storage, arg1, (uint8_t *)arg2, (uint8_t *)arg3, 1);
|
||||
|
||||
case TK1_SYSCALL_PRELOAD_GET_DIGSIG:
|
||||
return preload_get_digsig(&part_table, (uint8_t *)arg1, (uint8_t *)arg2, 1);
|
||||
return preload_get_digsig(&part_table_storage.table, (uint8_t *)arg1, (uint8_t *)arg2, 1);
|
||||
|
||||
default:
|
||||
assert(1 == 2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue