Documentation
¶
Overview ¶
Package encfile implements encrypted paged files
Index ¶
- Constants
- Variables
- func ChangePass(filename string, oldPassphrase, newPassphrase []byte) error
- func FileExists(filename string) bool
- type EncryptedFile
- func Append(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)
- func Create(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)
- func New(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)
- func Open(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)
- func View(filename string, passphrase []byte, sectorSize int) (*EncryptedFile, error)
- func (ef *EncryptedFile) Close() error
- func (ef *EncryptedFile) CountSector() uint64
- func (ef *EncryptedFile) Delete() error
- func (ef *EncryptedFile) PadSector(data []byte) []byte
- func (ef *EncryptedFile) Read(b []byte) (n int, err error)
- func (ef *EncryptedFile) ReadAt(b []byte, off int64) (n int, err error)
- func (ef *EncryptedFile) ReadSector(sector uint64) ([]byte, error)
- func (ef *EncryptedFile) Seek(off int64) int64
- func (ef *EncryptedFile) Stat() (os.FileInfo, error)
- func (ef *EncryptedFile) Sync() error
- func (ef *EncryptedFile) Write(b []byte) (n int, err error)
- func (ef *EncryptedFile) WriteAt(b []byte, off int64) (n int, err error)
- func (ef *EncryptedFile) WriteSector(sector uint64, data []byte) error
- func (ef *EncryptedFile) WriteSectorPad(sector uint64, data []byte) error
- func (ef *EncryptedFile) WriteSectorSync(sector uint64, data []byte) error
- func (ef *EncryptedFile) ZeroSector(sector uint64) error
Constants ¶
const BlockSize = 16
BlockSize of XTS cipher
const KeySize = 64
KeySize is the _raw_ keysize
Variables ¶
var ( // ScryptN scrypt n param ScryptN = 16384 // ScryptR scrypt r param ScryptR = 8 // ScryptP scrypt p param ScryptP = 1 )
var ErrSectorSize = errors.New("Sectorsize is no multiple of blocksize")
ErrSectorSize .
var RandomSource = rand.Reader
RandomSource of the packet
Functions ¶
func ChangePass ¶
ChangePass change passphrase of filename from old to new
func FileExists ¶
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) CountSector ¶
func (ef *EncryptedFile) CountSector() uint64
CountSector returns the number of sectors in the file
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) 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!