|
From: Tekto <te...@ge...> - 2013-07-26 17:14:00
|
Hi,
-- Description --
SIG0.signMessage in Version 2.1.5 is calculating a wrong signature. Sending
following update-request to a server will produce a SERVFAIL:
SimpleResolver resolver = new SimpleResolver("somedns.example.invalid.");
Name sig0zoneName = new Name("sig0.invalid.");
Name sig0hostName = new Name("sometext.sig0.invalid.");
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
RSAPrivateKey privKey = getPrivateZoneCrtKey(keyFactory);
RSAPublicKey pubKey = getPublicZoneKey(keyFactory);
KEYRecord keyRecord = new KEYRecord(sig0zoneName, DClass.IN, 0, Flags.HOST, Protocol.DNSSEC, Algorithm.RSASHA1, pubKey);
TXTRecord txtRecord = new TXTRecord(sig0hostName, DClass.IN, 0, "Hello World!");
Update updateMessage = new Update(sig0zoneName);
updateMessage.add(txtRecord);
SIG0.signMessage(updateMessage, keyRecord, privKey, null);
-- How to reproduce --
Use SIG0.verifyMessage and try to verify updateMessage.toWire() which will
throw a DNSSEC.DNSSECException.
SIG0.verifyMessage(updateMessage, updateMessage.toWire(), keyRecord, null);
-- Reason --
in DNSSEC.java signMessage(Message message, SIGRecord previous, KEYRecord key,
PrivateKey privkey, Date inception, Date expiration)
update message is added to the same DNSOutput-Buffer as the introducing SIG-RDATA.
Therefore name compression calculation in update-section will refer to a wrong
offset (Start of to-sign data block instead of the start of the message will be
truly send over the wire. Verification on the server counterpart will fail.
(tested against BIND 9.7.3)
-- How to fix it --
Changing line 955 (in Version 2.1.5) in DNSSEC.java from
message.toWire(out);
to
out.writeByteArray(message.toWire());
will fix this behaviour since it uses a second, independent DNSOutput-buffer for
calculation.
Regards,
Adam
|