Package org.xbill.DNS
Class TSIG
java.lang.Object
org.xbill.DNS.TSIG
Transaction signature handling. This class generates and verifies TSIG records on messages, which
provide transaction security.
- Author:
- Brian Wellington
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA utility class for generating signed message responses.static classA utility class for verifying multiple message responses. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationThe default fudge value for outgoing packets.static final NameThe domain name representing the gss-tsig algorithm.static final NameDeprecated.static final NameThe domain name representing the HMAC-MD5 algorithm.static final NameThe domain name representing the HMAC-SHA1 algorithm.static final NameThe domain name representing the HMAC-SHA224 algorithm.static final NameThe domain name representing the HMAC-SHA256 algorithm.static final NameThe domain name representing the HMAC-SHA384 algorithm.static final NameThe domain name representing the HMAC-SHA512 algorithm. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.UseTSIG(Name, String, String)to explicitly specify an algorithm.Creates a new TSIG object, which can be used to sign or verify a message.Deprecated.Use one of the constructors that specifies an algorithm and key.Deprecated.UseTSIG(Name, Name, SecretKey)to explicitly specify an algorithm.Creates a new TSIG object, which can be used to sign or verify a message.Creates a new TSIG key, which can be used to sign or verify a message.Creates a new TSIG object, which can be used to sign or verify a message.Creates a new TSIG key, which can be used to sign or verify a message.Creates a new TSIG key, which can be used to sign or verify a message. -
Method Summary
Modifier and TypeMethodDescriptionstatic NamealgorithmToName(String alg) Convert an algorithm String to its equivalent Name.voidapply(Message m, int error, TSIGRecord old) Generates a TSIG record with a specific error for a message and adds it to the message.voidapply(Message m, int error, TSIGRecord old, boolean fullSignature) Generates a TSIG record with a specific error for a message and adds it to the message.voidapply(Message m, TSIGRecord old) Generates a TSIG record for a message and adds it to the messagevoidapply(Message m, TSIGRecord old, boolean fullSignature) Generates a TSIG record with a specific error for a message and adds it to the message.voidapplyStream(Message m, TSIGRecord old, boolean fullSignature) Deprecated.static TSIGfromString(String str) Deprecated.Use an explicit constructorgenerate(Message m, byte[] b, int error, TSIGRecord old) Generates a TSIG record with a specific error for a message that has been rendered.generate(Message m, byte[] b, int error, TSIGRecord old, boolean fullSignature) Generates a TSIG record with a specific error for a message that has been rendered.static StringnameToAlgorithm(Name name) Deprecated.Returns java algorithm name, will be made private in 4.0intReturns the maximum length of a TSIG record generated by this key.byteverify(Message m, byte[] b, int length, TSIGRecord old) Deprecated.intverify(Message m, byte[] messageBytes, TSIGRecord requestTSIG) Verifies a TSIG record on an incoming message.intverify(Message m, byte[] messageBytes, TSIGRecord requestTSIG, boolean fullSignature) Verifies a TSIG record on an incoming message.
-
Field Details
-
GSS_TSIG
The domain name representing the gss-tsig algorithm. -
HMAC_MD5
The domain name representing the HMAC-MD5 algorithm. -
HMAC
Deprecated.useHMAC_MD5The domain name representing the HMAC-MD5 algorithm. -
HMAC_SHA1
The domain name representing the HMAC-SHA1 algorithm. -
HMAC_SHA224
The domain name representing the HMAC-SHA224 algorithm. -
HMAC_SHA256
The domain name representing the HMAC-SHA256 algorithm. -
HMAC_SHA384
The domain name representing the HMAC-SHA384 algorithm. -
HMAC_SHA512
The domain name representing the HMAC-SHA512 algorithm. -
FUDGE
The default fudge value for outgoing packets. Can be overridden by the tsigfudge option.
-
-
Constructor Details
-
TSIG
Creates a new TSIG object, which can be used to sign or verify a message.- Parameters:
name- The name of the shared key.key- The shared key's data represented as a base64 encoded string.- Throws:
IllegalArgumentException- The key name is an invalid nameIllegalArgumentException- The key data is improperly encodedNullPointerException- key is null- Since:
- 3.2
-
TSIG
Creates a new TSIG key, which can be used to sign or verify a message.- Parameters:
algorithm- The algorithm of the shared key.name- The name of the shared key.keyBytes- The shared key's data.
-
TSIG
Creates a new TSIG key, which can be used to sign or verify a message.- Parameters:
algorithm- The algorithm of the shared key.name- The name of the shared key.key- The shared key.
-
TSIG
Creates a new TSIG key, which can be used to sign or verify a message.- Parameters:
algorithm- The algorithm of the shared key.name- The name of the shared key.key- The shared key.- Since:
- 3.2
-
TSIG
Deprecated.Use one of the constructors that specifies an algorithm and key.Creates a new TSIG key from a pre-initialized Mac instance. This assumes that init() has already been called on the mac to set up the key.- Parameters:
mac- The JCE HMAC objectname- The name of the key
-
TSIG
Deprecated.UseTSIG(Name, Name, SecretKey)to explicitly specify an algorithm.Creates a new TSIG key with theHMAC_MD5algorithm, which can be used to sign or verify a message.- Parameters:
name- The name of the shared key.key- The shared key's data.
-
TSIG
Creates a new TSIG object, which can be used to sign or verify a message.- Parameters:
name- The name of the shared key.key- The shared key's data represented as a base64 encoded string.- Throws:
IllegalArgumentException- The key name is an invalid nameIllegalArgumentException- The key data is improperly encoded
-
TSIG
Creates a new TSIG object, which can be used to sign or verify a message.- Parameters:
algorithm- The RFC8945 algorithm name of the shared key. The legal values are:- hmac-md5.sig-alg.reg.int.
- hmac-md5. (alias for hmac-md5.sig-alg.reg.int.)
- hmac-sha1.
- hmac-sha224.
- hmac-sha256.
- hmac-sha384.
- hmac-sha512.
name- The name of the shared key.key- The shared key's data represented as a base64 encoded string.- Throws:
IllegalArgumentException- The key name is an invalid nameIllegalArgumentException- The key data is improperly encoded- See Also:
-
TSIG
Deprecated.UseTSIG(Name, String, String)to explicitly specify an algorithm.Creates a new TSIG object with theHMAC_MD5algorithm, which can be used to sign or verify a message.- Parameters:
name- The name of the shared keykey- The shared key's data, represented as a base64 encoded string.- Throws:
IllegalArgumentException- The key name is an invalid nameIllegalArgumentException- The key data is improperly encoded
-
-
Method Details
-
algorithmToName
Convert an algorithm String to its equivalent Name.- Parameters:
alg- String containing name of algorithm.- Returns:
- Name object for algorithm
- Throws:
IllegalArgumentException- The algorithm is null or invalid.
-
nameToAlgorithm
Deprecated.Returns java algorithm name, will be made private in 4.0Convert an algorithm Name to a string.- Parameters:
name- Name object- Returns:
- String equivalent
-
fromString
Deprecated.Use an explicit constructorCreates a new TSIG object, which can be used to sign or verify a message.- Parameters:
str- The TSIG key, in the form name:secret, name/secret, alg:name:secret, or alg/name/secret. If no algorithm is specified, the default ofHMAC_MD5is used.- Throws:
IllegalArgumentException- The string does not contain both a name and secret.IllegalArgumentException- The key name is an invalid nameIllegalArgumentException- The key data is improperly encoded
-
generate
Generates a TSIG record with a specific error for a message that has been rendered.- Parameters:
m- The messageb- The rendered messageerror- The errorold- If this message is a response, the TSIG from the request- Returns:
- The TSIG record to be added to the message
-
generate
Generates a TSIG record with a specific error for a message that has been rendered.- Parameters:
m- The messageb- The rendered messageerror- The errorold- If this message is a response, the TSIG from the requestfullSignature-trueif thisTSIGRecordis the to be added to the first of many messages in a TCP connection and all TSIG variables (rfc2845, 3.4.2.) should be included in the signature.falsefor subsequent messages with reduced TSIG variables set (rfc2845, 4.4.).- Returns:
- The TSIG record to be added to the message
- Since:
- 3.2
-
apply
Generates a TSIG record for a message and adds it to the message- Parameters:
m- The messageold- If this message is a response, the TSIG from the request
-
apply
Generates a TSIG record with a specific error for a message and adds it to the message.- Parameters:
m- The messageerror- The errorold- If this message is a response, the TSIG from the request
-
apply
Generates a TSIG record with a specific error for a message and adds it to the message.- Parameters:
m- The messageold- If this message is a response, the TSIG from the requestfullSignature-trueif this message is the first of many in a TCP connection and all TSIG variables (rfc2845, 3.4.2.) should be included in the signature.falsefor subsequent messages with reduced TSIG variables set (rfc2845, 4.4.).- Since:
- 3.2
-
apply
Generates a TSIG record with a specific error for a message and adds it to the message.- Parameters:
m- The messageerror- The errorold- If this message is a response, the TSIG from the requestfullSignature-trueif this message is the first of many in a TCP connection and all TSIG variables (rfc2845, 3.4.2.) should be included in the signature.falsefor subsequent messages with reduced TSIG variables set (rfc2845, 4.4.).- Since:
- 3.2
-
applyStream
Deprecated.Generates a TSIG record for a message and adds it to the message- Parameters:
m- The messageold- If this message is a response, the TSIG from the requestfullSignature-trueif this message is the first of many in a TCP connection and all TSIG variables (rfc2845, 3.4.2.) should be included in the signature.falsefor subsequent messages with reduced TSIG variables set (rfc2845, 4.4.).
-
verify
Deprecated.Verifies a TSIG record on an incoming message. Since this is only called in the context where a TSIG is expected to be present, it is an error if one is not present. After calling this routine, Message.isVerified() may be called on this message.Use
TSIG.StreamVerifierto validate multiple messages in a stream.- Parameters:
m- The messageb- An array containing the message in unparsed form. This is necessary since TSIG signs the message in wire format, and we can't recreate the exact wire format (with the same name compression).length- unusedold- If this message is a response, the TSIG from the request- Returns:
- The result of the verification (as an Rcode)
- See Also:
-
verify
Verifies a TSIG record on an incoming message. Since this is only called in the context where a TSIG is expected to be present, it is an error if one is not present. After calling this routine, Message.isVerified() may be called on this message.Use
TSIG.StreamVerifierto validate multiple messages in a stream.- Parameters:
m- The message to verifymessageBytes- An array containing the message in unparsed form. This is necessary since TSIG signs the message in wire format, and we can't recreate the exact wire format (with the same name compression).requestTSIG- If this message is a response, the TSIG from the request- Returns:
- The result of the verification (as an Rcode)
- See Also:
-
verify
Verifies a TSIG record on an incoming message. Since this is only called in the context where a TSIG is expected to be present, it is an error if one is not present. After calling this routine, Message.isVerified() may be called on this message.Use
TSIG.StreamVerifierto validate multiple messages in a stream.- Parameters:
m- The message to verifymessageBytes- An array containing the message in unparsed form. This is necessary since TSIG signs the message in wire format, and we can't recreate the exact wire format (with the same name compression).requestTSIG- If this message is a response, the TSIG from the requestfullSignature-trueif this message is the first of many in a TCP connection and all TSIG variables (rfc2845, 3.4.2.) should be included in the signature.falsefor subsequent messages with reduced TSIG variables set (rfc2845, 4.4.).- Returns:
- The result of the verification (as an Rcode)
- Since:
- 3.2
- See Also:
-
recordLength
public int recordLength()Returns the maximum length of a TSIG record generated by this key.- See Also:
-
HMAC_MD5