if (error != Rcode.BADTIME)
timeSigned = new Date();
else
timeSigned = old.getTimeSigned();
int fudge;
HMAC hmac = null;
if (error == Rcode.NOERROR || error == Rcode.BADTIME)
hmac = new HMAC(digest, key);
fudge = Options.intValue("tsigfudge");
if (fudge < 0 || fudge > 0x7FFF)
fudge = FUDGE;
if (old != null) {
DNSOutput out = new DNSOutput();
out.writeU16(old.getSignature().length);
if (hmac != null) {
hmac.update(out.toByteArray());
hmac.update(old.getSignature());
}
}
/* Digest the message */
if (hmac != null)
hmac.update(b);
DNSOutput out = new DNSOutput();
name.toWireCanonical(out);
out.writeU16(DClass.ANY); /* class */
out.writeU32(0); /* ttl */
alg.toWireCanonical(out);
long time = timeSigned.getTime() / 1000;
int timeHigh = (int) (time >> 32);
long timeLow = (time & 0xFFFFFFFFL);
out.writeU16(timeHigh);
out.writeU32(timeLow);
out.writeU16(fudge);
out.writeU16(error);
out.writeU16(0); /* No other data */
if (hmac != null)
hmac.update(out.toByteArray());
byte [] signature;
if (hmac != null)
signature = hmac.sign();
else
signature = new byte[0];
byte [] other = null;
if (error == Rcode.BADTIME) {