From: Nils Wisiol Date: Thu, 27 Aug 2020 07:47:02 +0000 (+0200) Subject: Adds SMIMEA record type, RFC 8162 X-Git-Tag: v2.1.0rc1~38^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f19845344b468325d3fc6d3919ccc0869b6ca9d;p=thirdparty%2Fdnspython.git Adds SMIMEA record type, RFC 8162 --- diff --git a/dns/rdatatype.py b/dns/rdatatype.py index a6b5d649..65da6d4e 100644 --- a/dns/rdatatype.py +++ b/dns/rdatatype.py @@ -72,6 +72,7 @@ class RdataType(dns.enum.IntEnum): NSEC3 = 50 NSEC3PARAM = 51 TLSA = 52 + SMIMEA = 53 HIP = 55 NINFO = 56 CDS = 59 @@ -272,6 +273,7 @@ DHCID = RdataType.DHCID NSEC3 = RdataType.NSEC3 NSEC3PARAM = RdataType.NSEC3PARAM TLSA = RdataType.TLSA +SMIMEA = RdataType.SMIMEA HIP = RdataType.HIP NINFO = RdataType.NINFO CDS = RdataType.CDS diff --git a/dns/rdtypes/ANY/SMIMEA.py b/dns/rdtypes/ANY/SMIMEA.py new file mode 100644 index 00000000..3e504893 --- /dev/null +++ b/dns/rdtypes/ANY/SMIMEA.py @@ -0,0 +1,7 @@ +import dns.rdatatype +from dns.rdtypes.ANY.TLSA import TLSA + + +@dns.immutable.immutable +class SMIMEA(TLSA): + """SMIMEA record, same format as TLSA per https://tools.ietf.org/html/rfc8162#section-2""" diff --git a/dns/rdtypes/ANY/__init__.py b/dns/rdtypes/ANY/__init__.py index 0d1a7406..b0ea7077 100644 --- a/dns/rdtypes/ANY/__init__.py +++ b/dns/rdtypes/ANY/__init__.py @@ -48,6 +48,7 @@ __all__ = [ 'RP', 'RRSIG', 'RT', + 'SMIMEA', 'SOA', 'SPF', 'SSHFP', diff --git a/doc/rdata-subclasses.rst b/doc/rdata-subclasses.rst index 347610e2..17a537a3 100644 --- a/doc/rdata-subclasses.rst +++ b/doc/rdata-subclasses.rst @@ -433,6 +433,25 @@ Rdata Subclass Reference A ``dns.name.Name``, the exchange name. +.. autoclass:: dns.rdtypes.ANY.SMIMEA.SMIMEA + :members: + + .. attribute:: usage + + An ``int``, the certificate usage. + + .. attribute:: selector + + An ``int``, the selector. + + .. attribute:: mtype + + An ``int``, the matching type. + + .. attribute:: cert + + A ``bytes``, the certificate association data. + .. autoclass:: dns.rdtypes.ANY.SOA.SOA :members: diff --git a/doc/rdatatype-list.rst b/doc/rdatatype-list.rst index df21370c..ed526111 100644 --- a/doc/rdatatype-list.rst +++ b/doc/rdatatype-list.rst @@ -111,6 +111,8 @@ Rdatatypes :annotation: = 46 .. py:data:: dns.rdatatype.RT :annotation: = 21 +.. py:data:: dns.rdatatype.SMIMEA + :annotation: = 53 .. py:data:: dns.rdatatype.SIG :annotation: = 24 .. py:data:: dns.rdatatype.SOA diff --git a/doc/rfc.rst b/doc/rfc.rst index 257790c9..e5aed950 100644 --- a/doc/rfc.rst +++ b/doc/rfc.rst @@ -141,6 +141,8 @@ PTR `RFC 1035 `_ RRSIG `RFC 4034 `_ +SMIMEA + `RFC 8162 `_ SOA `RFC 1035 `_ SPF diff --git a/tests/example b/tests/example index b0772487..c8c13953 100644 --- a/tests/example +++ b/tests/example @@ -138,6 +138,9 @@ $TTL 3600 ; 1 hour tlsa1 TLSA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 tlsa2 TLSA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 tlsa3 TLSA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 +smimea1 SMIMEA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 +smimea2 SMIMEA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 +smimea3 SMIMEA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 txt01 TXT "foo" txt02 TXT "foo" "bar" txt03 TXT foo diff --git a/tests/example1.good b/tests/example1.good index 4aaea377..8c751c2c 100644 --- a/tests/example1.good +++ b/tests/example1.good @@ -108,6 +108,9 @@ rt01 3600 IN RT 0 intermediate-host rt02 3600 IN RT 65535 . s 300 IN NS ns.s ns.s 300 IN A 73.80.65.49 +smimea1 3600 IN SMIMEA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 +smimea2 3600 IN SMIMEA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 +smimea3 3600 IN SMIMEA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 spf 3600 IN SPF "v=spf1 mx -all" srv01 3600 IN SRV 0 0 0 . srv02 3600 IN SRV 65535 65535 65535 old-slow-box.example.com. diff --git a/tests/example2.good b/tests/example2.good index cd7a8555..ebe1a7ef 100644 --- a/tests/example2.good +++ b/tests/example2.good @@ -108,6 +108,9 @@ rt01.example. 3600 IN RT 0 intermediate-host.example. rt02.example. 3600 IN RT 65535 . s.example. 300 IN NS ns.s.example. ns.s.example. 300 IN A 73.80.65.49 +smimea1.example. 3600 IN SMIMEA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 +smimea2.example. 3600 IN SMIMEA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 +smimea3.example. 3600 IN SMIMEA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 spf.example. 3600 IN SPF "v=spf1 mx -all" srv01.example. 3600 IN SRV 0 0 0 . srv02.example. 3600 IN SRV 65535 65535 65535 old-slow-box.example.com. diff --git a/tests/example3.good b/tests/example3.good index 4aaea377..8c751c2c 100644 --- a/tests/example3.good +++ b/tests/example3.good @@ -108,6 +108,9 @@ rt01 3600 IN RT 0 intermediate-host rt02 3600 IN RT 65535 . s 300 IN NS ns.s ns.s 300 IN A 73.80.65.49 +smimea1 3600 IN SMIMEA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 +smimea2 3600 IN SMIMEA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 +smimea3 3600 IN SMIMEA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 spf 3600 IN SPF "v=spf1 mx -all" srv01 3600 IN SRV 0 0 0 . srv02 3600 IN SRV 65535 65535 65535 old-slow-box.example.com. diff --git a/tests/test_rdata.py b/tests/test_rdata.py index 72ed15a1..40714037 100644 --- a/tests/test_rdata.py +++ b/tests/test_rdata.py @@ -638,6 +638,18 @@ class RdataTestCase(unittest.TestCase): with self.assertRaises(dns.exception.SyntaxError): dns.rdata.from_text('in', 'txt', 'a' * 256) + def equal_smimea(self, a, b): + a = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SMIMEA, a) + b = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SMIMEA, b) + self.assertEqual(a, b) + + def test_good_SMIMEA(self): + self.equal_smimea('3 0 1 aabbccddeeff', '3 0 01 AABBCCDDEEFF') + + def test_bad_SMIMEA(self): + with self.assertRaises(dns.exception.SyntaxError): + dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SMIMEA, '1 1 1 aGVsbG8gd29ybGQh') + class UtilTestCase(unittest.TestCase):