diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-08-04 16:15:53 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-08-04 16:15:53 +0200 |
commit | 8c34c4cbb3780c433148966a004f5a51aace0f64 (patch) | |
tree | a590de76c326f6dfe3c92d2e27b78ce2ab792289 /src/noise_protocol.go | |
parent | 22c83f4b8d98b6b3c7dabc078e70801d0201876c (diff) |
First set of code review patches
Diffstat (limited to 'src/noise_protocol.go')
-rw-r--r-- | src/noise_protocol.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/noise_protocol.go b/src/noise_protocol.go index e2ff573..5c776a8 100644 --- a/src/noise_protocol.go +++ b/src/noise_protocol.go @@ -135,6 +135,10 @@ func (device *Device) CreateMessageInitiation(peer *Peer) (*MessageInitiation, e handshake.mutex.Lock() defer handshake.mutex.Unlock() + if isZero(handshake.precomputedStaticStatic[:]) { + return nil, errors.New("Static shared secret is zero") + } + // create ephemeral key var err error @@ -226,7 +230,11 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer { if peer == nil { return nil } + handshake := &peer.handshake + if isZero(handshake.precomputedStaticStatic[:]) { + return nil + } // verify identity @@ -472,6 +480,7 @@ func (peer *Peer) NewKeyPair() *KeyPair { func() { kp.mutex.Lock() defer kp.mutex.Unlock() + // TODO: Adapt kernel behavior noise.c:161 if isInitiator { if kp.previous != nil { kp.previous.send = nil |