mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-17 19:02:15 -04:00
fw: Rename partition digest to checksum
- Rename functions, defines, et c to indicate that it's a checksum over the partition, not necessarily a cryptographic hash digest even though we use a version of BLAKE2s. - Add comments describing where the checksum is stored and what it is used for. Co-authored-by: Mikael Ågren <mikael@tillitis.se>
This commit is contained in:
parent
106a7a5613
commit
66ea8df1d9
2 changed files with 16 additions and 12 deletions
|
@ -17,11 +17,13 @@ enum part_status part_get_status(void)
|
|||
return part_status;
|
||||
}
|
||||
|
||||
static void part_digest(struct partition_table *part_table, uint8_t *out_digest,
|
||||
size_t out_len);
|
||||
static void part_checksum(struct partition_table *part_table,
|
||||
uint8_t *out_digest, size_t out_len);
|
||||
|
||||
static void part_digest(struct partition_table *part_table, uint8_t *out_digest,
|
||||
size_t out_len)
|
||||
// part_digest computes a checksum over the partition table to detect
|
||||
// flash problems
|
||||
static void part_checksum(struct partition_table *part_table,
|
||||
uint8_t *out_digest, size_t out_len)
|
||||
{
|
||||
int blake2err = 0;
|
||||
|
||||
|
@ -50,7 +52,7 @@ int part_table_read(struct partition_table_storage *storage)
|
|||
ADDR_PARTITION_TABLE_0,
|
||||
ADDR_PARTITION_TABLE_1,
|
||||
};
|
||||
uint8_t check_digest[PART_DIGEST_SIZE] = {0};
|
||||
uint8_t check_digest[PART_CHECKSUM_SIZE] = {0};
|
||||
|
||||
if (storage == NULL) {
|
||||
return -1;
|
||||
|
@ -64,10 +66,10 @@ int part_table_read(struct partition_table_storage *storage)
|
|||
sizeof(*storage)) != 0) {
|
||||
return -1;
|
||||
}
|
||||
part_digest(&storage->table, check_digest,
|
||||
sizeof(check_digest));
|
||||
part_checksum(&storage->table, check_digest,
|
||||
sizeof(check_digest));
|
||||
|
||||
if (memeq(check_digest, storage->check_digest,
|
||||
if (memeq(check_digest, storage->checksum,
|
||||
sizeof(check_digest))) {
|
||||
if (i == 1) {
|
||||
part_status = PART_SLOT0_INVALID;
|
||||
|
@ -91,8 +93,8 @@ int part_table_write(struct partition_table_storage *storage)
|
|||
return -1;
|
||||
}
|
||||
|
||||
part_digest(&storage->table, storage->check_digest,
|
||||
sizeof(storage->check_digest));
|
||||
part_checksum(&storage->table, storage->checksum,
|
||||
sizeof(storage->checksum));
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
flash_sector_erase(offset[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue