NativeCrypt
class NativeCrypt extends Native
Implements an encryption layer on top of the native filesystem.
Files are divided into chunks, the size of which can be configured. Import and Truncate are not as fast since new data must actually be written.
The crypto key for the filesystem is stored plainly in the database, so this is only useful for off-server untrusted external storages. Client-side crypto should be used for any case where the API is not trusted.
Properties
| protected | $fsmanager | from FSImpl | |
| protected | $masterkey | ||
| protected | $chunksize |
Methods
Returns the preferred byte alignment of the filesystem.
Helper function to emulate copying a folder by copying its contents manually
Chunk swapping is prevented by signing each with the file ID and chunk index
Returns the chunk index storing the given byte offset
Returns the number of chunks required to store the given number of bytes
Encrypts and writes the given data to the given chunk
Details
at line 29
__construct(FSManager $filesystem, string $masterkey, int $chunksize)
No description
at line 36
int|null
GetChunkSize()
Returns the preferred byte alignment of the filesystem.
Reads and writes should align to these boundaries for performance
in
FSImpl at line 40
protected FSManager
GetFSManager()
Returns a reference to the parent FS manager
in
FSImpl at line 46
protected ObjectDatabase
GetDatabase()
Returns a database reference
at line 47
FSImpl
ImportFile(File $file, InputPath $infile)
Creates a new file and imports its content
in
BaseFileFS at line 19
FSImpl
CreateFile(File $file)
Creates an empty file on storage
in
BaseFileFS at line 49
FSImpl
DeleteFile(File $file)
Deletes the given file from storage
at line 73
string
ReadBytes(File $file, int $start, int $length)
Reads the exact number of desired bytes from the given file
Throws an error if the read goes beyond the end of the file
at line 101
FSImpl
WriteBytes(File $file, int $start, string $data)
Writes to the given file, possibly appending it
in
BaseFileFS at line 44
FSImpl
CopyFile(File $file, File $dest)
Copies a file
in
Native at line 93
protected string
GetFilePath(File $file)
The path to a file is simply its ID, broken into a prefix
in
BaseFileFS at line 60
protected BaseFileFS
ManualCopyFolder(Folder $folder, Folder $dest)
Helper function to emulate copying a folder by copying its contents manually
at line 39
private
GetAuthString(File $file, int $index)
Chunk swapping is prevented by signing each with the file ID and chunk index
at line 42
protected int
GetChunkIndex(int $byte)
Returns the chunk index storing the given byte offset
at line 45
protected int
GetNumChunks(int $bytes)
Returns the number of chunks required to store the given number of bytes
at line 189
protected string
ReadChunk(File $file, int $index)
Reads and decrypts the given chunk from the file
at line 223
protected NativeCrypt
WriteChunk(File $file, int $index, string $data)
Encrypts and writes the given data to the given chunk