de.flexiprovider.core.mac
Class TwoTrackMac
java.lang.Object
|
+--javax.crypto.MacSpi
|
+--de.flexiprovider.api.Mac
|
+--de.flexiprovider.core.mac.TwoTrackMac
- Direct Known Subclasses:
- TwoTrackMac.TTMac128, TwoTrackMac.TTMac160, TwoTrackMac.TTMac32, TwoTrackMac.TTMac64, TwoTrackMac.TTMac96
- public abstract class TwoTrackMac
- extends Mac
This class extends the Mac class for providing the functionality of
the TTMAC(Two-Track-MAC) algorithm, as specified in the
version 2.0 of the NESSIE final reports.
Any application dealing with MAC computation, uses the getInstance method of
the MAC class for creating a MAC object.
The FlexiProvider supports TTMAC computation with 32, 64, 96, 128 and 160-bit
output.
- Author:
- Paul Nguentcheu
|
Constructor Summary |
protected |
TwoTrackMac(int len)
Creates a new TTMac with the specified MAC length. |
|
Method Summary |
byte[] |
doFinal()
Returns the calculated MAC value. |
int |
getMacLength()
Returns the length of the MAC in Bytes. |
void |
init(SecretKey key,
AlgorithmParameterSpec params)
Initializes the Object with the given secret key for the following
MAC-calculations. |
void |
reset()
Resets the MAC for further use, maintaining the secret key that the MAC
was initialized with. |
void |
update(byte b)
Processes the given byte |
void |
update(byte[] bytes,
int offset,
int len)
Processes the given number of bytes, supplied in a byte array starting at
the given position. |
| Methods inherited from class javax.crypto.MacSpi |
clone |
| Methods inherited from class java.lang.Object |
, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TwoTrackMac
protected TwoTrackMac(int len)
- Creates a new TTMac with the specified MAC length.
- Parameters:
len - the bitlength of the MAC. Possible lengths are 32, 64, 96, 128
and 160.
getMacLength
public int getMacLength()
- Returns the length of the MAC in Bytes.
- Overrides:
getMacLength in class Mac
- Returns:
- the length of the MAC.
init
public void init(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidKeyException
- Initializes the Object with the given secret key for the following
MAC-calculations.
- Overrides:
init in class Mac
- Parameters:
key - the secret key with which this MAC object is initialized..params - the parameters are not used.- Throws:
InvalidKeyException - if the key size is invalid.
update
public void update(byte b)
- Processes the given byte
- Overrides:
update in class Mac
- Parameters:
b - the byte to be processed.
update
public void update(byte[] bytes,
int offset,
int len)
- Processes the given number of bytes, supplied in a byte array starting at
the given position.
- Overrides:
update in class Mac
- Parameters:
bytes - byte array containing the message to be processedoffset - offset into the array to start fromlen - number of bytes to be processed.
doFinal
public byte[] doFinal()
- Returns the calculated MAC value. After the MAC finally has been
calculated, the MAC object is reset for further MAC computations.
- Overrides:
doFinal in class Mac
- Returns:
- the calculated MAC value.
reset
public void reset()
- Resets the MAC for further use, maintaining the secret key that the MAC
was initialized with.
- Overrides:
reset in class Mac