|
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.hash.BaseHash
A base abstract class to facilitate hash implementations.
Field Summary | |
protected int |
blockSize
The hash (inner) block size in bytes. |
protected byte[] |
buffer
Temporary input buffer. |
protected long |
count
Number of bytes processed so far. |
protected int |
hashSize
The hash (output) size in bytes. |
protected java.lang.String |
name
The canonical name prefix of the hash. |
Constructor Summary | |
protected |
BaseHash(java.lang.String name,
int hashSize,
int blockSize)
Trivial constructor for use by concrete subclasses. |
Method Summary | |
int |
blockSize()
Returns the algorithm's (inner) block size in bytes. |
abstract java.lang.Object |
clone()
Returns a clone copy of this instance. |
byte[] |
digest()
Completes the message digest by performing final operations such as padding and resetting the instance. |
protected abstract byte[] |
getResult()
Constructs the result from the contents of the current context. |
int |
hashSize()
Returns the output length in bytes of this message digest algorithm. |
java.lang.String |
name()
Returns the canonical name of this algorithm. |
protected abstract byte[] |
padBuffer()
Returns the byte array to use as padding before completing a hash operation. |
void |
reset()
Resets the current context of this instance clearing any eventually cached intermediary values. |
protected abstract void |
resetContext()
Resets the instance for future re-use. |
abstract boolean |
selfTest()
A basic test. |
protected abstract void |
transform(byte[] in,
int offset)
The block digest transformation per se. |
void |
update(byte b)
Continues a message digest operation using the input byte. |
void |
update(byte[] b,
int offset,
int len)
Continues a message digest operation, by filling the buffer, processing data in the algorithm's HASH_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 int hashSize
protected int blockSize
protected long count
protected byte[] buffer
Constructor Detail |
protected BaseHash(java.lang.String name, int hashSize, int blockSize)
Trivial constructor for use by concrete subclasses.
name
- the canonical name prefix of this instance.hashSize
- the block size of the output in bytes.blockSize
- the block size of the internal transform.Method Detail |
public java.lang.String name()
IMessageDigest
Returns the canonical name of this algorithm.
name
in interface IMessageDigest
public int hashSize()
IMessageDigest
Returns the output length in bytes of this message digest algorithm.
hashSize
in interface IMessageDigest
public int blockSize()
IMessageDigest
Returns the algorithm's (inner) block size in bytes.
blockSize
in interface IMessageDigest
public void update(byte b)
IMessageDigest
Continues a message digest operation using the input byte.
update
in interface IMessageDigest
b
- the input byte to digest.public void update(byte[] b, int offset, int len)
IMessageDigest
Continues a message digest operation, by filling the buffer, processing data in the algorithm's HASH_SIZE-bit block(s), updating the context and count, and buffering the remaining bytes in buffer for the next operation.
update
in interface IMessageDigest
b
- the input block.offset
- start of meaningful bytes in input block.len
- number of bytes, in input block, to consider.public byte[] digest()
IMessageDigest
Completes the message digest by performing final operations such as padding and resetting the instance.
digest
in interface IMessageDigest
public void reset()
IMessageDigest
Resets the current context of this instance clearing any eventually cached intermediary values.
reset
in interface IMessageDigest
public abstract java.lang.Object clone()
IMessageDigest
Returns a clone copy of this instance.
clone
in interface IMessageDigest
public abstract boolean selfTest()
IMessageDigest
A basic test. Ensures that the digest of a pre-determined message is equal to a known pre-computed value.
selfTest
in interface IMessageDigest
protected abstract byte[] padBuffer()
Returns the byte array to use as padding before completing a hash operation.
protected abstract byte[] getResult()
Constructs the result from the contents of the current context.
protected abstract void resetContext()
protected abstract void transform(byte[] in, int offset)
The block digest transformation per se.
in
- the blockSize long block, as an array of bytes to digest.offset
- the index where the data to digest is located within the
input buffer.
|
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 |