Fixed broken test
This commit is contained in:
parent
59f9316f51
commit
70179f8c8c
@ -32,7 +32,7 @@ type Device struct {
|
||||
stop chan struct{}
|
||||
}
|
||||
peers map[NoisePublicKey]*Peer
|
||||
mac MacStateDevice
|
||||
mac MACStateDevice
|
||||
}
|
||||
|
||||
func (device *Device) SetPrivateKey(sk NoisePrivateKey) {
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type MacStateDevice struct {
|
||||
type MACStateDevice struct {
|
||||
mutex sync.RWMutex
|
||||
refreshed time.Time
|
||||
secret [blake2s.Size]byte
|
||||
@ -19,7 +19,7 @@ type MacStateDevice struct {
|
||||
xaead cipher.AEAD
|
||||
}
|
||||
|
||||
func (state *MacStateDevice) Init(pk NoisePublicKey) {
|
||||
func (state *MACStateDevice) Init(pk NoisePublicKey) {
|
||||
state.mutex.Lock()
|
||||
defer state.mutex.Unlock()
|
||||
func() {
|
||||
@ -32,7 +32,7 @@ func (state *MacStateDevice) Init(pk NoisePublicKey) {
|
||||
state.refreshed = time.Time{} // never
|
||||
}
|
||||
|
||||
func (state *MacStateDevice) CheckMAC1(msg []byte) bool {
|
||||
func (state *MACStateDevice) CheckMAC1(msg []byte) bool {
|
||||
size := len(msg)
|
||||
startMac1 := size - (blake2s.Size128 * 2)
|
||||
startMac2 := size - blake2s.Size128
|
||||
@ -47,7 +47,7 @@ func (state *MacStateDevice) CheckMAC1(msg []byte) bool {
|
||||
return hmac.Equal(mac1[:], msg[startMac1:startMac2])
|
||||
}
|
||||
|
||||
func (state *MacStateDevice) CheckMAC2(msg []byte, addr *net.UDPAddr) bool {
|
||||
func (state *MACStateDevice) CheckMAC2(msg []byte, addr *net.UDPAddr) bool {
|
||||
state.mutex.RLock()
|
||||
defer state.mutex.RUnlock()
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type MacStatePeer struct {
|
||||
type MACStatePeer struct {
|
||||
mutex sync.RWMutex
|
||||
cookieSet time.Time
|
||||
cookie [blake2s.Size128]byte
|
||||
@ -18,7 +18,7 @@ type MacStatePeer struct {
|
||||
xaead cipher.AEAD
|
||||
}
|
||||
|
||||
func (state *MacStatePeer) Init(pk NoisePublicKey) {
|
||||
func (state *MACStatePeer) Init(pk NoisePublicKey) {
|
||||
state.mutex.Lock()
|
||||
defer state.mutex.Unlock()
|
||||
func() {
|
||||
@ -31,7 +31,7 @@ func (state *MacStatePeer) Init(pk NoisePublicKey) {
|
||||
state.cookieSet = time.Time{} // never
|
||||
}
|
||||
|
||||
func (state *MacStatePeer) AddMacs(msg []byte) {
|
||||
func (state *MACStatePeer) AddMacs(msg []byte) {
|
||||
size := len(msg)
|
||||
|
||||
if size < blake2s.Size128*2 {
|
||||
|
@ -57,8 +57,8 @@ type MessageInitiation struct {
|
||||
Ephemeral NoisePublicKey
|
||||
Static [NoisePublicKeySize + poly1305.TagSize]byte
|
||||
Timestamp [TAI64NSize + poly1305.TagSize]byte
|
||||
Mac1 [blake2s.Size128]byte
|
||||
Mac2 [blake2s.Size128]byte
|
||||
MAC1 [blake2s.Size128]byte
|
||||
MAC2 [blake2s.Size128]byte
|
||||
}
|
||||
|
||||
type MessageResponse struct {
|
||||
@ -67,8 +67,8 @@ type MessageResponse struct {
|
||||
Receiver uint32
|
||||
Ephemeral NoisePublicKey
|
||||
Empty [poly1305.TagSize]byte
|
||||
Mac1 [blake2s.Size128]byte
|
||||
Mac2 [blake2s.Size128]byte
|
||||
MAC1 [blake2s.Size128]byte
|
||||
MAC2 [blake2s.Size128]byte
|
||||
}
|
||||
|
||||
type MessageTransport struct {
|
||||
|
@ -118,7 +118,7 @@ func TestNoiseHandshake(t *testing.T) {
|
||||
var out []byte
|
||||
var nonce [12]byte
|
||||
out = key1.send.Seal(out, nonce[:], testMsg, nil)
|
||||
out, err = key2.recv.Open(out[:0], nonce[:], out, nil)
|
||||
out, err = key2.receive.Open(out[:0], nonce[:], out, nil)
|
||||
assertNil(t, err)
|
||||
assertEqual(t, out, testMsg)
|
||||
}()
|
||||
@ -129,7 +129,7 @@ func TestNoiseHandshake(t *testing.T) {
|
||||
var out []byte
|
||||
var nonce [12]byte
|
||||
out = key2.send.Seal(out, nonce[:], testMsg, nil)
|
||||
out, err = key1.recv.Open(out[:0], nonce[:], out, nil)
|
||||
out, err = key1.receive.Open(out[:0], nonce[:], out, nil)
|
||||
assertNil(t, err)
|
||||
assertEqual(t, out, testMsg)
|
||||
}()
|
||||
|
@ -39,7 +39,7 @@ type Peer struct {
|
||||
outbound chan *QueueOutboundElement // sequential ordering of work
|
||||
inbound chan *QueueInboundElement // sequential ordering of work
|
||||
}
|
||||
mac MacStatePeer
|
||||
mac MACStatePeer
|
||||
}
|
||||
|
||||
func (device *Device) NewPeer(pk NoisePublicKey) *Peer {
|
||||
|
Loading…
Reference in New Issue
Block a user