aboutsummaryrefslogtreecommitdiffstats
path: root/device/noise-types.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-01-28 14:44:51 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-28 14:45:53 +0100
commitd4725bc45685187088c84234a6d2be396a1373e5 (patch)
tree8f9004104f4cde6589380d17793e9412b6b67742 /device/noise-types.go
parentdevice: get rid of nonce routine (diff)
downloadwireguard-go-d4725bc45685187088c84234a6d2be396a1373e5.tar.xz
wireguard-go-d4725bc45685187088c84234a6d2be396a1373e5.zip
device: the psk is not a chapoly key
It's a separate type of key that gets hashed into the chain. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/noise-types.go')
-rw-r--r--device/noise-types.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/device/noise-types.go b/device/noise-types.go
index f793ef5..90108d4 100644
--- a/device/noise-types.go
+++ b/device/noise-types.go
@@ -9,19 +9,18 @@ import (
"crypto/subtle"
"encoding/hex"
"errors"
-
- "golang.org/x/crypto/chacha20poly1305"
)
const (
- NoisePublicKeySize = 32
- NoisePrivateKeySize = 32
+ NoisePublicKeySize = 32
+ NoisePrivateKeySize = 32
+ NoisePresharedKeySize = 32
)
type (
NoisePublicKey [NoisePublicKeySize]byte
NoisePrivateKey [NoisePrivateKeySize]byte
- NoiseSymmetricKey [chacha20poly1305.KeySize]byte
+ NoisePresharedKey [NoisePresharedKeySize]byte
NoiseNonce uint64 // padded to 12-bytes
)
@@ -82,10 +81,10 @@ func (key NoisePublicKey) Equals(tar NoisePublicKey) bool {
return subtle.ConstantTimeCompare(key[:], tar[:]) == 1
}
-func (key *NoiseSymmetricKey) FromHex(src string) error {
+func (key *NoisePresharedKey) FromHex(src string) error {
return loadExactHex(key[:], src)
}
-func (key NoiseSymmetricKey) ToHex() string {
+func (key NoisePresharedKey) ToHex() string {
return hex.EncodeToString(key[:])
}