|
For the latest news and information visit The GNU Crypto project |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | 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 |
|
| 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()
IMessageDigestReturns the canonical name of this algorithm.
name in interface IMessageDigestgnu.crypto.hash.IMessageDigestpublic int hashSize()
IMessageDigestReturns the output length in bytes of this message digest algorithm.
hashSize in interface IMessageDigestgnu.crypto.hash.IMessageDigestpublic int blockSize()
IMessageDigestReturns the algorithm's (inner) block size in bytes.
blockSize in interface IMessageDigestgnu.crypto.hash.IMessageDigestpublic void update(byte b)
IMessageDigestContinues a message digest operation using the input byte.
update in interface IMessageDigestgnu.crypto.hash.IMessageDigestb - the input byte to digest.
public void update(byte[] b,
int offset,
int len)
IMessageDigestContinues 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 IMessageDigestgnu.crypto.hash.IMessageDigestin - the input block.offset - start of meaningful bytes in input block.length - number of bytes, in input block, to consider.public byte[] digest()
IMessageDigestCompletes the message digest by performing final operations such as padding and resetting the instance.
digest in interface IMessageDigestgnu.crypto.hash.IMessageDigestpublic void reset()
IMessageDigestResets the current context of this instance clearing any eventually cached intermediary values.
reset in interface IMessageDigestpublic abstract java.lang.Object clone()
IMessageDigestReturns a clone copy of this instance.
clone in interface IMessageDigestclone in class java.lang.Objectgnu.crypto.hash.IMessageDigestpublic abstract boolean selfTest()
IMessageDigestA basic test. Ensures that the digest of a pre-determined message is equal to a known pre-computed value.
selfTest in interface IMessageDigestgnu.crypto.hash.IMessageDigestprotected 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: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||