On Mon, Mar 26, 2007 at 05:12:25PM -0400, Jeremy Kister wrote:
> I've found RFC2535 section 3 which talks about the KEY RR and declares
> it type number 25. Unfortunately i'm confused how to finesse the four
> fields (16896, 4, 1, AQOR...) into the rdata for tinydns.
The format is in section 3.1; you just have to concatenate all of the
parts together (the flags are 16-bit big-endian, protocol and algorithm
are a byte each, and then the rest is a binary blob). The dump you
provided has the blob base64-encoded; tinydns-data expects octal
escapes.
> Can someone convert this into a tinydns generic syntax for me, while,
> more importantly, explaining it along the way?
The perl script below takes the input you provided in your original mail
and creates a tinydns KEY record. Publishing it with tinydns and using
querying with dig returns the original. Beyond that, I didn't test it at
all, so use with caution.
-Peff
-- >8 --
#!/usr/bin/perl
use MIME::Base64;
undef $/;
local $_ = <STDIN>;
my ($name, $ttl, $flags, $protocol, $algorithm, $blob) =
/(\S+)\s+
(\d+)\s+
IN\s+
KEY\s+
(\d+)\s+
(\d+)\s+
(\d+)\s+
(.*)
/xs;
$blob = decode_base64($blob)
or die "unable to decode blob\n";
my $rdata = pack('nCCa*', $flags, $protocol, $algorithm, $blob);
$rdata =~ s/[^A-Za-z0-9]/sprintf '\%03o', ord($&)/ge;
print ":$name:25:$rdata:$ttl",
|