Skip to content

Commit 41843e8

Browse files
committed
Better comments in the reference implementation
1 parent c0eaa2d commit 41843e8

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎reference-implementation/certificate_retrieval.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,14 @@ def serve_certificates(
162162
) -> bytes:
163163
"""Answer a certificate query under the anti-amplification rule.
164164
165-
The small classical certificates are always returned. The large PQ
166-
certificates are added only when the complete response still fits within the
167-
request that triggered it, because over UDP a response MUST NOT be larger than
168-
its request, or a spoofed query would be amplified. When the PQ certificates do
169-
not fit, the response carries only the classical certificates with the TC bit
170-
set and a PQ-capable client retries over TCP. Over TCP the handshake validates
171-
the source, so the PQ certificates are always included.
165+
The classical certificate is always returned for compatibility with deployed
166+
DNSCrypt v2 clients and resolvers. The large PQ certificates are added over
167+
UDP only when the complete response still fits within the request that
168+
triggered it, because otherwise a spoofed query could amplify traffic. When
169+
the PQ certificates do not fit, the response carries the classical
170+
certificates with the TC bit set and a PQ-capable client retries over TCP.
171+
Over TCP the handshake validates the source, so all certificates are always
172+
included.
172173
"""
173174

174175
full = build_certificate_response(

‎reference-implementation/test_dnscrypt.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ def test_certificate_retrieval_amplification(self):
304304
self.assertLessEqual(len(served), len(padded))
305305
self.assertEqual(d.relay_certificate_response(padded, served), served)
306306

307-
# An unpadded query is too small: the PQ certificate is withheld with TC set.
307+
# An unpadded query is too small for the PQ certificate: return the
308+
# classical certificate with TC set, matching deployed resolvers.
308309
small = d.certificate_query(provider_name)
309310
truncated = d.serve_certificates(small, [classical], [pq], over_udp=True)
310311
self.assertEqual(truncated[6:8], b"\x00\x01") # classical only

0 commit comments

Comments
 (0)