Skip to content

Commit 8987906

Browse files
committed
Remove support for xsalsapoly
1 parent 699a6a1 commit 8987906

3 files changed

Lines changed: 8 additions & 28 deletions

File tree

dnscrypt-proxy/common.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type CryptoConstruction uint16
1818

1919
const (
2020
UndefinedConstruction CryptoConstruction = iota
21-
XSalsa20Poly1305
2221
XChacha20Poly1305
2322
)
2423

dnscrypt-proxy/crypto.go

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"github.com/jedisct1/dlog"
1010
"github.com/jedisct1/xsecretbox"
1111
"golang.org/x/crypto/curve25519"
12-
"golang.org/x/crypto/nacl/box"
13-
"golang.org/x/crypto/nacl/secretbox"
1412
)
1513

1614
const (
@@ -57,19 +55,9 @@ func ComputeSharedKey(
5755
dlog.Criticalf("[%v] Weak XChaCha20 public key", providerName)
5856
}
5957
} else {
60-
box.Precompute(&sharedKey, serverPk, secretKey)
61-
c := byte(0)
62-
for i := 0; i < 32; i++ {
63-
c |= sharedKey[i]
64-
}
65-
if c == 0 {
66-
dlog.Criticalf("[%v] Weak XSalsa20 public key", providerName)
67-
if _, err := crypto_rand.Read(sharedKey[:]); err != nil {
68-
dlog.Fatal(err)
69-
}
70-
}
58+
dlog.Criticalf("[%v] Unsupported encryption system", providerName)
7159
}
72-
return
60+
return sharedKey
7361
}
7462

7563
func (proxy *Proxy) Encrypt(
@@ -124,9 +112,7 @@ func (proxy *Proxy) Encrypt(
124112
if serverInfo.CryptoConstruction == XChacha20Poly1305 {
125113
encrypted = xsecretbox.Seal(encrypted, nonce, padded, sharedKey[:])
126114
} else {
127-
var xsalsaNonce [24]byte
128-
copy(xsalsaNonce[:], nonce)
129-
encrypted = secretbox.Seal(encrypted, padded, &xsalsaNonce, sharedKey)
115+
err = errors.New("Unsupported encryption system")
130116
}
131117
return
132118
}
@@ -153,13 +139,7 @@ func (proxy *Proxy) Decrypt(
153139
if serverInfo.CryptoConstruction == XChacha20Poly1305 {
154140
packet, err = xsecretbox.Open(nil, serverNonce, encrypted[responseHeaderLen:], sharedKey[:])
155141
} else {
156-
var xsalsaServerNonce [24]byte
157-
copy(xsalsaServerNonce[:], serverNonce)
158-
var ok bool
159-
packet, ok = secretbox.Open(nil, encrypted[responseHeaderLen:], &xsalsaServerNonce, sharedKey)
160-
if !ok {
161-
err = errors.New("Incorrect tag")
162-
}
142+
err = errors.New("Unsupported encryption system")
163143
}
164144
if err != nil {
165145
return encrypted, err

dnscrypt-proxy/dnscrypt_certs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ func FetchCurrentDNSCryptCert(
9595
cryptoConstruction := CryptoConstruction(0)
9696
switch esVersion := binary.BigEndian.Uint16(binCert[4:6]); esVersion {
9797
case 0x0001:
98-
cryptoConstruction = XSalsa20Poly1305
98+
dlog.Noticef("[%v] Deprecated, now unsupported encryption system", *serverName)
99+
continue
99100
case 0x0002:
100101
cryptoConstruction = XChacha20Poly1305
101102
default:
102-
dlog.Noticef("[%v] Unsupported crypto construction", *serverName)
103+
dlog.Noticef("[%v] Unsupported encryption system", *serverName)
103104
continue
104105
}
105106
signature := binCert[8:72]
@@ -163,7 +164,7 @@ func FetchCurrentDNSCryptCert(
163164
dlog.Debugf("[%v] Upgrading the construction from %v to %v", *serverName, certInfo.CryptoConstruction, cryptoConstruction)
164165
}
165166
}
166-
if cryptoConstruction != XChacha20Poly1305 && cryptoConstruction != XSalsa20Poly1305 {
167+
if cryptoConstruction != XChacha20Poly1305 {
167168
dlog.Noticef("[%v] Cryptographic construction %v not supported", *serverName, cryptoConstruction)
168169
continue
169170
}

0 commit comments

Comments
 (0)