org.mozilla.jss.crypto
Class JSSMessageDigest
java.lang.Object
org.mozilla.jss.crypto.JSSMessageDigest
public abstract class JSSMessageDigest
extends java.lang.Object
A class for performing message digesting (hashing) and MAC operations.
byte[] | digest() - Completes digestion.
|
byte[] | digest(byte[] input) - Provides final data to the digest, then completes it and returns the
output.
|
int | digest(byte[] buf, int offset, int len) - Completes digesting, storing the result into the provided array.
|
DigestAlgorithm | getAlgorithm() - Returns the algorithm that this digest uses.
|
int | getOutputSize() - Returns the length of the digest created by this digest's
digest algorithm.
|
void | initHMAC(SymmetricKey key) - Initializes an HMAC digest with the given symmetric key.
|
void | reset() - Resets this digest for further use.
|
void | update(byte input) - Updates the digest with a single byte of input.
|
void | update(byte[] input) - Updates the digest with an array.
|
void | update(byte[] input, int offset, int len) - Updates the digest with a portion of an array.
|
digest
public byte[] digest()
throws DigestException
Completes digestion.
- The, ahem, output of the digest operation.
digest
public byte[] digest(byte[] input)
throws DigestException
Provides final data to the digest, then completes it and returns the
output.
input
- The digest's last meal.
- The completed digest.
digest
public int digest(byte[] buf,
int offset,
int len)
throws DigestException
Completes digesting, storing the result into the provided array.
buf
- The buffer in which to place the digest output.offset
- The offset in the buffer at which to store the output.len
- The amount of space available in the buffer for the
digest output.
- The number of bytes actually stored into buf.
getAlgorithm
public DigestAlgorithm getAlgorithm()
Returns the algorithm that this digest uses.
getOutputSize
public int getOutputSize()
Returns the length of the digest created by this digest's
digest algorithm.
- The size in bytes of the output of this digest.
initHMAC
public void initHMAC(SymmetricKey key)
throws DigestException,
InvalidKeyException
Initializes an HMAC digest with the given symmetric key. This also
has the effect of resetting the digest.
reset
public void reset()
throws DigestException
Resets this digest for further use. This clears all input and
output streams. If this is an HMAC digest, the HMAC key is not
cleared.
update
public void update(byte input)
throws DigestException
Updates the digest with a single byte of input.
update
public void update(byte[] input)
throws DigestException
Updates the digest with an array.
input
- An array to feed to the digest.
update
public void update(byte[] input,
int offset,
int len)
throws DigestException
Updates the digest with a portion of an array.
input
- An array from which to update the digest.offset
- The index in the array at which to start digesting.len
- The number of bytes to digest.