public abstract class SymmetricCipherMac
extends javax.crypto.MacSpi
Algorithms that provide a way to check the integrity of information based on a secret key are called message authentication codes (MAC). Typically, message authentication codes are used between two parties that share a secret key in order to validate information transmitted between these parties. An DAC is simply a MAC algorithm based on a symmetric cipher. This implementation of the DAC algorithm is designed based on FIPS 113, but modified to operate with any symmetric cipher.
A symmetric cipher algorithm transforms (or encrypts) n-bit input vectors to n-bit output vectors using a cryptographic key, where n indicates the cipher block size. Let D be any n-bit input vector and assume a key has been selected. The n-bit vector, O, which is the output of the symmetric cipher algorithm when applied to D, using the enciphering operation, is represented as follows:
The data (e.g., record, file, message, or program) to be authenticated is grouped into contiguous n-bit blocks: D1, D2,.... Dx. If the number of data bits is not a multiple of n, then the final input block will be a partial block of data, left justified. with zeroes appended to form a full n-bit block. The calculation of the MAC is given by the following equations:
The MAC is selected from Ox. By using the appropriate algorithm parameters, the leftmost M bits of Ox can be selected as as the MAC, where 16 < M < 64 and M is a multiple of 8.
The Cipher Block Chaining Mode (CBC) with Initialization Vector (IV) = 0 and the n-bit Cipher Feedback Mode with IV = D1 and data equal to D2, D3, ..., Dn (see FIPS PUB 81) both yield the required MAC calculation. This implementation uses the CBC mode for the underlying symmetric cipher.
An DAC algorithm instance can be obtained using the Java Cryptography
Architecture (JCA), by requesting the '<algorithm>' MAC from the
Entrust cryptographic
service provider. This can be done using the following call:
Mac.getInstance("<algorithm>", "Entrust");
The following key types are currently supported:
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
engineDoFinal()
Completes the MAC computation and resets the MAC for further use,
maintaining the secret key that the MAC was initialized with.
|
protected int |
engineGetMacLength()
Returns the length of the MAC in bytes.
|
protected void |
engineInit(java.security.Key key,
java.security.spec.AlgorithmParameterSpec params)
Initializes the MAC with the given (secret) key and algorithm parameters.
|
protected void |
engineReset()
Resets the MAC for further use, maintaining the secret key that the MAC
was initialized with.
|
protected void |
engineUpdate(byte input)
Processes the given byte.
|
protected void |
engineUpdate(byte[] input,
int offset,
int len)
Processes the first
len bytes in input,
starting at offset inclusive. |
protected final int engineGetMacLength()
engineGetMacLength in class javax.crypto.MacSpiFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected final void engineInit(java.security.Key key,
java.security.spec.AlgorithmParameterSpec params)
throws java.security.InvalidKeyException,
java.security.InvalidAlgorithmParameterException
engineInit in class javax.crypto.MacSpikey - [FIPS 140-2 data input] [FIPS 140-2 CSP] the (secret) key.params - [FIPS 140-2 data input] the algorithm parameters.java.security.InvalidKeyException - [FIPS 140-2 status output] if the given key is
inappropriate for initializing this MAC.java.security.InvalidAlgorithmParameterException - [FIPS 140-2 status output] if the given algorithm
parameters are inappropriate for this MAC.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected final void engineUpdate(byte input)
engineUpdate in class javax.crypto.MacSpiinput - [FIPS 140-2 data input] the input byte to be processed.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected final void engineUpdate(byte[] input,
int offset,
int len)
len bytes in input,
starting at offset inclusive.
engineUpdate in class javax.crypto.MacSpiinput - [FIPS 140-2 data input] the input buffer.offset - [FIPS 140-2 data input] the offset in input where
the input starts.len - [FIPS 140-2 data input] the number of bytes to process.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected final byte[] engineDoFinal()
engineDoFinal in class javax.crypto.MacSpiFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected final void engineReset()
engineReset in class javax.crypto.MacSpiFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operations