Documentation ¶
Index ¶
- func CalculateBlockHash(b []byte) (string, error)
- func CopyByteArea(start int, end int, reader *bytes.Reader) ([]byte, error)
- func OpenDB(dbpath string, readonly bool) (*bolt.DB, error)
- func ReadBlock(node Node, part *bytes.Reader, totalReadBlocks int) ([]byte, int, error)
- func ReadDB(partition string) (string, error)
- func ReadKey() (string, error)
- func VerifyBlock(block []byte, node Node) error
- func VerifyNode(node Node, nextNode Node) error
- func VerifySignature(key string, signature string, database string) (bool, error)
- type Header
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateBlockHash ¶
CalculateBlockHash calculates the sha1 checksum of a given byte slice b.
func CopyByteArea ¶
CopyByteArea copies an area of bytes from a reader. It verifies that the reader reads the wanted amount of bytes, and returns an error if this is not the case.
func ReadBlock ¶
ReadBlock reads a data area of a bytes.Reader specified in the given node. It additionally verifies that the amount of bytes read equal the wanted amount and returns an error if this is not the case.
func ReadDB ¶
ReadDB reads the database from a fsverify partition. It verifies the the size of the database with the size specified in the partition header and returns an error if the sizes do not match. Due to limitations with bbolt the database gets written to a temporary path and the function returns the path to the database.
func ReadKey ¶
ReadKey is a wrapper function to call the proper readKey function according to config.KeyStore.
func VerifyBlock ¶
VerifyBlock verifies a byte slice with the hash in a given Node.
func VerifyNode ¶
VerifyNode verifies that the current Node is valid by matching the checksum of it with the PrevNodeSum field of the next node.
Types ¶
type Header ¶
type Header struct { MagicNumber int Signature string FilesystemSize int FilesystemUnit int TableSize int TableUnit int }
Header contains all information stored in the header of a fsverify partition.
func ReadHeader ¶
ReadHeader reads the partition header and puts it in a variable of type Header. If any field fails to be read, the function returns an empty Header struct and the error.
type Node ¶
Node contains all information stored in a database node. If the Node is the first node in the database, PrevNodeSum should be set to Entrypoint.