|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.crypto.hash.BaseHashStandalone
public abstract class BaseHashStandalone
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 |
BaseHashStandalone(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)
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. |
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 BaseHashStandalone(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()
IMessageDigestStandalone
Returns the canonical name of this algorithm.
name
in interface IMessageDigestStandalone
public int hashSize()
IMessageDigestStandalone
Returns the output length in bytes of this message digest algorithm.
hashSize
in interface IMessageDigestStandalone
public int blockSize()
IMessageDigestStandalone
Returns the algorithm's (inner) block size in bytes.
blockSize
in interface IMessageDigestStandalone
public void update(byte b)
IMessageDigestStandalone
Continues a message digest operation using the input byte.
update
in interface IMessageDigestStandalone
b
- the input byte to digest.public void update(byte[] b)
IMessageDigestStandalone
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 IMessageDigestStandalone
b
- the input block.public void update(byte[] b, int offset, int len)
IMessageDigestStandalone
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 IMessageDigestStandalone
b
- the input block.offset
- start of meaningful bytes in input block.len
- number of bytes, in input block, to consider.public byte[] digest()
IMessageDigestStandalone
Completes the message digest by performing final operations such as padding and resetting the instance.
digest
in interface IMessageDigestStandalone
public void reset()
IMessageDigestStandalone
Resets the current context of this instance clearing any eventually cached intermediary values.
reset
in interface IMessageDigestStandalone
public abstract java.lang.Object clone()
IMessageDigestStandalone
Returns a clone copy of this instance.
clone
in interface IMessageDigestStandalone
clone
in class java.lang.Object
public abstract boolean selfTest()
IMessageDigestStandalone
A basic test. Ensures that the digest of a pre-determined message is equal to a known pre-computed value.
selfTest
in interface IMessageDigestStandalone
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |