mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-09 23:22:12 -04:00
fw: Indicate which partition table used by return value when reading
- Return 0: Slot 0 used. - Return 1: Slot 1 used, indicating slot 0 broken!
This commit is contained in:
parent
2eee630649
commit
e1d25f6d74
1 changed files with 9 additions and 1 deletions
|
@ -24,6 +24,14 @@ void part_digest(struct partition_table *part_table, uint8_t *out_digest, size_t
|
||||||
assert(blake2err == 0);
|
assert(blake2err == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// part_table_read reads and verifies the partition table storage,
|
||||||
|
// first trying slot 0, then slot 1 if slot 0 does not verify.
|
||||||
|
//
|
||||||
|
// It stores the partition table in storage.
|
||||||
|
//
|
||||||
|
// Returns negative values on errors.
|
||||||
|
// Returns 0 if using slot 0.
|
||||||
|
// Returns 1 if using slot 1, indicating that slot 0 failed verification.
|
||||||
int part_table_read(struct partition_table_storage *storage)
|
int part_table_read(struct partition_table_storage *storage)
|
||||||
{
|
{
|
||||||
uint32_t offset[2] = {
|
uint32_t offset[2] = {
|
||||||
|
@ -41,7 +49,7 @@ int part_table_read(struct partition_table_storage *storage)
|
||||||
part_digest(&storage->table, check_digest, sizeof(check_digest));
|
part_digest(&storage->table, check_digest, sizeof(check_digest));
|
||||||
|
|
||||||
if (memeq(check_digest, storage->check_digest, sizeof(check_digest))) {
|
if (memeq(check_digest, storage->check_digest, sizeof(check_digest))) {
|
||||||
return 0;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue