mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-05-06 16:04:58 -04:00
fw/tools: Change partition checksum to vanilla BLAKE2s
Instead of using 16 byte BLAKE2s with a dummy key, use plain vanilla unkeyed 32 byte BLAKE2s for partition checksum. Co-authored-by: Mikael Ågren <mikael@tillitis.se>
This commit is contained in:
parent
66ea8df1d9
commit
3e8ff9671c
3 changed files with 5 additions and 24 deletions
|
@ -34,7 +34,7 @@ type PartTable struct {
|
|||
|
||||
type PartTableStorage struct {
|
||||
PartTable PartTable
|
||||
Digest [16]uint8
|
||||
Checksum [32]byte
|
||||
}
|
||||
|
||||
type Flash struct {
|
||||
|
@ -85,21 +85,7 @@ func printPartTableStorageCondensed(storage PartTableStorage) {
|
|||
fmt.Printf(" %x\n", appData.Signature[32:48])
|
||||
fmt.Printf(" %x\n", appData.Signature[48:])
|
||||
}
|
||||
fmt.Printf(" Digest : %x\n", storage.Digest)
|
||||
}
|
||||
|
||||
func calculateStorageDigest(data []byte) []byte {
|
||||
key := [16]byte{}
|
||||
|
||||
hash, err := blake2s.New128(key[:])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
hash.Write(data)
|
||||
digest := hash.Sum([]byte{})
|
||||
|
||||
return digest
|
||||
fmt.Printf(" Digest : %x\n", storage.Checksum)
|
||||
}
|
||||
|
||||
func generatePartTableStorage(outputFilename string, app0Filename string) {
|
||||
|
@ -125,8 +111,7 @@ func generatePartTableStorage(outputFilename string, app0Filename string) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
digest := calculateStorageDigest(buf[:len])
|
||||
copy(storage.Digest[:], digest)
|
||||
storage.Checksum = blake2s.Sum256(buf[:len])
|
||||
|
||||
storageFile, err := os.Create(outputFilename)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue