org.xbill.DNS.utils
public class HMAC extends java.lang.Object
Constructor and Description |
---|
HMAC(java.security.MessageDigest digest,
byte[] key)
Deprecated.
won't work with digests using a padding length other than 64;
use
HMAC(MessageDigest digest, int blockLength,
byte [] key) instead. |
HMAC(java.security.MessageDigest digest,
int blockLength,
byte[] key)
Creates a new HMAC instance
|
HMAC(java.lang.String digestName,
byte[] key)
Deprecated.
won't work with digests using a padding length other than 64;
use
HMAC(String digestName, int blockLength, byte [] key)
instead |
HMAC(java.lang.String digestName,
int blockLength,
byte[] key)
Creates a new HMAC instance
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Resets the HMAC object for further use
|
int |
digestLength()
Returns the length of the digest.
|
byte[] |
sign()
Signs the data (computes the secure hash)
|
void |
update(byte[] b)
Adds data to the current hash
|
void |
update(byte[] b,
int offset,
int length)
Adds data to the current hash
|
boolean |
verify(byte[] signature)
Verifies the data (computes the secure hash and compares it to the input)
|
boolean |
verify(byte[] signature,
boolean truncation_ok)
Verifies the data (computes the secure hash and compares it to the input)
|
public HMAC(java.security.MessageDigest digest, int blockLength, byte[] key)
digest
- The message digest object.blockLength
- The block length of the message digest.key
- The secret keypublic HMAC(java.lang.String digestName, int blockLength, byte[] key)
digestName
- The name of the message digest function.blockLength
- The block length of the message digest.key
- The secret key.public HMAC(java.security.MessageDigest digest, byte[] key)
HMAC(MessageDigest digest, int blockLength,
byte [] key)
instead.digest
- The message digest object.key
- The secret keyHMAC(MessageDigest digest, int blockLength, byte [] key)
public HMAC(java.lang.String digestName, byte[] key)
HMAC(String digestName, int blockLength, byte [] key)
insteaddigestName
- The name of the message digest function.key
- The secret key.HMAC(String digestName, int blockLength, byte [] key)
public void update(byte[] b, int offset, int length)
b
- The dataoffset
- The index at which to start adding to the hashlength
- The number of bytes to hashpublic void update(byte[] b)
b
- The datapublic byte[] sign()
public boolean verify(byte[] signature)
signature
- The signature to compare againstpublic boolean verify(byte[] signature, boolean truncation_ok)
signature
- The signature to compare againsttruncation_ok
- If true, the signature may be truncated; only the
number of bytes in the provided signature are compared.public void clear()
public int digestLength()