Skip to content

Commit d1cadc3

Browse files
committed
Fixes
1 parent 3dff013 commit d1cadc3

1 file changed

Lines changed: 17 additions & 22 deletions

File tree

draft-denis-dprive-dnscrypt.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ The ongoing communication phase operates with several important characteristics
101101

102102
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.
103103

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.
107105

108106
With this understanding of the protocol flow, we can now examine the specific components that make up DNSCrypt packets and their structure.
109107

@@ -123,7 +121,7 @@ Definitions for client queries:
123121
- `AE`: the authenticated encryption function.
124122
- `<encrypted-query>`: `AE(<shared-key> <client-nonce> <client-nonce-pad>, <client-query> <client-query-pad>)`
125123
- `<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.
127125
- `<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.
128126
- `<client-query-pad>`: the variable-length padding.
129127

@@ -136,10 +134,10 @@ Definitions for server responses:
136134
- `<client-pk>`: the client's public key.
137135
- `<resolver-sk>`: the resolver's secret key.
138136
- `<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.
139-
- `DE`: the authenticated decryption function.
140-
- `<encrypted-response>`: `DE(<shared-key>, <nonce>, <resolver-response> <resolver-response-pad>)`
137+
- `AE`: the authenticated encryption function.
138+
- `<encrypted-response>`: `AE(<shared-key>, <nonce>, <resolver-response> <resolver-response-pad>)`
141139
- `<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.
143141
- `<resolver-response-pad>`: the variable-length padding.
144142

145143
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
194192
2. The client generates its own key pair.
195193
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}}.
196194
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.
199197

200198
Key features of the DNSCrypt protocol include:
201199

@@ -294,9 +292,7 @@ or
294292

295293
### Client Queries Over TCP
296294

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.
300296

301297
Unlike UDP queries, a query sent over TCP can be shorter than the response.
302298

@@ -423,7 +419,7 @@ The DNSCrypt protocol provides several security benefits:
423419

424420
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.
425421

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.
427423

428424
These fundamental security properties depend on correct implementation practices. Several implementation-specific security aspects require particular attention.
429425

@@ -432,15 +428,14 @@ These fundamental security properties depend on correct implementation practices
432428
Implementations should consider the following security aspects:
433429

434430
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
437433
- Provider secret keys used for certificate signing SHOULD be stored in hardware security modules (HSMs)
438434
- Example: A resolver might generate new key pairs daily at midnight UTC
439435

440436
2. **Nonce Management**:
441437
- 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
444439
- Example: A nonce might be constructed as: `timestamp || random_bytes`
445440

446441
3. **Padding**:
@@ -464,9 +459,9 @@ DNSCrypt provides protection against several types of attacks:
464459

465460
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.
466461

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.
468463

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.
470465

471466
While DNSCrypt effectively mitigates these attacks, implementers should also be aware of privacy considerations that extend beyond basic protocol security.
472467

@@ -645,7 +640,7 @@ The `Box-XChaChaPoly` algorithm combines the `X25519` {{!RFC7748}} key exchange
645640

646641
`HChaCha20` is based on the construction and security proof used to create XSalsa20, an extended-nonce variant of Salsa20.
647642

648-
The `HChaCha20` function takes the following input paramters:
643+
The `HChaCha20` function takes the following input parameters:
649644

650645
- `<k>`: secret key
651646
- `<in>`: a 128-bit input
@@ -672,7 +667,7 @@ block_out[7] =
672667
LOAD32_LE(block_bytes[60..][0..4]) - LOAD32_LE(in[12..][0..4])
673668

674669
for i in 0..8:
675-
STORE32_LE(out[i * 4..][0..4], blocks_out[i])
670+
STORE32_LE(out[i * 4..][0..4], block_out[i])
676671

677672
return out
678673
~~~
@@ -727,7 +722,7 @@ The Box-XChaChaPoly algorithm combines the key exchange mechanism X25519 defined
727722

728723
- `<k>`: encryption key
729724
- `<m>`: message to encrypt
730-
- `<pk>`: recipent's public key
725+
- `<pk>`: recipient's public key
731726
- `<sk>`: sender's secret key
732727
- `<sk'>`: `HChaCha20(X25519(<pk>, <sk>))`
733728
- `Box-XChaChaPoly(pk, sk, m)`: `XChaCha20_DJB-Poly1305(<sk'>, <m>)`

0 commit comments

Comments
 (0)