public class HelixEncryption extends Object
Constructor and Description |
---|
HelixEncryption(byte[] key,
byte[] nonce)
Creates a new HelixEncryption primitive using the specified key
and nonce.
|
Modifier and Type | Method and Description |
---|---|
int |
bufferSize()
Returns the number of bytes that are currently buffered.
|
protected void |
doBlock(int word)
Applies a single Helix block to an input word.
|
byte[] |
feed(byte[] part)
Processes the next whole number of words (32-bit integers) from
part.
|
byte[] |
finish(byte[] part)
Completes a Helix encryption/decryption operation.
|
byte[] |
getGeneratedMac()
Returns the MAC that was generated following a successful
encryption/decryption operation.
|
protected int |
nextStateWord()
Returns the next state word for use in the main encryption/decryption
loop.
|
protected int[] |
transformWords(int[] plainTextWords,
int mask)
Performs the main encryption/decryption loop.
|
public HelixEncryption(byte[] key, byte[] nonce)
key
- the Helix key (cannot exceed 32 bytes in length)nonce
- the Helix nonce (must be exactly 16 bytes in length)protected int[] transformWords(int[] plainTextWords, int mask)
plainTextWords
- the next group of plaintext words to be encryptedmask
- (ignored)protected final int nextStateWord()
protected final void doBlock(int word)
word
- a single word (32-bit integer) of plaintext or ciphertextpublic final byte[] feed(byte[] part)
Up to three bytes at the end of part may be buffered for the next call, in order to ensure that only a whole number of words are processed during this call.
feed
in interface HelixPrimitive
part
- the next sequence of bytes to be processed by this primitivepublic final int bufferSize()
bufferSize
in interface HelixPrimitive
public byte[] finish(byte[] part)
If this method completes successfully, the generated MAC can be retrieved
using the HelixPrimitive.getGeneratedMac()
method.
All remaining bytes (buffered + part) are processed. Up to three zero-bytes of padding are added to the remaining bytes to ensure that there is a whole number of words to process. Any padded bytes are masked off when the operation is completed.
If this method completes successfully, the generated MAC can be retrieved
using the HelixPrimitive.getGeneratedMac()
method.
finish
in interface HelixPrimitive
part
- the last input bytes to be fedpublic final byte[] getGeneratedMac()
getGeneratedMac
in interface HelixPrimitive
IllegalStateException
- if the encryption/decryption operation has not completed
successfullyCopyright © 2010-2015 Matthew Zipay. All Rights Reserved.