Salmon
Loading...
Searching...
No Matches
Mku.Salmon.SalmonDrive Class Referenceabstract

Class provides an abstract virtual drive that can be extended for use with any filesystem ie disk, net, cloud, etc. Drive implementations needs to be realized together with IRealFile }. More...

Inheritance diagram for Mku.Salmon.SalmonDrive:
Mku.Drive.VirtualDrive Mku.Android.Salmon.Drive.AndroidDrive Mku.Salmon.Drive.DotNetDrive

Public Member Functions

void SetPassword (string pass)
 Change the user password.
 
byte[] GetAuthIdBytes ()
 Get the device authorization byte array for the current drive.
 
string GetDefaultAuthConfigFilename ()
 Get the default authorization config filename.
 
byte[] GetNextNonce (SalmonDrive salmonDrive)
 Get the next nonce for the drive. This operation IS atomic as per transaction.
 
void RevokeAuthorization ()
 Revoke authorization for this device. This will effectively terminate write operations on the current disk by the current device. Warning: If you need to authorize write operations to the device again you will need to have another device to export an authorization config file and reimport it.
 
string GetAuthId ()
 Get the authorization ID for the current device.
 
byte[] GetBytesFromRealFile (IRealFile file, int bufferSize)
 Get the byte contents of a file from the real filesystem.
 
bool HasConfig ()
 Return true if the drive is already created and has a configuration file.
 
void Close ()
 Close the drive and close associated resources.
 
- Public Member Functions inherited from Mku.Drive.VirtualDrive
void OnUnlockSuccess ()
 
void OnUnlockError ()
 

Static Public Member Functions

static SalmonDrive OpenDrive (IRealFile dir, Type driveClassType, string password, INonceSequencer sequencer)
 Set the drive location to an external directory. This requires you previously use SetDriveClass() to provide a class for the drive.
 
static SalmonDrive CreateDrive (IRealFile dir, Type driveClassType, string password, INonceSequencer sequencer)
 Create a new drive in the provided location.
 

Protected Member Functions

void Initialize (IRealFile realRoot, bool createIfNotExists=false)
 Create a virtual drive at the directory path provided.
 
void InitFS ()
 Initialize the drive virtual filesystem.
 
SalmonDriveConfig GetDriveConfig ()
 Return the configuration properties of this drive.
 

Properties

static string ConfigFilename = "vault.slmn" [get, set]
 Default config filename.
 
static string AuthConfigFilename = "auth.slma" [get, set]
 Default aUthorization filename.
 
static string VirtualDriveDirectoryName = "fs" [get, set]
 Virtual drive directory to host the encrypted files.
 
static string ShareDirectoryName = "share" [get, set]
 Default shared directory.
 
static string ExportDirectoryName = "export" [get, set]
 Default export directory filename.
 
int DefaultFileChunkSize = DEFAULT_FILE_CHUNK_SIZE [get, set]
 Default file chunk that will be used to import new files.
 
SalmonDriveKey Key = null [get]
 The current key.
 
byte[] DriveId [get]
 The current drive ID.
 
IRealFile RealRoot = null [get]
 The real root location of the vault.
 
INonceSequencer Sequencer [get, set]
 Set the nonce sequencer used for the current drive.
 
override SalmonFile Root [get]
 Return the virtual root directory of the drive.
 
IRealFile ExportDir [get]
 Return the default external export dir that all file can be exported to.
 
- Properties inherited from Mku.Drive.VirtualDrive
IRealFile PrivateDir [get]
 Get the private directory for this drive.
 
IVirtualFile Root [get]
 Get the root directory.
 

Detailed Description

Class provides an abstract virtual drive that can be extended for use with any filesystem ie disk, net, cloud, etc. Drive implementations needs to be realized together with IRealFile }.

Member Function Documentation

◆ CreateDrive()

static SalmonDrive Mku.Salmon.SalmonDrive.CreateDrive ( IRealFile dir,
Type driveClassType,
string password,
INonceSequencer sequencer )
static

