# DNSCurve

DNSCurve is a proposed secure protocol for the Domain Name System (DNS), designed by Daniel J. Bernstein. It encrypts and authenticates DNS packets between resolvers and authoritative servers.
DNSCurve claims advantages over previous DNS services of:
* Confidentiality—usual DNS requests and responses are not encrypted, and broadcast to any attacker.
* Integrity—usual DNS has some protection, but with patience and sniffing attackers can forge DNS records; this is prevented by DNSCurve cryptographic authentication.
* Availability—usual DNS has no protection against denial of service (DoS) by a sniffing attacker sending a few forged packets per second. DNSCurve recognizes and discards forged DNS packets, providing some protection, though SMTP, HTTP, HTTPS, are also vulnerable to DoS.

## Structure

DNSCurve uses Curve25519 elliptic curve cryptography to establish the identity of authoritative servers. Public keys for remote authoritative servers are placed in NS records, so recursive resolvers know whether the server supports DNSCurve. Keys begin with the magic string uz5 and are followed by a 51-byte Base32 encoding of the server's 255-bit public key. E.g., in BIND format:
The identity is used to establish keys used by an authenticated encryption scheme consisting of Salsa20 and Poly1305.The cryptographic setup is called a "cryptographic box", specifically crypto_box_curve25519xsalsa20poly1305.
The "cryptographic box" tool used in DNSCurve are the same used in CurveCP, a UDP-based protocol which is similar to TCP but uses elliptic-curve cryptography to encrypt and authenticate data. An analogy is that while DNSSEC is like signing a webpage with Pretty Good Privacy (PGP), CurveCP and DNSCurve are like encrypting and authenticating the channel using Transport Layer Security (TLS). Just as PGP-signed webpages can be sent over an encrypted channel using SSL, DNSSEC data can be protected using DNSCurve.

## Operation

The resolver first retrieves the public key from the NS record, see § Structure above.
The resolver then sends to the server a packet containing its DNSCurve public key, a 96-bit nonce, and a cryptographic box containing the query. The cryptographic box is created using the resolver's private key, the server's public key, and the nonce. The response from the server contains a different 96-bit nonce and its own cryptographic box containing the answer to the query.

## Security

DNSCurve uses 256-bit elliptic-curve cryptography, which NIST estimates to be roughly equivalent to 3072-bit RSA. ECRYPT reports a similar equivalence. It uses per-query public-key crypto (like SSH and SSL), and 96-bit nonces to protect against replay attacks. Adam Langley, security officer at Google, says "With very high probability, no one will ever solve a single instance of Curve25519 without a large, quantum computer."

## Speed

Adam Langley has posted speed tests on his personal website showing Curve25519, used by DNSCurve, to be the fastest among elliptic curves tested. According to the U.S. National Security Agency (NSA), elliptic curve cryptography offers vastly superior performance over RSA and Diffie–Hellman at a geometric rate as key sizes increase.

## Implementations

DNSCurve first gained recursive support in dnscache via a patch by Matthew Dempsky. Dempsky also has a GitHub repository which includes Python DNS lookup tools and a forwarder in C. Adam Langley has a GitHub repository as well. There is an authoritative forwarder called CurveDNS which allows DNS administrators to protect existing installations without patching.
Jan Mojžíš has released curveprotect, a software suite which implements DNSCurve and CurveCP protection for common services like DNS, SSH, HTTP, and SMTP.
DNSCurve.io (2023) recommends two implementations: Jan Mojžíš's dqcache for recursive resolvers, CurveDNS for authoritative servers.

## Deployment

OpenDNS, which has 50 million users, announced support for DNSCurve on its recursive resolvers on February 23, 2010. In other words, its recursive resolvers now use DNSCurve to communicate to authoritative servers if available. On December 6, 2011, OpenDNS announced a new tool, called DNSCrypt. DNSCrypt is based on similar cryptographic tools as DNSCurve, but instead protects the channel between OpenDNS and its users.
No equally large authoritative DNS providers have yet deployed DNSCurve.