cryptostream

package
v0.0.0-...-395ddcd Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package cryptostream implements transparent encryption on ReaderAt and Writer streams in order to enforce encrypted backups

Index

Constants

View Source
const HeaderSize = aes.BlockSize

HeaderSize represents the metadata size prepended to the data stream and needs to be subtracted when passing the payload size by using the file size of the encrypted data

Variables

This section is empty.

Functions

This section is empty.

Types

type CryptoReaderAt

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

CryptoReaderAt implements an io.ReaderAt on an AES-256-CTR encrypted data stream. The data stream is expected to have the format defined in this library.

func NewReaderAt

func NewReaderAt(next io.ReaderAt, pass []byte) (CryptoReaderAt, error)

NewReaderAt creates a new CryptoReaderAt on the given io.ReaderAt, reads header and salt and verifies the stream follows the format specified in this library.

func (CryptoReaderAt) ReadAt

func (c CryptoReaderAt) ReadAt(p []byte, off int64) (n int, err error)

ReadAt implements the io.ReaderAt interface

type CryptoWriteCloser

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

CryptoWriteCloser implements an io.Writer following the specification of this package onto a given io.Writer

func NewWriter

func NewWriter(next io.Writer, pass []byte) (*CryptoWriteCloser, error)

NewWriter creates a new CryptoWriteCloser, gets a random salt and writes the header to the underlying writer

func (*CryptoWriteCloser) Close

func (c *CryptoWriteCloser) Close() error

Close implements the io.Closer interface and MUST be called after all writes are finished as the Write method might NOT have written all data to the underlying writer. This method ensures the data is fully and properly written

func (*CryptoWriteCloser) Write

func (c *CryptoWriteCloser) Write(p []byte) (n int, err error)

Write implements the io.Writer interface. See Close for hints how to properly write all data to the underlying writer. This method contains a buffer which buffers up to 16 bytes.

Jump to

Keyboard shortcuts

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