You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: draft-denis-dprive-dnscrypt.md
+17-22Lines changed: 17 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,9 +101,7 @@ The ongoing communication phase operates with several important characteristics
101
101
102
102
2. **Out-of-Order Responses**: Responses may arrive in a different order than the queries were sent. Each response is self-contained and can be processed independently.
103
103
104
-
3. **Multiple Responses**: A single query may result in multiple responses, and responses can be received without sending new queries. For example, a server might send additional responses for a query that has multiple answers or requires additional processing.
105
-
106
-
4. **Asynchronous Communication**: The protocol does not require strict request-response pairing. A client can send multiple queries before receiving responses, and responses can be processed as they arrive.
104
+
3. **Concurrent Queries**: A client can send multiple queries without waiting for earlier responses, and responses can be processed independently as they arrive.
107
105
108
106
With this understanding of the protocol flow, we can now examine the specific components that make up DNSCrypt packets and their structure.
109
107
@@ -123,7 +121,7 @@ Definitions for client queries:
- `<shared-key>`: the shared key derived from `<resolver-pk>` and `<client-sk>`, using the key exchange algorithm defined in the chosen certificate.
126
-
- `<client-query>`: the unencrypted client query. The query is not modified; in particular, the query flags are not altered and the query length MUST be kept in queries prepared to be sent over TCP {{!RFC7766}}.
124
+
- `<client-query>`: the unencrypted client query. The query is not modified; in particular, the query flags are not altered.
127
125
- `<client-nonce-pad>`: `<client-nonce>`length is half the nonce length required by the encryption algorithm. In client queries, the other half, `<client-nonce-pad>` is filled with NUL bytes.
128
126
- `<client-query-pad>`: the variable-length padding.
129
127
@@ -136,10 +134,10 @@ Definitions for server responses:
136
134
- `<client-pk>`: the client's public key.
137
135
- `<resolver-sk>`: the resolver's secret key.
138
136
- `<resolver-nonce>`: a unique response identifier for a given `(<client-pk>, <resolver-sk>)` tuple. The length of `<resolver-nonce>` depends on the chosen encryption algorithm.
- `<shared-key>`: the shared key derived from `<resolver-sk>` and `<client-pk>`, using the key exchange algorithm defined in the chosen certificate.
142
-
- `<resolver-response>`: the unencrypted resolver response. The response is not modified; in particular, the query flags are not altered and the response length MUST be kept in responses prepared to be sent over TCP {{!RFC7766}}.
140
+
- `<resolver-response>`: the unencrypted resolver response. The response is not modified; in particular, the query flags are not altered.
143
141
- `<resolver-response-pad>`: the variable-length padding.
144
142
145
143
The following diagram shows the structure of a DNSCrypt query packet:
@@ -194,8 +192,8 @@ Building on the protocol flow and components described earlier, this section pro
194
192
2. The client generates its own key pair.
195
193
3. The client encrypts unmodified DNS queries using a server's public key, padding them as necessary, and concatenates them to a nonce and a copy of the client's public key. The resulting output is transmitted to the server via standard DNS transport mechanisms {{!RFC1035}}.
196
194
4. Encrypted queries are decrypted by the server using the attached client public key and the server's own secret key. The output is a regular DNS packet that doesn't require any special processing.
197
-
5. To send an encrypted response, the server adds padding to the unmodified response, encrypts the result using the client's public key and the client's nonce, and truncates the response if necessary. The resulting packet, truncated or not, is sent to the client using standard DNS mechanisms.
198
-
6. The client authenticates and decrypts the response using its secret key, the server's public key, the client's nonce included in the response, and the client's original nonce. If the response was truncated, the client MAY adjust internal parameters and retry over TCP {{!RFC7766}}. If not, the output is a regular DNS response that can be directly forwarded to applications and stub resolvers.
195
+
5. To send an encrypted response, the server adds padding to the unmodified response, encrypts the result using the shared key and a nonce made of the client's nonce followed by the resolver's nonce, and truncates the response if necessary. The resulting packet, truncated or not, is sent to the client using standard DNS mechanisms.
196
+
6. The client authenticates and decrypts the response using the shared key and the nonce included in the response. If the response was truncated, the client MAY adjust internal parameters and retry over TCP {{!RFC7766}}. If not, the output is a regular DNS response that can be directly forwarded to applications and stub resolvers.
199
197
200
198
Key features of the DNSCrypt protocol include:
201
199
@@ -294,9 +292,7 @@ or
294
292
295
293
### Client Queries Over TCP
296
294
297
-
The sole differences between encrypted client queries transmitted via TCP and those sent using UDP lie in the padding length calculation and the inclusion of a length prefix, represented as two big-endian bytes.
298
-
299
-
In contrast, cleartext DNS query payloads do not necessitate a length prefix, regardless of whether they are transmitted via TCP.
295
+
The sole differences between encrypted client queries transmitted via TCP and those sent using UDP lie in the padding length calculation and the inclusion of a two-byte big-endian length prefix for the encrypted DNSCrypt packet.
300
296
301
297
Unlike UDP queries, a query sent over TCP can be shorter than the response.
302
298
@@ -423,7 +419,7 @@ The DNSCrypt protocol provides several security benefits:
423
419
424
420
3. **Authentication**: The use of X25519 {{!RFC7748}} for key exchange and Ed25519 for certificate signatures provides strong authentication of resolvers. Clients can verify they are communicating with the intended resolver and not an impostor.
425
421
426
-
4. **Forward Secrecy**: Short-term key pairs are used for each session, providing forward secrecy. Even if a long-term key is compromised, past communications remain secure.
422
+
4. **Short-Term Resolver Keys**: Resolver certificates carry short-term public keys, limiting the impact of key compromise and enabling regular key rotation.
427
423
428
424
These fundamental security properties depend on correct implementation practices. Several implementation-specific security aspects require particular attention.
429
425
@@ -432,15 +428,14 @@ These fundamental security properties depend on correct implementation practices
432
428
Implementations should consider the following security aspects:
433
429
434
430
1. **Key Management**:
435
-
- Resolvers MUST rotate their short-term key pairs at least every 24 hours
436
-
- Previous secret keys MUST be securely erased after rotation
431
+
- Resolvers MUST rotate their short-term key pairs at most every 24 hours
432
+
- Previous secret keys MUST be discarded after rotation
437
433
- Provider secret keys used for certificate signing SHOULD be stored in hardware security modules (HSMs)
438
434
- Example: A resolver might generate new key pairs daily at midnight UTC
439
435
440
436
2. **Nonce Management**:
441
437
- Nonces MUST NOT be reused for a given shared secret
442
-
- Clients SHOULD include timestamps in their nonces to prevent replay attacks
443
-
- Resolvers SHOULD verify that nonces are within a reasonable time window (e.g., ±5 minutes)
438
+
- Clients can include timestamps in their nonces in order to quickly discard stale responses
444
439
- Example: A nonce might be constructed as: `timestamp || random_bytes`
445
440
446
441
3. **Padding**:
@@ -464,9 +459,9 @@ DNSCrypt provides protection against several types of attacks:
464
459
465
460
2. **Amplification Attacks**: The padding requirements and minimum query length help prevent amplification attacks {{!RFC5358}}. For example, a 256-byte minimum query size limits the amplification factor.
466
461
467
-
3. **Fragmentation Attacks**: The protocol handles fragmentation in a way that prevents certain types of attacks. Large responses are properly fragmented and reassembled.
462
+
3. **Fragmentation Attacks**: The protocol mitigates fragmentation risks by padding queries, allowing truncated UDP responses, and retrying over TCP when necessary.
468
463
469
-
4. **Replay Attacks**: The use of nonces and timestamps helps prevent replay attacks. A replayed query would be detected due to nonce reuse.
464
+
4. **Replay Exposure Reduction**: Nonces make responses query-specific, and clients can use timestamps in client nonces to quickly discard stale responses.
470
465
471
466
While DNSCrypt effectively mitigates these attacks, implementers should also be aware of privacy considerations that extend beyond basic protocol security.
472
467
@@ -645,7 +640,7 @@ The `Box-XChaChaPoly` algorithm combines the `X25519` {{!RFC7748}} key exchange
645
640
646
641
`HChaCha20`is based on the construction and security proof used to create XSalsa20, an extended-nonce variant of Salsa20.
647
642
648
-
The `HChaCha20` function takes the following input paramters:
643
+
The `HChaCha20` function takes the following input parameters:
0 commit comments