diff options
| author | Brian Wellington <bwelling@xbill.org> | 2020-08-10 11:43:20 -0700 |
|---|---|---|
| committer | Brian Wellington <bwelling@xbill.org> | 2020-08-10 11:43:20 -0700 |
| commit | b7ad53ef1a7177b01cc081f589f2efb5460cd41a (patch) | |
| tree | b0e4b45cef17cf9a491629ac241bb9e8ff972b2e /tests | |
| parent | 8ac073718d44c79e4a34efd9894966d4e6f032a9 (diff) | |
| download | dnspython-b7ad53ef1a7177b01cc081f589f2efb5460cd41a.tar.gz | |
Add support for new TSIG algorithms.
This adds support for the hmac-sha256-128, hmac-sha384-192, and hmac-sha512-256 truncated algorithms.
This also reorders some of the declarations in the TSIG code.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_tsig.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_tsig.py b/tests/test_tsig.py index ec5a6cc..6e3993b 100644 --- a/tests/test_tsig.py +++ b/tests/test_tsig.py @@ -226,3 +226,22 @@ class TSIGTestCase(unittest.TestCase): def bad(): dns.message.from_wire(w, keyring=keyring, request_mac=q.mac) self.assertRaises(ex, bad) + + def _test_truncated_algorithm(self, alg, length): + key = dns.tsig.Key('foo', b'abcdefg', algorithm=alg) + q = dns.message.make_query('example', 'a') + q.use_tsig(key) + q2 = dns.message.from_wire(q.to_wire(), keyring=key) + + self.assertTrue(q2.had_tsig) + self.assertEqual(q2.tsig[0].algorithm, q.tsig[0].algorithm) + self.assertEqual(len(q2.tsig[0].mac), length // 8) + + def test_hmac_sha256_128(self): + self._test_truncated_algorithm(dns.tsig.HMAC_SHA256_128, 128) + + def test_hmac_sha384_192(self): + self._test_truncated_algorithm(dns.tsig.HMAC_SHA384_192, 192) + + def test_hmac_sha512_256(self): + self._test_truncated_algorithm(dns.tsig.HMAC_SHA512_256, 256) |
