Documentation ¶
Index ¶
- Constants
- type ContentCrypter
- func (cc *ContentCrypter) BlockNoToCipherOff(blockNo uint64) uint64
- func (cc *ContentCrypter) BlockNoToPlainOff(blockNo uint64) uint64
- func (cc *ContentCrypter) BlockOverhead() uint64
- func (cc *ContentCrypter) CipherBS() int
- func (cc *ContentCrypter) CipherOffToBlockNo(cipherOffset uint64) uint64
- func (cc *ContentCrypter) CipherSizeToPlainSize(cipherSize uint64) uint64
- func (cc *ContentCrypter) DecryptBlocks(cipher []byte, firstBlockNo uint64, fileID []byte) ([][]byte, error)
- func (cc *ContentCrypter) EncryptBlocks(blocks [][]byte, firstBlockNo uint64, fileID []byte) ([]byte, error)
- func (cc *ContentCrypter) ExplodePlainRange(offset uint64, length int) []IntraBlock
- func (cc *ContentCrypter) MergeBlock(oldData []byte, newData []byte, offset int) []byte
- func (cc *ContentCrypter) PlainBS() int
- func (cc *ContentCrypter) PlainOffToBlockNo(plainOffset uint64) uint64
- func (cc *ContentCrypter) PlainSizeToCipherSize(plainSize uint64) uint64
- func (cc *ContentCrypter) RewriteBlock(oldData []byte, newData []byte, offset int) []byte
- func (cc *ContentCrypter) TransformPlainRange(offset uint64, length int) (plainSkip int, alignedOff uint64, alignedLen int)
- type FileHeader
- type IntraBlock
Constants ¶
const ( // CurrentVersion is the current On-Disk-Format version CurrentVersion = 0 // HeaderLen is the total header length HeaderLen = headerVersionLen + headerIDLen + headerPropertiesLen + headerSignLen )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentCrypter ¶
type ContentCrypter struct { // Plaintext block pool. Always returns plainBS-sized byte slices. PBlockPool bPool // Ciphertext request data pool. Always returns byte slices of size // fuse.MAX_KERNEL_WRITE + overhead. CReqPool bPool // Plaintext request data pool. Slice have size fuse.MAX_KERNEL_WRITE. PReqPool bPool // contains filtered or unexported fields }
ContentCrypter encrypt and decrypt file content
func NewContentCrypter ¶
func NewContentCrypter(core corecrypter.CoreCrypter, plainBS int) *ContentCrypter
NewContentCrypter initiate a ContentCrypter
func (*ContentCrypter) BlockNoToCipherOff ¶
func (cc *ContentCrypter) BlockNoToCipherOff(blockNo uint64) uint64
BlockNoToCipherOff gets the ciphertext offset of block "blockNo"
func (*ContentCrypter) BlockNoToPlainOff ¶
func (cc *ContentCrypter) BlockNoToPlainOff(blockNo uint64) uint64
BlockNoToPlainOff gets the plaintext offset of block "blockNo"
func (*ContentCrypter) BlockOverhead ¶
func (cc *ContentCrypter) BlockOverhead() uint64
BlockOverhead returns the per-block overhead.
func (*ContentCrypter) CipherBS ¶
func (cc *ContentCrypter) CipherBS() int
CipherBS return the cipher block size
func (*ContentCrypter) CipherOffToBlockNo ¶
func (cc *ContentCrypter) CipherOffToBlockNo(cipherOffset uint64) uint64
CipherOffToBlockNo converts the ciphertext offset to the plaintext block numccr.
func (*ContentCrypter) CipherSizeToPlainSize ¶
func (cc *ContentCrypter) CipherSizeToPlainSize(cipherSize uint64) uint64
CipherSizeToPlainSize calculates the plaintext size from a ciphertext size
func (*ContentCrypter) DecryptBlocks ¶
func (cc *ContentCrypter) DecryptBlocks(cipher []byte, firstBlockNo uint64, fileID []byte) ([][]byte, error)
DecryptBlocks decrypt multiple continous cipher blocks
func (*ContentCrypter) EncryptBlocks ¶
func (cc *ContentCrypter) EncryptBlocks(blocks [][]byte, firstBlockNo uint64, fileID []byte) ([]byte, error)
EncryptBlocks encrypt multiple continuous plain blocks
func (*ContentCrypter) ExplodePlainRange ¶
func (cc *ContentCrypter) ExplodePlainRange(offset uint64, length int) []IntraBlock
ExplodePlainRange splits a plaintext byte range into (possibly partial) blocks Returns an empty slice if length == 0.
func (*ContentCrypter) MergeBlock ¶ added in v0.3.1
func (cc *ContentCrypter) MergeBlock(oldData []byte, newData []byte, offset int) []byte
MergeBlock - Merge newData into oldData at offset
func (*ContentCrypter) PlainBS ¶
func (cc *ContentCrypter) PlainBS() int
PlainBS return the plain block size
func (*ContentCrypter) PlainOffToBlockNo ¶
func (cc *ContentCrypter) PlainOffToBlockNo(plainOffset uint64) uint64
PlainOffToBlockNo converts a plaintext offset to the ciphertext block numccr.
func (*ContentCrypter) PlainSizeToCipherSize ¶
func (cc *ContentCrypter) PlainSizeToCipherSize(plainSize uint64) uint64
PlainSizeToCipherSize calculates the ciphertext size from a plaintext size
func (*ContentCrypter) RewriteBlock ¶
func (cc *ContentCrypter) RewriteBlock(oldData []byte, newData []byte, offset int) []byte
RewriteBlock - Merge newData into oldData at offset
Rewrite in place.
func (*ContentCrypter) TransformPlainRange ¶
func (cc *ContentCrypter) TransformPlainRange(offset uint64, length int) (plainSkip int, alignedOff uint64, alignedLen int)
TransformPlainRange transform plain range to a cipher range for reading
plainSkip: offset to the block start alignedOff: the first block start pos in ciphertext before the transformed range alignedLen: cipher length to cover the transformed range
type FileHeader ¶
type FileHeader struct { Version uint16 FileID []byte Mode uint32 // contains filtered or unexported fields }
FileHeader represents the header stored on each non-empty file.
func NewFileHeader ¶
func NewFileHeader(mode uint32) *FileHeader
NewFileHeader - create new fileHeader object with random Id
func ParseHeader ¶
func ParseHeader(buf []byte) (*FileHeader, error)
ParseHeader - parse "buf" into fileHeader object
func (*FileHeader) Pack ¶
func (h *FileHeader) Pack() []byte
Pack - sign and serialize fileHeader object
type IntraBlock ¶
type IntraBlock struct { // BlockNo is the block numccr in the file BlockNo uint64 // Skip is an offset into the block payload // In forwared mode: block plaintext // In reverse mode: offset into block ciphertext. Takes the header into // account. Skip int // Length of payload data in this block // In forwared mode: length of the plaintext // In reverse mode: length of the ciphertext. Takes header and trailer into // account. Length int // Partial - if this intra block is partial of a block Partial bool }
IntraBlock identifies a part of a file block