From 71cc54810fdb51e428b83a37ff89d54a6cc3d8c8 Mon Sep 17 00:00:00 2001 From: axtloss Date: Sun, 4 Feb 2024 13:35:03 +0100 Subject: add minisign signature verification --- core/storage.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'core/storage.go') diff --git a/core/storage.go b/core/storage.go index f6f1ffd..8346c12 100644 --- a/core/storage.go +++ b/core/storage.go @@ -99,7 +99,7 @@ func ReadHeader(partition string) (Header, error) { return Header{}, err } - header.Signature = fmt.Sprintf("untrusted comment: signature from minisign secret key\r\n%s\r\ntrusted comment: timestamp:0\tfile:fsverify\thashed\r\n%s\r\n", UntrustedHash, TrustedHash) + header.Signature = fmt.Sprintf("untrusted comment: fsverify\r\n%s\r\ntrusted comment: fsverify\r\n%s\r\n", UntrustedHash, TrustedHash) header.FilesystemSize = int(binary.BigEndian.Uint16(FilesystemSize)) header.TableSize = int(binary.BigEndian.Uint32(TableSize)) header.FilesystemUnit = parseUnitSpec(FilesystemUnit) @@ -135,10 +135,14 @@ func ReadDB(partition string) (string, error) { } db := make([]byte, header.TableSize*header.TableUnit) - _, err = io.ReadFull(reader, db) + n, err := io.ReadFull(reader, db) if err != nil { return "", err } + if n != header.TableSize*header.TableUnit { + return "", fmt.Errorf("Error: Database is not expected size. Got: %d, expected %d", n, header.TableSize*header.TableUnit) + } + fmt.Printf("db: %d\n", n) temp, err := os.MkdirTemp("", "*-fsverify") if err != nil { -- cgit v1.2.3