|
For the latest news and information visit The GNU Crypto project |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object gnu.crypto.mac.BaseMac
A base abstract class to facilitate MAC (Message Authentication Code) implementations.
Field Summary | |
protected java.lang.String |
name
The canonical name prefix of the MAC. |
protected int |
truncatedSize
The length of the truncated output in bytes. |
protected IMessageDigest |
underlyingHash
Reference to the underlying hash algorithm instance. |
Fields inherited from interface gnu.crypto.mac.IMac |
MAC_KEY_MATERIAL, TRUNCATED_SIZE |
Constructor Summary | |
protected |
BaseMac(java.lang.String name)
Trivial constructor for use by concrete subclasses. |
protected |
BaseMac(java.lang.String name,
IMessageDigest underlyingHash)
Trivial constructor for use by concrete subclasses. |
Method Summary | |
abstract java.lang.Object |
clone()
Returns a clone copy of this instance. |
abstract byte[] |
digest()
Completes the MAC by performing final operations such as padding and resetting the instance. |
abstract void |
init(java.util.Map attributes)
Initialises the algorithm with designated attributes. |
int |
macSize()
Returns the output length in bytes of this MAC algorithm. |
java.lang.String |
name()
Returns the canonical name of this algorithm. |
void |
reset()
Resets the algorithm instance for re-initialisation and use with other characteristics. |
abstract boolean |
selfTest()
A basic test. |
void |
update(byte b)
Continues a MAC operation using the input byte. |
void |
update(byte[] b,
int offset,
int len)
Continues a MAC operation, by filling the buffer, processing data in the algorithm's MAC_SIZE-bit block(s), updating the context and count, and buffering the remaining bytes in buffer for the next operation. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String name
protected IMessageDigest underlyingHash
protected int truncatedSize
Constructor Detail |
protected BaseMac(java.lang.String name)
Trivial constructor for use by concrete subclasses.
name
- the canonical name of this instance.protected BaseMac(java.lang.String name, IMessageDigest underlyingHash)
Trivial constructor for use by concrete subclasses.
name
- the canonical name of this instance.underlyingHash
- the underlying message digest algorithm instance.Method Detail |
public java.lang.String name()
IMac
Returns the canonical name of this algorithm.
name
in interface IMac
public int macSize()
IMac
Returns the output length in bytes of this MAC algorithm.
macSize
in interface IMac
public void update(byte b)
IMac
Continues a MAC operation using the input byte.
update
in interface IMac
b
- the input byte to digest.public void update(byte[] b, int offset, int len)
IMac
Continues a MAC operation, by filling the buffer, processing data in the algorithm's MAC_SIZE-bit block(s), updating the context and count, and buffering the remaining bytes in buffer for the next operation.
update
in interface IMac
b
- the input block.offset
- start of meaningful bytes in input block.len
- number of bytes, in input block, to consider.public void reset()
IMac
Resets the algorithm instance for re-initialisation and use with other characteristics. This method always succeeds.
reset
in interface IMac
public abstract java.lang.Object clone()
IMac
Returns a clone copy of this instance.
clone
in interface IMac
public abstract void init(java.util.Map attributes) throws java.security.InvalidKeyException, java.lang.IllegalStateException
IMac
Initialises the algorithm with designated attributes. Permissible names and values are described in the class documentation above.
init
in interface IMac
attributes
- a set of name-value pairs that describe the desired
future instance behaviour.
java.security.InvalidKeyException
- if the key data is invalid.
java.lang.IllegalStateException
- if the instance is already initialised.IMac.MAC_KEY_MATERIAL
public abstract byte[] digest()
IMac
Completes the MAC by performing final operations such as padding and resetting the instance.
digest
in interface IMac
public abstract boolean selfTest()
IMac
A basic test. Ensures that the MAC of a pre-determined message is equal to a known pre-computed value.
selfTest
in interface IMac
true
if the implementation passes a basic self-test.
Returns false
otherwise.
|
For the latest news and information visit The GNU Crypto project |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |