Skip to content

Commit 55f2f43

Browse files
committed
Use local references
1 parent 7d94662 commit 55f2f43

8 files changed

Lines changed: 31 additions & 31 deletions

File tree

reference-implementation/certificates.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dataclasses import dataclass, replace
77
from typing import Iterable, Sequence
88

9-
from .constants import (
9+
from constants import (
1010
AEAD_ID_XCHACHA20_DJB_POLY1305,
1111
CERT_MAGIC,
1212
CLIENT_MAGIC_SIZE,
@@ -22,8 +22,8 @@
2222
XWING_CIPHERTEXT_SIZE,
2323
XWING_PUBLIC_KEY_SIZE,
2424
)
25-
from .crypto import _require_size, ed25519_sign, ed25519_verify
26-
from .errors import CertificateError
25+
from crypto import _require_size, ed25519_sign, ed25519_verify
26+
from errors import CertificateError
2727

2828

2929
def resolver_pk_len_for_es_version(es_version: bytes) -> int:

reference-implementation/crypto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from cryptography.hazmat.primitives.poly1305 import Poly1305
1313
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
1414

15-
from .constants import NONCE_SIZE, PADDING_BLOCK_SIZE, RESOLVER_NONCE_SIZE, TAG_SIZE
16-
from .errors import CertificateError, DecryptionError, PaddingError
15+
from constants import NONCE_SIZE, PADDING_BLOCK_SIZE, RESOLVER_NONCE_SIZE, TAG_SIZE
16+
from errors import CertificateError, DecryptionError, PaddingError
1717

1818

1919
def _require_size(name: str, value: bytes, size: int) -> None:
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"""Readable reference implementation for DNSCrypt v2 and PQDNSCrypt.
22
33
This module is a compatibility facade. The implementation is split by topic in
4-
the neighboring modules, but importing `reference.dnscrypt` exposes the same
5-
simple API used by the tests and examples.
4+
the neighboring modules, but importing `dnscrypt` exposes the same simple API
5+
used by the tests and examples.
66
"""
77

8-
from .certificates import *
9-
from .constants import *
10-
from .crypto import *
11-
from .errors import *
12-
from .packets import *
13-
from .pq import *
14-
from .transport import *
15-
from .types import *
8+
from certificates import *
9+
from constants import *
10+
from crypto import *
11+
from errors import *
12+
from packets import *
13+
from pq import *
14+
from transport import *
15+
from protocol_types import *
1616

reference-implementation/packets.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import os
66
from typing import Sequence
77

8-
from .certificates import client_pk_len_for_es_version
9-
from .constants import (
8+
from certificates import client_pk_len_for_es_version
9+
from constants import (
1010
CLIENT_MAGIC_SIZE,
1111
CLIENT_NONCE_SIZE,
1212
ES_VERSION_XCHACHA20POLY1305,
@@ -18,7 +18,7 @@
1818
RESOLVER_NONCE_SIZE,
1919
TAG_SIZE,
2020
)
21-
from .crypto import (
21+
from crypto import (
2222
_require_size,
2323
box_xchacha20_shared_key,
2424
pad_7816_4,
@@ -28,8 +28,8 @@
2828
xchacha20_djb_poly1305_open,
2929
xchacha20_djb_poly1305_seal,
3030
)
31-
from .errors import CertificateError, DecryptionError
32-
from .types import DecryptedQuery, PreparedQuery, ResolverCertificate
31+
from errors import CertificateError, DecryptionError
32+
from protocol_types import DecryptedQuery, PreparedQuery, ResolverCertificate
3333

3434

3535
def encrypt_dnscrypt_query(
@@ -92,7 +92,7 @@ def decrypt_dnscrypt_query(
9292
if certificate.es_version == ES_VERSION_XCHACHA20POLY1305:
9393
shared_key = box_xchacha20_shared_key(match.resolver_sk, client_pk)
9494
elif certificate.es_version == ES_VERSION_XWING:
95-
from .pq import pq_shared_key, xwing_decapsulate
95+
from pq import pq_shared_key, xwing_decapsulate
9696

9797
kem_ss = xwing_decapsulate(encrypted_kem=client_pk, secret_seed=match.resolver_sk)
9898
shared_key = pq_shared_key(certificate, kem_ss, client_pk)

reference-implementation/pq.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from cryptography.hazmat.primitives.asymmetric import mlkem, x25519
1010
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
1111

12-
from .certificates import DNSCryptCertificate, parse_pq_profile_extension
13-
from .constants import (
12+
from certificates import DNSCryptCertificate, parse_pq_profile_extension
13+
from constants import (
1414
CLIENT_NONCE_SIZE,
1515
ES_VERSION_XWING,
1616
MIN_UDP_QUERY_LEN,
@@ -27,7 +27,7 @@
2727
XWING_MLKEM_PUBLIC_KEY_SIZE,
2828
XWING_PUBLIC_KEY_SIZE,
2929
)
30-
from .crypto import (
30+
from crypto import (
3131
_require_size,
3232
hkdf_sha256,
3333
pad_7816_4,
@@ -36,9 +36,9 @@
3636
xchacha20_djb_poly1305_open,
3737
xchacha20_djb_poly1305_seal,
3838
)
39-
from .errors import CertificateError, DecryptionError
40-
from .packets import decrypt_dnscrypt_response, encrypt_dnscrypt_response
41-
from .types import (
39+
from errors import CertificateError, DecryptionError
40+
from packets import decrypt_dnscrypt_response, encrypt_dnscrypt_response
41+
from protocol_types import (
4242
DecryptedQuery,
4343
IssuedPQTicket,
4444
OpenedTicket,

reference-implementation/types.py renamed to reference-implementation/protocol_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
import ipaddress
77

8-
from .certificates import DNSCryptCertificate
8+
from certificates import DNSCryptCertificate
99

1010

1111
@dataclass(frozen=True)

reference-implementation/test_dnscrypt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import hashlib
22
import unittest
33

4-
from reference import dnscrypt as d
4+
import dnscrypt as d
55

66

77
DNS_QUERY = bytes.fromhex(

reference-implementation/transport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import ipaddress
66

7-
from .constants import ANON_MAGIC
8-
from .types import AnonymizedDNSCryptQuery
7+
from constants import ANON_MAGIC
8+
from protocol_types import AnonymizedDNSCryptQuery
99

1010

1111
def tcp_packet(packet: bytes) -> bytes:

0 commit comments

Comments
 (0)