Salmon
|
A virtual file backed by an encrypted IRealFile on the real filesystem. Supports operations for retrieving SalmonStream for reading/decrypting and writing/encrypting contents. More...
Classes | |
class | FileTaskProgress |
File task progress class. More... | |
Public Member Functions | |
SalmonFile (IRealFile realFile, SalmonDrive drive=null) | |
Provides a file handle that can be used to create encrypted files. Requires a virtual drive that supports the underlying filesystem, see DotNetFile implementation. | |
override SalmonStream | GetInputStream () |
Opens a SalmonStream that will be used for reading/decrypting the file contents. | |
override SalmonStream | GetOutputStream () |
Opens a SalmonStream for encrypting/writing contents. | |
void | SetVerifyIntegrity (bool integrity, byte[] hashKey) |
Enabled verification of file integrity during read() and write() | |
void | SetApplyIntegrity (bool integrity, byte[] hashKey, int? requestChunkSize) |
Enable integrity when writing contents. | |
override SalmonFile[] | ListFiles () |
Lists files and directories under this directory. | |
override SalmonFile | GetChild (string filename) |
Get a file/subdirectory with this filename. | |
override SalmonFile | CreateDirectory (string dirName) |
Creates a directory under this directory. | |
SalmonFile | CreateDirectory (string dirName, byte[] key, byte[] dirNameNonce) |
Creates a directory under this directory. | |
override void | Delete () |
Delete this file. | |
override void | Mkdir () |
Create this directory. Currently Not Supported. | |
override SalmonFile | CreateFile (string realFilename) |
Create a file under this directory. | |
SalmonFile | CreateFile (string realFilename, byte[] key, byte[] fileNameNonce, byte[] fileNonce) |
Create a file under this directory. | |
override void | Rename (string newFilename) |
Rename the virtual file name. | |
void | Rename (string newFilename, byte[] nonce) |
Rename the virtual file name. | |
override SalmonFile | Move (IVirtualFile dir, Action< long, long > OnProgressListener) |
Move file to another directory. | |
override SalmonFile | Copy (IVirtualFile dir, Action< long, long > OnProgressListener) |
Copy a file to another directory. | |
override void | CopyRecursively (IVirtualFile dest, Action< IVirtualFile, long, long > progressListener, Func< IVirtualFile, string > AutoRename, bool autoRenameFolders, Action< IVirtualFile, Exception > OnFailed) |
Copy a directory recursively. | |
override void | MoveRecursively (IVirtualFile dest, Action< IVirtualFile, long, long > progressListener, Func< IVirtualFile, string > AutoRename, bool autoRenameFolders, Action< IVirtualFile, Exception > OnFailed) |
Move a directory recursively. | |
override void | DeleteRecursively (Action< IVirtualFile, long, long > progressListener, Action< IVirtualFile, Exception > OnFailed) |
Delete a directory recursively. | |
int | GetMinimumPartSize () |
Returns the minimum part size that can be encrypted / decrypted in parallel aligning to the integrity chunk size if available. | |
Public Member Functions inherited from Mku.File.IVirtualFile | |
Stream | GetInputStream () |
Opens a Stream that will be used for reading the file contents. | |
Stream | GetOutputStream () |
Opens a stream for writing contents. | |
IVirtualFile[] | ListFiles () |
Lists files and directories under this directory. | |
IVirtualFile | GetChild (string filename) |
Get a file/subdirectory with this filename. | |
void | Delete () |
Delete this file. | |
void | Mkdir () |
Create this directory. | |
IVirtualFile | CreateDirectory (string dirName) |
Creates a directory under this directory. | |
IVirtualFile | CreateFile (string realFilename) |
Create a file under this directory. | |
void | Rename (string newFilename) |
Rename the virtual file name. | |
IVirtualFile | Move (IVirtualFile dir, Action< long, long > OnProgressListener) |
Move file to another directory. | |
IVirtualFile | Copy (IVirtualFile dir, Action< long, long > OnProgressListener) |
Copy a file to another directory. | |
void | MoveRecursively (IVirtualFile dest, Action< IVirtualFile, long, long > progressListener, Func< IVirtualFile, string > AutoRename, bool autoRenameFolders, Action< IVirtualFile, Exception > OnFailed) |
Move a directory recursively. | |
void | CopyRecursively (IVirtualFile dest, Action< IVirtualFile, long, long > progressListener, Func< IVirtualFile, string > AutoRename, bool autoRenameFolders, Action< IVirtualFile, Exception > OnFailed) |
Copy a directory recursively. | |
void | DeleteRecursively (Action< IVirtualFile, long, long > progressListener, Action< IVirtualFile, Exception > OnFailed) |
Delete a directory recursively. | |
Static Public Member Functions | |
static string | AutoRename (IVirtualFile file) |
Get an auto generated copy of the name for the file. | |
Protected Member Functions | |
string | GetDecryptedFilename (string filename, byte[] key, byte[] nonce) |
Return the decrypted filename of a real filename. | |
string | GetEncryptedFilename (string filename, byte[] key, byte[] nonce) |
Return the encrypted filename of a virtual filename. | |
Properties | |
SalmonDrive | Drive [get] |
The drive this file belongs too. | |
override IRealFile | RealFile [get, protected set] |
The real encrypted file on the physical disk. | |
override string | Path [get] |
The path of the real file stored. | |
override string | RealPath [get] |
The path of the real file. | |
override long | LastDateTimeModified [get] |
The last date modified in milliseconds. | |
override long | Size [get] |
The virtual size of the file excluding the header and hash signatures. | |
override bool | IsFile [get] |
True if this is a file. | |
override bool | IsDirectory [get] |
True if this is a directory. | |
bool | AllowOverwrite [get, set] |
Warning! Allow overwriting on a current stream. Overwriting is not a good idea because it will re-use the same IV. This is not recommended if you use the stream on storing files or generally data if prior version can be inspected by others. You should only use this setting for initial encryption with parallel streams and not for overwriting! | |
bool | IsIntegrityEnabled [get] |
Is integrity enabled;. | |
Object | Tag [get, set] |
File Tag. You can use to tag this file. | |
int? | RequestedChunkSize [get] |
Return the current chunk size requested that will be used for integrity. | |
int? | FileChunkSize [get] |
Get the file chunk size from the header. | |
SalmonHeader | Header [get] |
The custom SalmonHeader from this file. | |
byte[] | EncryptionKey [get, set] |
Returns the current encryption key. | |
byte[] | FileNonce [get] |
Returns the initial vector that is used for encryption / decryption. | |
byte[] | RequestedNonce [get, set] |
Get the nonce that is used for encryption/decryption of this file. | |
int | BlockSize [get] |
Return the AES block size for encryption / decryption. | |
int | ChildrenCount [get] |
Get the count of files and subdirectories. | |
override string | BaseName [get] |
The base name for the file. | |
override SalmonFile | Parent [get] |
Returns the virtual parent directory. | |
override bool | Exists [get] |
True if this file/directory exists. | |
Properties inherited from Mku.File.IVirtualFile | |
bool | IsFile [get] |
True if this is a file. | |
bool | IsDirectory [get] |
True if this is a directory. | |
string | Path [get] |
The path of the real file stored. | |
string | RealPath [get] |
The path of the real file. | |
IRealFile | RealFile [get, protected set] |
The real encrypted file on the physical disk. | |
string | BaseName [get] |
The base name for the file. | |
IVirtualFile | Parent [get] |
Returns the virtual parent directory. | |
long | LastDateTimeModified [get] |
The last date modified in milliseconds. | |
long | Size [get] |
The virtual size of the file excluding the header and hash signatures. | |
bool | Exists [get] |
True if this file/directory exists. | |
A virtual file backed by an encrypted IRealFile on the real filesystem. Supports operations for retrieving SalmonStream for reading/decrypting and writing/encrypting contents.
Mku.Salmon.SalmonFile.SalmonFile | ( | IRealFile | realFile, |
SalmonDrive | drive = null ) |
Provides a file handle that can be used to create encrypted files. Requires a virtual drive that supports the underlying filesystem, see DotNetFile implementation.
drive | The file virtual system that will be used with file operations |
realFile | The real file |
|
static |
Get an auto generated copy of the name for the file.
file | The file |
override SalmonFile Mku.Salmon.SalmonFile.Copy | ( | IVirtualFile | dir, |
Action< long, long > | OnProgressListener ) |
Copy a file to another directory.
dir | Target directory. |
OnProgressListener | Observer to notify when copy progress changes. |
IOException | Thrown if error during IO |
override void Mku.Salmon.SalmonFile.CopyRecursively | ( | IVirtualFile | dest, |
Action< IVirtualFile, long, long > | progressListener, | ||
Func< IVirtualFile, string > | AutoRename, | ||
bool | autoRenameFolders, | ||
Action< IVirtualFile, Exception > | OnFailed ) |
Copy a directory recursively.
dest | The destination directory |
progressListener | The progress listener |
AutoRename | The autorename function to use when renaming files if they exist |
autoRenameFolders | Apply autorename to folders also (default is true) |
OnFailed | Callback when copy fails |
override SalmonFile Mku.Salmon.SalmonFile.CreateDirectory | ( | string | dirName | ) |
Creates a directory under this directory.
dirName | The name of the directory to be created |
SalmonFile Mku.Salmon.SalmonFile.CreateDirectory | ( | string | dirName, |
byte[] | key, | ||
byte[] | dirNameNonce ) |
Creates a directory under this directory.
dirName | The name of the directory to be created |
key | The key that will be used to encrypt the directory name |
dirNameNonce | The nonce to be used for encrypting the directory name |
override SalmonFile Mku.Salmon.SalmonFile.CreateFile | ( | string | realFilename | ) |
Create a file under this directory.
realFilename | The real file name of the file (encrypted) |
SalmonFile Mku.Salmon.SalmonFile.CreateFile | ( | string | realFilename, |
byte[] | key, | ||
byte[] | fileNameNonce, | ||
byte[] | fileNonce ) |
Create a file under this directory.
realFilename | The real file name of the file (encrypted) |
key | The key that will be used for encryption |
fileNameNonce | The nonce for the encrypting the filename |
fileNonce | The nonce for the encrypting the file contents |
override void Mku.Salmon.SalmonFile.DeleteRecursively | ( | Action< IVirtualFile, long, long > | progressListener, |
Action< IVirtualFile, Exception > | OnFailed ) |
Delete a directory recursively.
progressListener | The progress listener |
OnFailed | Callback when delete fails |
override SalmonFile Mku.Salmon.SalmonFile.GetChild | ( | string | filename | ) |
Get a file/subdirectory with this filename.
filename | The filename to match |
|
protected |
Return the decrypted filename of a real filename.
filename | The filename of a real file |
key | The encryption key if the file doesn't belong to a drive |
nonce | The nonce if the file doesn't belong to a drive |
|
protected |
Return the encrypted filename of a virtual filename.
filename | The virtual filename |
key | The encryption key if the file doesn't belong to a drive |
nonce | The nonce if the file doesn't belong to a drive |
override SalmonStream Mku.Salmon.SalmonFile.GetInputStream | ( | ) |
Opens a SalmonStream that will be used for reading/decrypting the file contents.
IOException | Thrown if error during IO |
SalmonSecurityException | Thrown when error with security |
IntegrityException | Thrown when data are corrupt or tampered with. |
override SalmonStream Mku.Salmon.SalmonFile.GetOutputStream | ( | ) |
Opens a SalmonStream for encrypting/writing contents.
SalmonSecurityException | Thrown when error with security |
IntegrityException | Thrown when data are corrupt or tampered with. |
SequenceException | Thrown when there is a failure in the nonce sequencer. |
override SalmonFile[] Mku.Salmon.SalmonFile.ListFiles | ( | ) |
Lists files and directories under this directory.
override SalmonFile Mku.Salmon.SalmonFile.Move | ( | IVirtualFile | dir, |
Action< long, long > | OnProgressListener ) |
Move file to another directory.
dir | Target directory. |
OnProgressListener | Observer to notify when move progress changes. |
IOException | Thrown if error during IO |
override void Mku.Salmon.SalmonFile.MoveRecursively | ( | IVirtualFile | dest, |
Action< IVirtualFile, long, long > | progressListener, | ||
Func< IVirtualFile, string > | AutoRename, | ||
bool | autoRenameFolders, | ||
Action< IVirtualFile, Exception > | OnFailed ) |
Move a directory recursively.
dest | The destination directory |
progressListener | The progress listener |
AutoRename | The autorename function to use when renaming files if they exist |
autoRenameFolders | Apply autorename to folders also (default is true) |
OnFailed | Callback when move fails |
override void Mku.Salmon.SalmonFile.Rename | ( | string | newFilename | ) |
Rename the virtual file name.
newFilename | The new filename this file will be renamed to |
void Mku.Salmon.SalmonFile.Rename | ( | string | newFilename, |
byte[] | nonce ) |
Rename the virtual file name.
newFilename | The new filename this file will be renamed to |
nonce | The nonce to be used |
void Mku.Salmon.SalmonFile.SetApplyIntegrity | ( | bool | integrity, |
byte[] | hashKey, | ||
int? | requestChunkSize ) |
Enable integrity when writing contents.
hashKey | The hash key |
integrity | The integrity |
requestChunkSize | 0 use default file chunk. |
A positive number to specify integrity chunks.
void Mku.Salmon.SalmonFile.SetVerifyIntegrity | ( | bool | integrity, |
byte[] | hashKey ) |
Enabled verification of file integrity during read() and write()
integrity | True if enable integrity verification |
hashKey | The hash key to be used for verification |
|
getset |
Warning! Allow overwriting on a current stream. Overwriting is not a good idea because it will re-use the same IV. This is not recommended if you use the stream on storing files or generally data if prior version can be inspected by others. You should only use this setting for initial encryption with parallel streams and not for overwriting!
value | True to allow overwriting operations |
|
get |
Get the count of files and subdirectories.
|
get |
Get the file chunk size from the header.
IOException | Thrown if the format is corrupt. |
|
get |
The custom SalmonHeader from this file.
IOException | Thrown if error during IO |
|
getset |
Get the nonce that is used for encryption/decryption of this file.