Subject: [dane] Announcing the alpha release of swede - A tool to create and verify TLSA records

From: Pieter Lexis <[email-masked]>
Date: Tue, 24 Jan 2012 13:30:32 +0100

Hi All,

I am doing a small academic project on the DANE specification to see it
is implementable in its current form (apart from issue 37 and 28
currently being discussed, yes). For this I created a tool that can
create all 18 permutations of TLSA records and can verify TLSA records
from DNS with the certificate(-chain) received from the SSL-service.

I have all permutations running on dane.kiev.studlab.os3.nl on ports
1500 through 1517 (tcp), using https.

I've also used the tool to successfully[0] verify records mentioned in [1].

It has limitations, which are mentioned in the README file.

The code is available on github[2] and as a tarball[3]. Please test it,
review the code and comment on it and send me patches or pull-requests
if you fix a bug.

I hope this tool will be helpful for the WG. In addition, I wonder if it
is a good idea to generate 18 test vectors for inclusion in the RFC?.
'swede' might be helpful in this respect

Regards,

Pieter Lexis

0 - http://pastie.org/3243017
1 - http://www.ietf.org/mail-archive/web/dane/current/msg04080.html
2 - https://github.com/pieterlexis/swede
3 - https://github.com/pieterlexis/swede/tarball/master

---

From: Scott Schmit <[email-masked]>
Date: Tue, 24 Jan 2012 08:22:40 -0500

> 'swede' might be helpful in this respect

Equally important are test vectors demonstrating validation failure and
going through multiple records on a given host (some of which pass and
some of which fail).

Nevertheless, good stuff! I've been meaning to do the same, but haven't
gotten around to it myself (other than to generate records).

-- 
Scott Schmit

---

From: Paul Wouters <[email-masked]>
Date: Tue, 24 Jan 2012 08:37:36 -0500 (EST)

> 1500 through 1517 (tcp), using https.

How do i specify type usage? The usage did not tell me. It seems to
generate the same RRdata otherwise (though we could have it both wrong
:)

Paul

---

From: Pieter Lexis <[email-masked]>
Date: Tue, 24 Jan 2012 14:53:14 +0100

> going through multiple records on a given host (some of which pass and

swede iterates over the TLSA records recieved and checks each of them.
Try swede verify -p 1518 dane.kiev.practicum.os3.nl

It returns a usage 0 and usage 1 RR. I also have created TXT records
with some info in them.

Cheers,

Pieter

---

From: Pieter Lexis <[email-masked]>
Date: Tue, 24 Jan 2012 14:54:26 +0100

Hi,

(now for the on-list reply)

> generate the same RRdata otherwise (though we could have it both wrong

swede create -h should show the options.

- ---
swede create -u {0,1,2}
- ---

Cheers,

Pieter

---

From: Jerry Lundström <[email-masked]>
Date: Tue, 24 Jan 2012 15:44:20 +0100

Hi,

On Jan 24, 2012, at 13:30 , Pieter Lexis wrote:

> 'swede'

I must ask, why the name? :)

--
Jerry Lundström - Software Engineer
.SE - The Internet Infrastructure Foundation
http://www.iis.se/

---

From: [email-masked]
Date: Tue, 24 Jan 2012 14:47:02 +0000

> I must ask, why the name? :)

At a guess:

Dane  - Danish
Swede - Swedish

-- 
Mike Cardwell  https://grepular.com/     http://cardwellit.com/
OpenPGP Key    35BC AF1D 3AA2 1F84 3DC3  B0CF 70A5 F512 0018 461F
XMPP OTR Key   8924 B06A 7917 AAF3 DBB1  BF1B 295C 3C78 3EF1 46B4

---

From: Pieter Lexis <[email-masked]>
Date: Tue, 24 Jan 2012 16:08:16 +0100

>> I must ask, why the name? :)

And 'dane' already was a tool in the SSHFP package.

---

From: James Cloos <[email-masked]>
Date: Tue, 24 Jan 2012 10:01:48 -0500

I was unable to use swede on my workstation because it started every
lookup at . and must have timed out before drilling down to the TLSA
and A/AAAA RRs.

I added this to take advantage of the local (unbound) cache:

>From a7e5728b624ab414d003cef169c1c107239733f2 Mon Sep 17 00:00:00 2001
From: James Cloos <[email-masked]>
Date: Tue, 24 Jan 2012 09:40:25 -0500
Subject: [PATCH] Use the local dns cache

Without this, swede is unable to drill down from the . IN NS lookup
to the final TLSA and A/AAAA lookup(s) before libunbound times out.

Signed-off-by: James Cloos <[email-masked]>
---
 swede |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/swede b/swede
index 643c079..5390427 100755
--- a/swede
+++ b/swede
@@ -111,6 +111,7 @@ def getRecords(hostname, rrtype='A', secure=True):
 	"""Do a lookup of a name and a rrtype, returns a list of binary coded strings. Only queries for rr_class IN."""
 	ctx = unbound.ub_ctx()
 	ctx.add_ta_file('root.key')
+	ctx.resolvconf("/etc/resolv.conf")
 
 	if type(rrtype) == str:
 		if 'RR_TYPE_' + rrtype in dir(unbound):
-- 
1.7.8.3

and it started working.

I haven't tested this with non-unbound resolvers in the resolv.conf, but
unbound itself works when using non-verifying foward-hosts so it ought
to be OK.

Also, this:

:; for p in $(seq 00 17);do dig @localhost +tcp +short +dnssec _15${p}._tcp.dane.kiev.studlab.os3.nl TYPE65468; done

generates NXDOMAIN for all of those ports.  Are those meant for create
instead of verify?)

-JimC
-- 
James Cloos <[email-masked]>         OpenPGP: 1024D/ED7DAEA6

---

From: Pieter Lexis <[email-masked]>
Date: Tue, 24 Jan 2012 16:37:06 +0100

On 01/24/2012 04:01 PM, James Cloos wrote:
> I added this to take advantage of the local (unbound) cache: I 
> haven't tested this with non-unbound resolvers in the resolv.conf, 
> but unbound itself works when using non-verifying foward-hosts so it

Thanks! I'll put it in, the reason I didn't was that (as far as I could
see) relied on the AD bit being set in the response.

As the resolving also worked when I turned off the local resolver didn't
load a resolv.conf.

> ought to be OK. :; for p in $(seq 00 17);do dig @localhost +tcp 
> +short +dnssec _15${p}._tcp.dane.kiev.studlab.os3.nl TYPE65468; done

I made a dump typo I make all the time, it's dane.kiev.practicum.os3.nl
using that hostname you can verify (studlab is a subdomain for the
machines, not to test stuff):

dig +tcp +short +dnssec _1516._tcp.dane.kiev.practicum.os3.nl TYPE65468
\# 35 000101DF2D479AC580EEAAACF26940DB1F5D85BD979868F3C89653AC
460C9061551CCE

If any one can tell me conclusively about the unbound thing, I'll amend
the code, for now I'll make it optional.

- --
Pieter Lexis

---

From: Pieter Lexis <[email-masked]>
Date: Tue, 24 Jan 2012 17:06:34 +0100

> I added this to take advantage of the local (unbound) cache:

Added it as an option[0], thanks!

0 -
https://github.com/pieterlexis/swede/commit/09009d50eff972daf8b995f5d21d8a65a71880d9

---

From: Warren Kumari <[email-masked]>
Date: Wed, 25 Jan 2012 22:05:56 -0500

This is wicked awesome, thank you very very much for doing this…

When running 'verify' on a domain that didn't have a DANE record it would die with an uncaught exception. This looked a little ugly, so here is a tiny patch to throw an exception in getRecords() (in case you want to handle it differently elsewhere) and then catch it in getTLSA().

