header

package
v0.0.1-demo Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2022 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderSize = 512

HeaderSize is the fixed size allocated for the header.

Variables

View Source
var (
	MagicBytes = []byte("STITCHv1")

	ErrInvalidHeaderSize = errors.New("invalid header size")
	ErrUnrecognizedMagic = errors.New("unrecognized magic bytes")
	ErrHeaderNotComplete = errors.New("header not complete")
)

Functions

This section is empty.

Types

type Header struct {
	// ShardIndex is the index of the shard.
	ShardIndex int `msgpack:"i"`
	// ShardCount is the total number of shards.
	ShardCount int `msgpack:"c"`
	// FileHash is the SHA256 hash of the whole file plaintext.
	FileHash []byte `msgpack:"h"`
	// FileKey is one shard of the AES key used to encrypt the file plaintext.
	FileKey []byte `msgpack:"k"`
	// FileSize is the size of the file plaintext.
	FileSize uint64 `msgpack:"s"`
	// EncryptedSize is the size of the file ciphertext.
	EncryptedSize uint64 `msgpack:"e"`
	// CompressedSize is the size of the file after compression.
	CompressedSize uint64 `msgpack:"z"`
	// RSBlockSize is the size of the Reed-Solomon block.
	RSBlockSize int `msgpack:"b"`
	// AESBlockSize is the size of the AES block.
	AESBlockSize int `msgpack:"a"`
	// IsComplete marks whether the header is complete.
	IsComplete bool `msgpack:"o"`
}

Header describes the header of a shard. This struct only contains the actual data. The full header of each shard is composed of the following:

| Description | Length | | ----------------------------- | ------ | | magic bytes `STITCHv1` | 8 | | length of header data uint16 | 2 | | header data | - | | padding to fill to 1024 bytes | - |

func NewHeader

func NewHeader() *Header

func (*Header) Decode

func (h *Header) Decode(data []byte) error

Decode implements the encoding.BinaryUnmarshaler interface.

func (*Header) Encode

func (h *Header) Encode() ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL