Documentation
¶
Index ¶
- Constants
- Variables
- func AESGCMDecrypt(cipherText []byte, key [16]byte) ([]byte, error)
- func AESGCMEncrypt(plainText []byte, key [16]byte) ([]byte, error)
- func DecryptContent(cipher *xts.Cipher, reader io.Reader, writer io.Writer, size int64) error
- func EncryptContent(cipher *xts.Cipher, reader io.Reader, writer io.Writer) error
- func GeneratePasswordFromFile(filePath string) ([]byte, error)
- func GenerateRandomPassword(length int) ([]byte, error)
- func HKDF(secret []byte, salt []byte, info []byte, length int) []byte
- func IsEmixFile(r io.Reader) (bool, error)
- func IsEmixFileByData(data []byte) (bool, error)
- func IsEmixFileByPath(path string) (bool, error)
- func NewAESGCM(key [16]byte) (cipher.AEAD, error)
- func NewAESXTS(key [16]byte) (*xts.Cipher, error)
- func ZipHeader() []byte
- func ZipHeaderLength() int
- type EmixHeader
- type FileInfo
Constants ¶
const ( // 4K XTSSectorSize = 1024 * 4 // SectorNumberStart as sector number for AES-XTS SectorNumberStart = 1024 )
Variables ¶
var ( /// errors ErrNameTooShort = errors.New("name too short") ErrNameTooLong = errors.New("name too long") ErrInvalidEmixHeader = errors.New("invalid emix header") ErrInvalidEmixFileContent = errors.New("invalid emix file content") ErrInvalidEncodedFileInfo = errors.New("invalid file info") )
Functions ¶
func DecryptContent ¶
EncryptContent decrypt file content using AES-XTS, read cipher data from reader and write plain data to writer
func EncryptContent ¶
EncryptContent encrypt file content using AES-XTS, read data from reader and write cipher data to writer
func GeneratePasswordFromFile ¶
GeneratePasswordFromFile use a credential file to generate password return 16-byte password
func GenerateRandomPassword ¶
GenerateRandomPassword generate random length-byte password
func IsEmixFile ¶
IsEmixFile check if the file is emix file
func IsEmixFileByData ¶
IsEmixFileByData check if the data is emix file
func IsEmixFileByPath ¶
IsEmixFileByPath check if the path is emix file
Types ¶
type EmixHeader ¶
type EmixHeader struct { EncryptInfo bool EncryptData bool // EmbedPassword must only use auto generated 16-byte password EmbedPassword bool Password [16]byte FileInfo FileInfo }
func (*EmixHeader) EncodedLength ¶
func (e *EmixHeader) EncodedLength() int
EncodedLength return EmixHeader encoded length
func (*EmixHeader) MarshalBinary ¶
func (e *EmixHeader) MarshalBinary() ([]byte, error)
func (*EmixHeader) UnmarshalBinary ¶
func (e *EmixHeader) UnmarshalBinary(data []byte) error
func (*EmixHeader) UnmarshalBinaryFromReader ¶
func (e *EmixHeader) UnmarshalBinaryFromReader(r io.Reader) error
type FileInfo ¶
type FileInfo struct { Name string Size uint64 Mode uint32 CreateTime uint64 ModifyTime uint64 FileContentHash [32]byte }
func (*FileInfo) EncodedLength ¶
EncodedLength measure encoded length
func (*FileInfo) MarshalBinary ¶
MarshalBinary serialize FileInfo format: namelength + name + size + mode + create time + modify time namelength use 2 bytes
func (*FileInfo) UnmarshalBinary ¶
UnmarshalBinary deserialize FileInfo