aboutsummaryrefslogtreecommitdiff
path: root/verifysetup/core
diff options
context:
space:
mode:
Diffstat (limited to 'verifysetup/core')
-rw-r--r--verifysetup/core/crypt.go1
-rw-r--r--verifysetup/core/storage.go24
2 files changed, 21 insertions, 4 deletions
diff --git a/verifysetup/core/crypt.go b/verifysetup/core/crypt.go
index 4658641..4b448c5 100644
--- a/verifysetup/core/crypt.go
+++ b/verifysetup/core/crypt.go
@@ -37,5 +37,6 @@ func SignDatabase(database string, minisignKeys string) ([]byte, error) {
return nil, err
}
signature := minisign.SignWithComments(privateKey, data, "fsverify", "fsverify")
+ fmt.Printf("SIGNATURE: %x\n", signature)
return signature, err
}
diff --git a/verifysetup/core/storage.go b/verifysetup/core/storage.go
index ddc70b3..e7ded32 100644
--- a/verifysetup/core/storage.go
+++ b/verifysetup/core/storage.go
@@ -2,8 +2,10 @@ package core
import (
"bytes"
+ "encoding/binary"
"encoding/json"
"fmt"
+
verify "github.com/axtloss/fsverify/core"
bolt "go.etcd.io/bbolt"
)
@@ -12,9 +14,9 @@ var TotalReadBlocks = 0
func ReadBlock(start int, end int, device *bytes.Reader) ([]byte, error) {
if end-start < 0 {
- return []byte{}, fmt.Errorf("ERROR: tried creating byte slice with negative length. %d to %d total %d\n", start, end, end-start)
+ return []byte{}, fmt.Errorf("tried creating byte slice with negative length. %d to %d total %d\n", start, end, end-start)
} else if end-start > 2000 {
- return []byte{}, fmt.Errorf("ERROR: tried creating byte slice with length over 2000. %d to %d total %d\n", start, end, end-start)
+ return []byte{}, fmt.Errorf("tried creating byte slice with length over 2000. %d to %d total %d\n", start, end, end-start)
}
block := make([]byte, end-start)
_, err := device.Seek(int64(start), 0)
@@ -63,8 +65,22 @@ func AddNode(node verify.Node, tx *bolt.Tx) error {
}
return nil
}
-/*
+
func CreateHeader(unsignedHash string, signedHash string, diskSize int, tableSize int) ([]byte, error) {
header := make([]byte, 200)
+ header[0] = 0xAC
+ header[1] = 0xAB
+ copy(header[2:], []byte(unsignedHash))
+ copy(header[102:], []byte(signedHash))
+
+ disk := make([]byte, 4)
+ binary.BigEndian.PutUint32(disk, uint32(diskSize))
+ copy(header[190:], disk)
-}*/
+ fmt.Println(tableSize)
+ db := make([]byte, 4)
+ binary.BigEndian.PutUint32(db, uint32(tableSize))
+ copy(header[195:], db)
+
+ return header, nil
+}