encfile

package module
v0.0.0-...-a9a3d44 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2015 License: BSD-3-Clause Imports: 8 Imported by: 0

README

encfile

Encrypted file library supporting random access, AES-128-XTS for file encryption, additional AES-256-GCM for sector encryption.

Documentation

Overview

Package encfile implements encrypted paged files

Index

Constants

View Source
const BlockSize = 16

BlockSize of XTS cipher

View Source
const KeySize = 64

KeySize is the _raw_ keysize

Variables

View Source
var (
	// ScryptN scrypt n param
	ScryptN = 16384
	// ScryptR scrypt r param
	ScryptR = 8
	// ScryptP scrypt p param
	ScryptP = 1
)
View Source
var ErrSectorSize = errors.New("Sectorsize is no multiple of blocksize")

ErrSectorSize .

View Source
var RandomSource = rand.Reader

RandomSource of the packet

Functions

func ChangePass

func ChangePass(filename string, oldPassphrase, newPassphrase []byte) error

ChangePass change passphrase of filename from old to new

func FileExists

func FileExists(filename string) bool

FileExists returns true if the file exists, false if not

Types

type EncryptedFile

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

EncryptedFile implements seekable file encryption

func Append

func Append(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)

Append a file. Must exist

func Create

func Create(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)

Create a file. May not exist

func New

func New(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)

New returns a handle on an encrypted file

func Open

func Open(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)

Open a file for read and write, MUST exist

func View

func View(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)

View a file. Open for reading only. Must exist

func (*EncryptedFile) Close

func (ef *EncryptedFile) Close() error

Close the file

func (*EncryptedFile) CountSector

func (ef *EncryptedFile) CountSector() uint64

CountSector returns the number of sectors in the file

func (*EncryptedFile) Delete

func (ef *EncryptedFile) Delete() error

Delete file by overwriting

func (*EncryptedFile) PadSector

func (ef *EncryptedFile) PadSector(data []byte) []byte

PadSector cuts or pads data to fit sector

func (*EncryptedFile) Read

func (ef *EncryptedFile) Read(b []byte) (n int, err error)

Read form current position

func (*EncryptedFile) ReadAt

func (ef *EncryptedFile) ReadAt(b []byte, off int64) (n int, err error)

ReadAt position

func (*EncryptedFile) ReadSector

func (ef *EncryptedFile) ReadSector(sector uint64) ([]byte, error)

ReadSector sector

func (*EncryptedFile) Seek

func (ef *EncryptedFile) Seek(off int64) int64

Seek to relative off

func (*EncryptedFile) Stat

func (ef *EncryptedFile) Stat() (os.FileInfo, error)

Stat of file

func (*EncryptedFile) Sync

func (ef *EncryptedFile) Sync() error

Sync the file

func (*EncryptedFile) Write

func (ef *EncryptedFile) Write(b []byte) (n int, err error)

Write b to file at current position

func (*EncryptedFile) WriteAt

func (ef *EncryptedFile) WriteAt(b []byte, off int64) (n int, err error)

WriteAt b to off

func (*EncryptedFile) WriteSector

func (ef *EncryptedFile) WriteSector(sector uint64, data []byte) error

WriteSector sector with data

func (*EncryptedFile) WriteSectorPad

func (ef *EncryptedFile) WriteSectorPad(sector uint64, data []byte) error

WriteSectorPad writes partial data to the sector, zeroing out any additonal data in the sector

func (*EncryptedFile) WriteSectorSync

func (ef *EncryptedFile) WriteSectorSync(sector uint64, data []byte) error

WriteSectorSync sector with data synched

func (*EncryptedFile) ZeroSector

func (ef *EncryptedFile) ZeroSector(sector uint64) error

ZeroSector overwrites the sector with random data. Reading it will fail!

Jump to

Keyboard shortcuts

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