Constructor
new SalmonAES256CTRTransformer()
Classes
Members
(static) BLOCK_SIZE
Salmon stream encryption block size, same as AES.
(static) EXPANDED_KEY_SIZE
Standard expansion key size for AES256 only.
Methods
getBlock() → {number}
Get the current block.
Returns:
The current block.
- Type
- number
getCounter() → {Uint8Array}
Get the current counter.
Returns:
The current counter.
- Type
- Uint8Array
getExpandedKey() → {Uint8Array|null}
Get the expanded key if available.
Returns:
The expanded key.
- Type
- Uint8Array | null
getKey() → {Uint8Array|null}
Get the current encryption key.
Returns:
The encryption key.
- Type
- Uint8Array | null
getNonce() → {Uint8Array|null}
Get the nonce (initial counter)
Returns:
The nonce.
- Type
- Uint8Array | null
increaseCounter(value)
Increase the Counter
We use only big endianness for AES regardless of the machine architecture
Parameters:
Name | Type | Description |
---|---|---|
value |
number | value to increase counter by |
(async) init(key, nonce)
Initialize the transformer. Most common operations include precalculating expansion keys or
any other prior initialization for efficiency.
Parameters:
Name | Type | Description |
---|---|---|
key |
Uint8Array | The key |
nonce |
Uint8Array | The nonce |
Throws:
SalmonSecurityException Thrown when error with security
resetCounter()
Resets the Counter and the block count.
setExpandedKey(expandedKey)
Set the expanded key. This should be called once during initialization phase.
Parameters:
Name | Type | Description |
---|---|---|
expandedKey |
Uint8Array | The expanded key |
syncCounter(position)
Syncs the Counter based on what AES block position the stream is at.
The block count is already excluding the header and the hash signatures.
Parameters:
Name | Type | Description |
---|---|---|
position |
number | The new position to sync to |