Members
(constant) AES_IMPL_AES
AES-256 using pure C.
(constant) AES_IMPL_AES_GPU
AES-256 using GPU (WebGPU).
(constant) AES_IMPL_AES_INTR
AES-256 using NI-Intrinsics.
Note: Not supported for browser
EncryptionFormat
Encryption Format
EncryptionFormat[undefined]
Generic format without header information, compatible with other AES-256 CTR libraries.
EncryptionFormat[undefined]
Salmon format with header (embedded nonce and integrity support).
EncryptionMode
Encryption Mode
- Source:
- See:
EncryptionMode[undefined]
Encryption Mode used with a base stream as a target.
EncryptionMode[undefined]
Decryption Mode used with a base stream as a source.
OSType
The operating system the script is running on.
- Source:
OSType[undefined]
Windows
- Source:
OSType[undefined]
Linux
- Source:
OSType[undefined]
Darwin (MacOS)
- Source:
OSType[undefined]
Unknown
- Source:
(constant) PBKDF_SHA256
Java Cipher key for SHA256. See javax.crypto.SecretKeyFactory.
PbkdfAlgo
Pbkdf algorithm implementation type.
PbkdfAlgo[undefined]
SHA256 hashing.
PbkdfType
Pbkdf implementation type.
PbkdfType[undefined]
Default Java pbkdf implementation.
PlatformType
The platform the script is running on.
- Source:
PlatformType[undefined]
Browser
- Source:
PlatformType[undefined]
NodeJs
- Source:
ProviderType
AES provider types. List of AES implementations that currently supported.
- Source:
- See:
ProviderType[undefined]
Default JS AES cipher.
ProviderType[undefined]
Salmon builtin AES intrinsics. This needs the SalmonNative library to be loaded. @see Salmon README.md
ProviderType[undefined]
Salmon AES implementation. This needs the SalmonNative library to be loaded. @see Salmon README.md
ProviderType[undefined]
Salmon AES GPU implementation. This needs OpenCL, a compatible graphics card, and the SalmonNative library to be loaded. @see Salmon README.md
SearchEvent
Event status types.
SearchEvent[undefined]
Search files
SearchEvent[undefined]
Search is complete
SeekOrigin
Used to identify the start offset for seeking to a stream.
SeekOrigin[undefined]
Start from the beginning of the stream.
SeekOrigin[undefined]
Start from the current position of the stream.
SeekOrigin[undefined]
Start from the end of the stream.
Status
Sequencer status.
- Source:
- See:
Status[undefined]
Newly created sequence.
Status[undefined]
Currently active sequence used to provide nonces for data encryption ie: file contents and filenames.
Status[undefined]
Revoked sequence. This cannot be reused you need to re-authorize the device.
Methods
(async) AesDrive.(dir, createIfNotExists) → {Promise.<AesDrive>}
Create a drive instance.
Parameters:
| Name | Type | Description |
|---|---|---|
dir |
IFile | The target directory where the drive is located. |
createIfNotExists |
boolean | Create the drive if it does not exist |
Throws:
SalmonSecurityException Thrown when error with security
Returns:
The drive
- Type
- Promise.<AesDrive>
(async) AuthConfig.(authConfigFile, drive, targetAuthId, targetStartingNonce, targetMaxNonce, configNonce)
Write the properties of the auth configuration to a config file that will be imported by another device.
The new device will then be authorized editing operations ie: import, rename files, etc.
Parameters:
| Name | Type | Description |
|---|---|---|
authConfigFile |
IFile | The authorization configuration file. |
drive |
AesDrive | The drive you want to create an auth config for. |
targetAuthId |
Uint8Array | Authorization ID of the target device. |
targetStartingNonce |
Uint8Array | Starting nonce for the target device. |
targetMaxNonce |
Uint8Array | Maximum nonce for the target device. |
configNonce |
Uint8Array | THe configuration nonce |
Throws:
Exception
(async) AuthConfig.(stream, driveId, authId, nextNonce, maxNonce)
Write authorization configuration to a SalmonStream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
RandomAccessStream | The stream to write to. |
driveId |
Uint8Array | The drive id. |
authId |
Uint8Array | The auth id of the new device. |
nextNonce |
Uint8Array | The next nonce to be used by the new device. |
maxNonce |
Uint8Array | The max nonce to be used byte the new device. |
Throws:
Exception
(async) AuthConfig.(drive, authFile) → {Promise.<AuthConfig>}
Get the app drive pair configuration properties for this drive
Parameters:
| Name | Type | Description |
|---|---|---|
drive |
AesDrive | The drive. |
authFile |
IFile | The encrypted authorization file. |
Throws:
Exception
Returns:
The decrypted authorization file.
- Type
- Promise.<AuthConfig>
(async) AuthConfig.(drive, authId) → {Promise.<boolean>}
Verify the authorization id with the current drive auth id.
Parameters:
| Name | Type | Description |
|---|---|---|
drive |
AesDrive | The drive |
authId |
Uint8Array | The authorization id to verify. |
Throws:
Exception
Returns:
True if verification succeeds
- Type
- Promise.<boolean>
(async) AuthConfig.(drive, authConfig)
Import sequence into the current drive.
Parameters:
| Name | Type | Description |
|---|---|---|
drive |
AesDrive | The drive |
authConfig |
AuthConfig | The authorization configuration |
Throws:
Exception
FileSequencer.(configs, driveId) → {NonceSequence|null}
Get the sequence for the drive provided.
Parameters:
| Name | Type | Description |
|---|---|---|
configs |
Map.<string, NonceSequence> | All sequence configurations. |
driveId |
string | The drive ID. |
Throws:
SequenceException Thrown if error with the nonce sequence
Returns:
The nonce sequence
- Type
- NonceSequence | null
(async) WebGPU.() → {any|null}
Retrieve the gpu device
Returns:
The gpu device
- Type
- any | null
aes_key_expand(key, expandedKey)
Expand an AES-256 32-byte key to a 240-byte set of round keys.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
The AES-256 (32-byte) key to expand. | |
expandedKey |
The expanded key (240-bytes). |
aes_transform(expandedKey, data)
Transform a 16-byte block using AES-256.
Parameters:
| Name | Type | Description |
|---|---|---|
expandedKey |
The expandedKey 240 bytes, see aes_key_expand() | |
data |
The data to transform. |
aes_transform_ctr(expandedKey, counter, srcBuffer, srcOffset, destBuffer, destOffset, count)
Transform the data using AES-256 CTR mode.
Parameters:
| Name | Type | Description |
|---|---|---|
expandedKey |
The expanded AES-256 key (240 bytes), see aes_key_expand() | |
counter |
The counter. | |
srcBuffer |
The source array to transform. | |
srcOffset |
The source offset. | |
destBuffer |
The source array to transform. | |
destOffset |
The destination offset | |
count |
The number of bytes to transform |
Returns:
The number of bytes transformed.
autoRename(file) → {Promise.<string>}
Default autorename.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
AesFile | The file to be renamed |
Returns:
The new file name
- Type
- Promise.<string>
autoRename(filename) → {string}
Get an auto generated copy of a file name
Parameters:
| Name | Type | Description |
|---|---|---|
filename |
string | The current file name |
- Source:
Returns:
The new file name
- Type
- string
autoRenameFile(file) → {Promise.<string>}
Default autorename.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
AesFile | The file to be renamed |
Returns:
The new file name
- Type
- Promise.<string>
autoRenameFile(file) → {Promise.<string>}
Get an auto generated copy of the name for a file.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
IFile | The file |
- Source:
Returns:
The new file name
- Type
- Promise.<string>
copyFileContents(src, dest, optionsopt) → {Promise.<boolean>}
Copy contents of a file to another file.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
src |
IFile | The source directory | |
dest |
IFile | The target directory | |
options |
CopyContentOptions |
<optional> |
The options |
- Source:
Throws:
IOException Thrown if there is an IO error.
Returns:
True if files are copied successfully
- Type
- Promise.<boolean>
copyRecursively(src, destDir, optionsopt)
Copy a directory recursively
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
src |
IFile | Source directory | |
destDir |
IFile | Destination directory to copy into. | |
options |
RecursiveCopyOptions |
<optional> |
The options. |
- Source:
Throws:
IOException Thrown if there is an IO error.
decryptData(data, start, count, outData, key, nonce, format, integrity, hashKey, chunkSize) → {Promise.<{startPos: number, endPos: number}>}
Decrypt the data.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array | The data to be decrypted. |
start |
number | The start position of the stream to be decrypted. |
count |
number | The number of bytes to be decrypted. |
outData |
Uint8Array | The buffer with the decrypted data. |
key |
Uint8Array | The AES key to be used. |
nonce |
Uint8Array | null | The nonce to be used. |
format |
EncryptionFormat | The format to use, see EncryptionFormat |
integrity |
boolean | True to verify integrity. |
hashKey |
Uint8Array | null | The hash key to be used for integrity verification. |
chunkSize |
number | The chunk size. Thrown if there is an error with the stream. |
Throws:
-
SalmonSecurityException Thrown if there is a security exception with the stream.
-
IntegrityException Thrown if the stream is corrupt or tampered with.
Returns:
The number of bytes decrypted.
- Type
- Promise.<{startPos: number, endPos: number}>
deleteRecursively(optionsopt)
Delete a directory recursively
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
RecursiveDeleteOptions |
<optional> |
The options |
- Source:
encryptData(data, start, count, outData, key, nonce, format, integrity, hashKey, chunkSize) → {Promise.<{startPos: number, endPos: number}>}
Encrypt the data.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array | The data to be encrypted. |
start |
number | The start position of the stream to be encrypted. |
count |
number | The number of bytes to be encrypted. |
outData |
Uint8Array | The buffer with the encrypted data. |
key |
Uint8Array | The AES key to be used. |
nonce |
Uint8Array | The nonce to be used. |
format |
EncryptionFormat | The format to use, see EncryptionFormat |
integrity |
boolean | True to apply integrity. |
hashKey |
Uint8Array | null | The key to be used for integrity application. |
chunkSize |
number | The chunk size. Thrown if there is an error with the stream. |
Throws:
-
SalmonSecurityException Thrown if there is a security exception with the stream.
-
IntegrityException Thrown if integrity cannot be applied.
Returns:
The number of bytes encrypted.
- Type
- Promise.<{startPos: number, endPos: number}>
exportFilePart(fileToExport, exportFile, start, count, totalBytesWritten, onProgressChanged)
Export a file part from the drive. Do not use this directly, use FileExporter instead.
Parameters:
| Name | Type | Description |
|---|---|---|
fileToExport |
IVirtualFile | The file the part belongs to |
exportFile |
IFile | The file to copy the exported part to |
start |
number | The start position on the file |
count |
number | The length of the bytes to be decrypted |
totalBytesWritten |
Array.<number> | The total bytes that were written to the external file |
onProgressChanged |
OnFileExportProgressChanged | The file progress |
fillBufferPart(cacheBuffer, length, stream)
Fills a cache buffer with the data from a part of a stream.
Do not use directly, use ReadableStreamWrapper.create() instead.
Parameters:
| Name | Type | Description |
|---|---|---|
cacheBuffer |
Buffer | The cache buffer that will store the contents |
length |
Uint8Array | The length of the data requested |
stream |
RandomAccessStream | The stream that will be used to read from |
getExtension(fileName) → {string}
Get extension from file name
Parameters:
| Name | Type | Description |
|---|---|---|
fileName |
string | The file name |
- Source:
Returns:
The extension
- Type
- string
getPbkdfAlgoString(pbkdfAlgo) → {string}
Get the PBKDF JavaScript cipher algorigthm string.
Parameters:
| Name | Type | Description |
|---|---|---|
pbkdfAlgo |
PbkdfAlgo.SHA256 | The PBKDF algorithm to be used |
Returns:
The JavaScript cipher algorithm string. See javax.crypto.SecretKeyFactory.
- Type
- string
getSalmonAESShader(chunkSize)
Get the AES shader
Parameters:
| Name | Type | Description |
|---|---|---|
chunkSize |
The chunk size |
Returns:
The shader for aes tranformation
importFilePart(fileToImport, aesFile, start, count, totalBytesRead, onProgressChanged)
Import a file part into a file in the drive. Do not use this directly, use FileImporter instead.
Parameters:
| Name | Type | Description |
|---|---|---|
fileToImport |
IFile | The external file that will be imported |
aesFile |
IVirtualFile | The file that will be imported to |
start |
number | The start position of the byte data that will be imported |
count |
number | The length of the file content that will be imported |
totalBytesRead |
number | The total bytes read from the external file |
onProgressChanged |
OnFileImportProgressChanged | Progress observer |
moveRecursively(file, destDir, optionsopt)
Move a directory recursively
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
file |
IFile | Source directory | |
destDir |
IFile | Destination directory to move into. | |
options |
RecursiveMoveOptions |
<optional> |
The options |
- Source:
salmon_expandKey(key, expandedKey)
Expand an AES-256 32-byte key to a 240-byte set of round keys.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
The AES-256 (32-byte) key to expand. | |
expandedKey |
The expanded key (240-bytes). |
salmon_init(aesImplType)
Initialize the transformer.
Parameters:
| Name | Type | Description |
|---|---|---|
aesImplType |
The AES implementation: see: AES_IMPL_AES_INTR, AES_IMPL_TINY_AES, AES_IMPL_AES_GPU |
salmon_transform(expandedKey, counter, srcBuffer, srcOffset, destBuffer, destOffset, count)
Transform the data using AES-256 CTR mode.
Parameters:
| Name | Type | Description |
|---|---|---|
expandedKey |
The expanded AES-256 key (240 bytes), see aes_key_expand | |
counter |
The counter to use. | |
srcBuffer |
The source byte array. | |
srcOffset |
The source byte offset. | |
destBuffer |
The destination byte array. | |
destOffset |
The destination byte offset. | |
count |
The number of bytes to transform. |
Returns:
The number of bytes transformed.
Type Definitions
OnFileExportProgressChanged(position, length)
Progress Callback
Parameters:
| Name | Type | Description |
|---|---|---|
position |
number | The current position |
length |
number | The total length |
OnFileImportProgressChanged(position, length)
Progress Callback
Parameters:
| Name | Type | Description |
|---|---|---|
position |
number | The current position |
length |
number | The total length |