]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: the psk is not a chapoly key
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 28 Jan 2021 13:44:51 +0000 (14:44 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 28 Jan 2021 13:45:53 +0000 (14:45 +0100)
It's a separate type of key that gets hashed into the chain.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
device/noise-protocol.go
device/noise-types.go

index 5669381cb03159dac5bc96bc0c255da90061218a..1068701b505a2c1e9c237d806c8a478658146c4d 100644 (file)
@@ -121,7 +121,7 @@ type Handshake struct {
        mutex                     sync.RWMutex
        hash                      [blake2s.Size]byte       // hash value
        chainKey                  [blake2s.Size]byte       // chain key
-       presharedKey              NoiseSymmetricKey        // psk
+       presharedKey              NoisePresharedKey        // psk
        localEphemeral            NoisePrivateKey          // ephemeral secret key
        localIndex                uint32                   // used to clear hash-table
        remoteIndex               uint32                   // index for sending
index f793ef5ba1f79ba66623c6f101e9fa4a9817cecf..90108d476a047117a00fef46a3d5175ae6547938 100644 (file)
@@ -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[:])
 }