|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--javax.crypto.MacSpi
|
+--de.flexiprovider.api.Mac
This class implements a "message authentication code" (MAC), a method to ensure the integrity of data transmitted between two parties who share a common secret key.
The best way to describe a MAC is as a keyed one-way hash function, which looks like:
D = MAC(K, M)
where K is the key, M is the message, and D is the resulting digest. One party will usually send the concatenation M || D to the other party, who will then verify D by computing D' in a similar fashion. If D == D', then the message is assumed to be authentic.
| Constructor Summary | |
Mac()
|
|
| Method Summary | |
abstract byte[] |
doFinal()
Finishes the computation of a MAC and returns the digest. |
byte[] |
doFinal(byte[] input)
Finishes the computation of a MAC with a final byte array (or computes a MAC over those bytes only) and returns the digest. |
int |
doFinal(byte[] output,
int outOffset)
Finishes the computation of a MAC and places the result into the given array. |
protected byte[] |
engineDoFinal()
|
protected int |
engineGetMacLength()
|
protected void |
engineInit(java.security.Key key,
java.security.spec.AlgorithmParameterSpec params)
|
protected void |
engineReset()
|
protected void |
engineUpdate(byte input)
|
protected void |
engineUpdate(byte[] input,
int offset,
int len)
|
abstract int |
getMacLength()
Return the MAC length. |
void |
init(SecretKey key)
Initialize this MAC with a key and no parameters. |
abstract void |
init(SecretKey key,
AlgorithmParameterSpec params)
Initialize this MAC with a key and parameters. |
abstract void |
reset()
Reset this instance. |
abstract void |
update(byte input)
Update the computation with a single byte. |
void |
update(byte[] input)
Update the computation with a byte array. |
abstract void |
update(byte[] input,
int offset,
int length)
Update the computation with a portion of a byte array. |
| Methods inherited from class javax.crypto.MacSpi |
clone |
| Methods inherited from class java.lang.Object |
|
| Constructor Detail |
public Mac()
| Method Detail |
protected final int engineGetMacLength()
engineGetMacLength in class javax.crypto.MacSpi
protected void engineInit(java.security.Key key,
java.security.spec.AlgorithmParameterSpec params)
throws java.security.InvalidKeyException,
java.security.InvalidAlgorithmParameterException
engineInit in class javax.crypto.MacSpiprotected final void engineUpdate(byte input)
engineUpdate in class javax.crypto.MacSpi
protected final void engineUpdate(byte[] input,
int offset,
int len)
engineUpdate in class javax.crypto.MacSpiprotected final byte[] engineDoFinal()
engineDoFinal in class javax.crypto.MacSpiprotected final void engineReset()
engineReset in class javax.crypto.MacSpipublic abstract int getMacLength()
public final void init(SecretKey key)
throws InvalidKeyException
key - The key to initialize this instance with.InvalidKeyException - If the key is unacceptable.
public abstract void init(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException,
InvalidKeyException
key - The key to initialize this instance with.params - The algorithm-specific parameters.InvalidAlgorithmParameterException - If the algorithm parameters are unacceptable.InvalidKeyException - If the key is unacceptable.public abstract void update(byte input)
input - The next byte.public final void update(byte[] input)
input - The next bytes.
public abstract void update(byte[] input,
int offset,
int length)
input - The next bytes.offset - The index in input to start.length - The number of bytes to update.public abstract byte[] doFinal()
After this method succeeds, it may be used again as just after a call to init, and can compute another MAC using the same key and parameters.
public final byte[] doFinal(byte[] input)
After this method succeeds, it may be used again as just after a call to init, and can compute another MAC using the same key and parameters.
input - The bytes to add.
public final int doFinal(byte[] output,
int outOffset)
throws ShortBufferException
After this method succeeds, it may be used again as just after a call to init, and can compute another MAC using the same key and parameters.
output - The destination for the result.outOffset - The index in the output array to start.ShortBufferException - If output is not large enough to hold the
result.public abstract void reset()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||