Again, thank you!

W

--------
wkumari@scratch-monkey:~/tmp/pieterlexis-swede-09009d5$ diff -rua swede.orig  swede
--- swede.orig	2012-01-26 02:36:46.108174855 +0000
+++ swede	2012-01-26 02:58:34.798175146 +0000
@@ -24,6 +24,11 @@
 from hashlib import sha256, sha512
 from ipaddr import IPv4Address, IPv6Address
 
+
+class LookupError(Exception):
+  """DNS Lookup Error."""
+
+
 def genTLSA(hostname, protocol, port, certificate, output='draft', usage=1, selector=0, mtype=1):
 	"""This function generates a TLSARecord object using the data passed in the parameters,
 	it then validates the record and returns the RR as a string.
@@ -135,7 +140,7 @@
 		# If we are here the data was either secure or insecure data is accepted
 		return result.data.raw
 	else:
-		raise Exception('Error: Unsuccesful lookup or no data returned.')
+		raise LookupError('Unsuccesful lookup or no data returned for rrtype %s.' % rrtype)
 
 def getHash(certificate, mtype):
 	"""Hashes the certificate based on the mtype.
@@ -170,6 +175,9 @@
 	except InsecureLookupException, e:
 		print str(e)
 		sys.exit(1)
+	except LookupError, e:
+		print 'Unable to resolve %s: %s' % (hostname, str(e))
+		sys.exit(1)
 	ret = []
 	for record in records:
 		hexdata = b2a_hex(record)
wkumari@scratch-monkey:~/tmp/pieterlexis-swede-09009d5$ 

-----------

On Jan 24, 2012, at 7:30 AM, Pieter Lexis wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi All,
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iQIcBAEBAgAGBQJPHqRlAAoJELPqGO5ebd4jsTIP+wZYurzeJoOFPhoMu/a/q1PR
> QNA09YYsCkuAc0cWloT+iZPppHrK0r/FlXbto2Dc4GSQwEv7INcEKv5ltLjqWJjl
> D7gLv+caIDw7M2cysPG3HIMaz+hRXHaerEtg+owoWleihE2lehgcTHPVPAXS78Sc
> iGg+9d775s4ISDFgSD8I9EJorj0gDCrvYAmQsi7ukl0GbM/ISJGMASVm1rE6WJ6A
> nvQeTqjAvvIba2Jse7ybH8xFjYkb8Ujk27RJP67ZlpTx4Bx8GdSXFDPCBHvBrlBW
> 8HqqCO8F4WWDpjxpcTv89c1CvmTyzE0ryfjh3OMbQj70FXE2ficVGbV46IvVTP5R
> CcfIpezr4u2PUkdbYFjlknjBA5rpV8CqXWDoTc8Eczn43VvOp2cF4ZlquPjQvQmZ
> gqu0FgXsN2ljHvGbxroXG/h7E9Uoe31+2Oyg/oY41h5c4JQlKDC6SaDzjHhOmFmT
> XHbKP+DuFoEV5Kpf9ZIeEwVTI++XKFHDU5iRDWbMv2WjA29p6oh5INZ5FP2lNx+e
> EshjxZVCeQuowHUXsCmS1mPsOEoPWZyV61ryUwQoLVHnozJfOy4AxbeWabtyPGud
> C06hSqZRpjVSKGIElimhG+ToVzPhJFwQuItn3+efruahe8NEhsbut45xk5Yi4EE0
> TX6onFLovK6N79BpSvdi
> =okS7
> -----END PGP SIGNATURE-----
> _______________________________________________
> dane mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/dane
> 

--
Don't be impressed with unintelligible stuff said condescendingly.
    -- Radia Perlman.

---

From: Warren Kumari <[email-masked]>
Date: Wed, 25 Jan 2012 22:07:07 -0500

And I meant to send this offlist… Oh well…

W