Create a new drive in the provided location.

Parameters
dirDirectory to store the drive configuration and virtual filesystem.
driveClassTypeThe drive class type of this drive (ie typeof(DotNetDrive))
passwordMaster password to encrypt the drive configuration.
sequencerThe sequencer
Returns
The newly created drive.
Exceptions
IntegrityExceptionThrown when data are corrupt or tampered with.
SequenceExceptionThrown when there is a failure in the nonce sequencer.

◆ GetAuthId()

string Mku.Salmon.SalmonDrive.GetAuthId ( )

Get the authorization ID for the current device.

Returns
The authorization id
Exceptions
SequenceExceptionThrown when there is a failure in the nonce sequencer.
SalmonAuthExceptionThrown when there is a failure during authorization

◆ GetAuthIdBytes()

byte[] Mku.Salmon.SalmonDrive.GetAuthIdBytes ( )

Get the device authorization byte array for the current drive.

Returns
The authorization id
Exceptions
ExceptionThrown if error during operation

◆ GetBytesFromRealFile()

byte[] Mku.Salmon.SalmonDrive.GetBytesFromRealFile ( IRealFile file,
int bufferSize )

Get the byte contents of a file from the real filesystem.

Parameters
fileThe file
bufferSizeThe buffer to be used when reading

◆ GetDefaultAuthConfigFilename()

string Mku.Salmon.SalmonDrive.GetDefaultAuthConfigFilename ( )

Get the default authorization config filename.

Returns
The default authorization configuration file name

◆ GetNextNonce()

byte[] Mku.Salmon.SalmonDrive.GetNextNonce ( SalmonDrive salmonDrive)

Get the next nonce for the drive. This operation IS atomic as per transaction.

Parameters
salmonDriveThe drive
Returns
The next nonce
Exceptions
SequenceExceptionThrown when there is a failure in the nonce sequencer.
SalmonRangeExceededExceptionThrown when maximum nonce range is exceeded.

◆ Initialize()

void Mku.Salmon.SalmonDrive.Initialize ( IRealFile realRoot,
bool createIfNotExists = false )
protected

Create a virtual drive at the directory path provided.

Parameters
realRootThe root of the real directory
createIfNotExistsCreate the drive if it does not exist

◆ OpenDrive()

static SalmonDrive Mku.Salmon.SalmonDrive.OpenDrive ( IRealFile dir,
Type driveClassType,
string password,
INonceSequencer sequencer )
static

Set the drive location to an external directory. This requires you previously use SetDriveClass() to provide a class for the drive.

Parameters
dirThe directory that will be used for storing the contents of the drive
driveClassTypeThe class type of the drive (ie: typeof(DotNetDrive))
passwordpassword
sequencerThe sequencer

◆ RevokeAuthorization()

void Mku.Salmon.SalmonDrive.RevokeAuthorization ( )

Revoke authorization for this device. This will effectively terminate write operations on the current disk by the current device. Warning: If you need to authorize write operations to the device again you will need to have another device to export an authorization config file and reimport it.

See: README.md

Exceptions
ExceptionThrown if error during operation

◆ SetPassword()

void Mku.Salmon.SalmonDrive.SetPassword ( string pass)

Change the user password.

Parameters
passThe new password.
Exceptions
IOExceptionThrown if error during IO
SalmonAuthExceptionThrown when there is a failure during authorization
SalmonSecurityExceptionThrown when error with security
IntegrityExceptionThrown when data are corrupt or tampered with.
SequenceExceptionThrown when there is a failure in the nonce sequencer.

Property Documentation

◆ ExportDir

IRealFile Mku.Salmon.SalmonDrive.ExportDir
get

Return the default external export dir that all file can be exported to.

Returns
The file on the real filesystem.

◆ Root

override SalmonFile Mku.Salmon.SalmonDrive.Root
get

Return the virtual root directory of the drive.

Returns
The root directory
Exceptions
SalmonAuthExceptionThrown when there is a failure during authorization

The documentation for this class was generated from the following file: