Package org.mozilla.jss.pkcs11
Class PK11MessageDigest
java.lang.Object
org.mozilla.jss.crypto.JSSMessageDigest
org.mozilla.jss.pkcs11.PK11MessageDigest
- All Implemented Interfaces:
AutoCloseable
Message Digesting with PKCS #11.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DigestAlgorithmprivate CipherContextProxyprivate PK11SymKeyprivate PK11Token -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intdigest(byte[] outbuf, int offset, int len) Completes digesting, storing the result into the provided array.private static intdigest(CipherContextProxy proxy, byte[] outbuf, int offset, int len) voidfinalize()private static CipherContextProxyvoidinitHMAC(SymmetricKey key) Initializes an HMAC digest with the given symmetric key.private static CipherContextProxyinitHMAC(PK11Token token, DigestAlgorithm alg, PK11SymKey key) voidreset()Resets this digest for further use.voidupdate(byte[] input, int offset, int len) Updates the digest with a portion of an array.private static voidupdate(CipherContextProxy proxy, byte[] inbuf, int offset, int len) Methods inherited from class org.mozilla.jss.crypto.JSSMessageDigest
digest, digest, getOutputSize, update, update
-
Field Details
-
token
-
digestProxy
-
hmacKey
-
alg
-
-
Constructor Details
-
PK11MessageDigest
PK11MessageDigest(PK11Token token, DigestAlgorithm alg) throws NoSuchAlgorithmException, DigestException
-
-
Method Details
-
initHMAC
Description copied from class:JSSMessageDigestInitializes an HMAC digest with the given symmetric key. This also has the effect of resetting the digest.- Specified by:
initHMACin classJSSMessageDigest- Parameters:
key- Symmetric key.- Throws:
DigestException- If this algorithm is not an HMAC algorithm.InvalidKeyException- If the given key is not valid.
-
update
Description copied from class:JSSMessageDigestUpdates the digest with a portion of an array.- Specified by:
updatein classJSSMessageDigest- 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.
-
digest
Description copied from class:JSSMessageDigestCompletes digesting, storing the result into the provided array.- Specified by:
digestin classJSSMessageDigest- Parameters:
outbuf- 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.
-
reset
Description copied from class:JSSMessageDigestResets this digest for further use. This clears all input and output streams. If this is an HMAC digest, the HMAC key is not cleared.- Specified by:
resetin classJSSMessageDigest- Throws:
DigestException- If an error occurred.
-
getAlgorithm
- Specified by:
getAlgorithmin classJSSMessageDigest- Returns:
- The algorithm that this digest uses.
-
initDigest
- Throws:
DigestException
-
initHMAC
private static CipherContextProxy initHMAC(PK11Token token, DigestAlgorithm alg, PK11SymKey key) throws DigestException - Throws:
DigestException
-
update
-
digest
-
finalize
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-