Package com.mku.salmon.transform
Class SalmonAES256CTRTransformer
java.lang.Object
com.mku.salmon.transform.SalmonAES256CTRTransformer
- All Implemented Interfaces:
ISalmonCTRTransformer
- Direct Known Subclasses:
SalmonDefaultTransformer,SalmonNativeTransformer
Abstract class for AES256 transformer implementations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSalmon stream encryption block size, same as AES.static final intStandard expansion key size for AES256 only. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetBlock()Get the current block.byte[]Get the current Counter.protected byte[]Get the expanded key if available.byte[]getKey()Get the current encryption key.byte[]getNonce()Get the nonce (initial counter)protected voidincreaseCounter(long value) Increase the Counter We use only big endianness for AES regardless of the machine architecturevoidinit(byte[] key, byte[] nonce) Initialize the transformer.voidResets the Counter and the block count.voidsetExpandedKey(byte[] expandedKey) Set the expanded key.voidsyncCounter(long position) Syncs the Counter based on what AES block position the stream is at.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.mku.salmon.transform.ISalmonCTRTransformer
decryptData, encryptData
-
Field Details
-
EXPANDED_KEY_SIZE
public static final int EXPANDED_KEY_SIZEStandard expansion key size for AES256 only.- See Also:
-
BLOCK_SIZE
public static final int BLOCK_SIZESalmon stream encryption block size, same as AES.- See Also:
-
-
Constructor Details
-
SalmonAES256CTRTransformer
public SalmonAES256CTRTransformer()
-
-
Method Details
-
resetCounter
public void resetCounter()Resets the Counter and the block count.- Specified by:
resetCounterin interfaceISalmonCTRTransformer
-
syncCounter
public void syncCounter(long 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.- Specified by:
syncCounterin interfaceISalmonCTRTransformer- Parameters:
position- The position to sync the counter to
-
increaseCounter
protected void increaseCounter(long value) Increase the Counter We use only big endianness for AES regardless of the machine architecture- Parameters:
value- value to increase counter by
-
init
public void init(byte[] key, byte[] nonce) Initialize the transformer. Most common operations include precalculating expansion keys or any other prior initialization for efficiency.- Specified by:
initin interfaceISalmonCTRTransformer- Parameters:
key- The keynonce- The nonce- Throws:
SalmonSecurityException- Thrown if there is a security exception
-
getCounter
public byte[] getCounter()Get the current Counter.- Specified by:
getCounterin interfaceISalmonCTRTransformer- Returns:
- The current counter
-
getBlock
public long getBlock()Get the current block.- Specified by:
getBlockin interfaceISalmonCTRTransformer- Returns:
- The current block
-
getKey
public byte[] getKey()Get the current encryption key.- Specified by:
getKeyin interfaceISalmonCTRTransformer- Returns:
- The encryption key
-
getExpandedKey
protected byte[] getExpandedKey()Get the expanded key if available.- Returns:
- The expanded key
-
getNonce
public byte[] getNonce()Get the nonce (initial counter)- Specified by:
getNoncein interfaceISalmonCTRTransformer- Returns:
- The nonce
-
setExpandedKey
public void setExpandedKey(byte[] expandedKey) Set the expanded key. This should be called once during initialization phase.- Parameters:
expandedKey- The expanded key
-