KEYFLAGS=257 HASHALG=2 # For dnssec-dsfromkey ROOTFILES=root-anchors.asc root-anchors.xml all: root-anchors.txt root-anchors.dnskey root-anchors.txt: root-anchors.xml xsltproc -o root-anchors.txt anchors2ds.xsl root-anchors.xml root-anchors.xml: @rm -f ${ROOTFILES} wget -nc -O root-anchors.xml https://data.iana.org/root-anchors/root-anchors.xml wget -nc -O root-anchors.asc https://data.iana.org/root-anchors/root-anchors.asc gpg --verify root-anchors.asc root-anchors.xml || \ rm -f ${ROOTFILES} root-anchors.dnskey: root-anchors.txt dig +nomultiline DNSKEY . | grep -w ${KEYFLAGS} > untrusted.key # Verify the key # Thanks to Kazunori Fujiwara for the idea dnssec-dsfromkey -${HASHALG} untrusted.key > untrusted.ds cut -d' ' -f1-6 untrusted.ds | tr '\n' ' ' > root-anchors.tmp cut -d' ' -f7- untrusted.ds | sed 's/ //g' | tr '\n' ' ' >> root-anchors.tmp echo >> root-anchors.tmp @diff root-anchors.txt root-anchors.tmp || \ sh -c 'echo "Invalid DNSKEY, deleting temporary files"; rm -f root-anchors.tmp untrusted.key untrusted.ds' awk '{print $$1 " " $$5 " " $$6 " " $$7 " " "\""; for (i = 8; i <= NF; i++) printf $$i " "; print "\";" }' untrusted.key > root-anchors.dnskey @echo "OK, root-anchors.dnskey is correct" clean: rm -f root-anchors.txt untrusted.key untrusted.ds root-anchors.tmp realclean: clean rm -f ${ROOTFILES} root-anchors.dnskey