Package org.mozilla.jss.crypto
Class JSSMessageDigest
java.lang.Object
org.mozilla.jss.crypto.JSSMessageDigest
- Direct Known Subclasses:
PK11MessageDigest
A class for performing message digesting (hashing) and MAC operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
digest()
Completes digestion.byte[]
digest
(byte[] input) Provides final data to the digest, then completes it and returns the output.abstract int
digest
(byte[] buf, int offset, int len) Completes digesting, storing the result into the provided array.abstract DigestAlgorithm
int
Returns the length of the digest created by this digest's digest algorithm.abstract void
initHMAC
(SymmetricKey key) Initializes an HMAC digest with the given symmetric key.abstract 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.abstract void
update
(byte[] input, int offset, int len) Updates the digest with a portion of an array.
-
Constructor Details
-
JSSMessageDigest
public JSSMessageDigest()
-
-
Method Details
-
initHMAC
Initializes an HMAC digest with the given symmetric key. This also has the effect of resetting the digest.- Parameters:
key
- Symmetric key.- Throws:
DigestException
- If this algorithm is not an HMAC algorithm.InvalidKeyException
- If the given key is not valid.
-
update
Updates the digest with a single byte of input.- Parameters:
input
- Input byte.- Throws:
DigestException
- If an error occurred.
-
update
Updates the digest with a portion of an array.- Parameters:
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.- Throws:
DigestException
- If an error occurs while digesting.
-
update
Updates the digest with an array.- Parameters:
input
- An array to feed to the digest.- Throws:
DigestException
- If an error occurs while digesting.
-
digest
Completes digestion.- Returns:
- The, ahem, output of the digest operation.
- Throws:
DigestException
- If an error occurs while digesting.
-
digest
Completes digesting, storing the result into the provided array.- Parameters:
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.- Returns:
- The number of bytes actually stored into buf.
- Throws:
DigestException
- If the provided space is too small for the digest, or an error occurs with the digest.
-
digest
Provides final data to the digest, then completes it and returns the output.- Parameters:
input
- The digest's last meal.- Returns:
- The completed digest.
- Throws:
DigestException
- If an error occurs while digesting.
-
reset
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.- Throws:
DigestException
- If an error occurred.
-
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.- Returns:
- The size in bytes of the output of this digest.
-