xbcrypt

package
v0.0.0-...-3852a4b Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XBCryptHashLen         = 32
	AESBlockSize           = 16
	MaxChunkSize           = math.MaxInt32
	MagicLen               = 8
	ReservedBytesSize      = 8
	OriginalSizeBytesSize  = unsafe.Sizeof(ChunkHeader{}.OriginSize)
	EncryptedSizeBytesSize = unsafe.Sizeof(ChunkHeader{}.EncryptedSize)
	ChecksumBytesSize      = 4
	IVSizeBytesSize        = 8
	ChunkHeaderFixSize     = MagicLen + ReservedBytesSize + OriginalSizeBytesSize + EncryptedSizeBytesSize + ChecksumBytesSize
	MagicStr1              = "XBCRYP01"
	MagicStr2              = "XBCRYP02"
	MagicStr3              = "XBCRYP03"
)

Variables

View Source
var (
	ChunkMagic1 = []byte(MagicStr1)
	ChunkMagic2 = []byte(MagicStr2)
	ChunkMagic3 = []byte(MagicStr3)
)

magics

View Source
var (
	ErrReadMagic         = errors.New("read magic failed")
	ErrReadHeaderFix     = errors.New("read header fix failed")
	ErrReadReserved      = errors.New("read reserved failed")
	ErrReadOriginalSize  = errors.New("read original size failed")
	ErrReadEncryptedSize = errors.New("read encrypted size failed")
	ErrReadChecksum      = errors.New("read checksum failed")
	ErrReadIVSize        = errors.New("read iv size failed")
	ErrReadIV            = errors.New("read iv failed")
	ErrReadEncryptedData = errors.New("read encrypted data failed")
	ErrReadHash          = errors.New("read hash failed")
	ErrHashNotMatch      = errors.New("hash not match")
	ErrDecrypt           = errors.New("decrypt failed")
	ErrExceedExtractSize = errors.New("exceed extract size")
)

errors

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	ChunkHeader
	ChunkEncrypted
}

type ChunkEncrypted

type ChunkEncrypted struct {
	PayloadSize uint64
	Hash        *bytes.Buffer
}

type ChunkHeader

type ChunkHeader struct {
	PrefixHeader  []uint8
	OriginSize    uint64
	EncryptedSize uint64
	Checksum      uint32
	IVSize        uint64
	IV            []byte
	Version       uint8
	HashAppended  bool
	HeaderSize    uint32
}

type DecryptContext

type DecryptContext struct {
	// contains filtered or unexported fields
}

DecryptContext provides sequential access to chunks from an xbstream. Each chunk returned represents a contiguous set of bytes for a file stored in the xbstream archive. The Next method advances the stream and returns the next chunk in the archive. Each archive then acts as a reader for its contiguous set of bytes

func NewDecryptContext

func NewDecryptContext(key []byte, reader io.Reader, writer io.Writer, extractLimitSize int64) (dc *DecryptContext, err error)

func NewReader

func NewReader(reader io.Reader) *DecryptContext

NewReader creates a new Reader by wrapping the provided reader

func (*DecryptContext) CheckMagicVersion

func (dc *DecryptContext) CheckMagicVersion() (err error)

func (*DecryptContext) Next

func (dc *DecryptContext) Next(w io.Writer) (err error)

Next advances the Reader and returns the next Chunk.

func (*DecryptContext) NextHeader

func (dc *DecryptContext) NextHeader() (err error)

NextHeader reads the next chunk header from the reader

func (*DecryptContext) ProcessChunks

func (dc *DecryptContext) ProcessChunks() (err error)

func (*DecryptContext) Read

func (dc *DecryptContext) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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