mirror of
https://github.com/logos-messaging/noise.git
synced 2026-01-02 14:13:07 +00:00
Add checks from revision 18
This commit is contained in:
parent
14af5e1fc8
commit
f7b9b28336
6
state.go
6
state.go
@ -186,6 +186,9 @@ func (s *HandshakeState) WriteMessage(out, payload []byte) ([]byte, *CipherState
|
||||
s.e = s.cs.GenerateKeypair(s.rng)
|
||||
out = s.EncryptAndHash(out, s.e.Public)
|
||||
case MessagePatternS:
|
||||
if len(s.s.Public) == 0 {
|
||||
panic("noise: invalid state, s.Public is nil")
|
||||
}
|
||||
out = s.EncryptAndHash(out, s.s.Public)
|
||||
case MessagePatternDHEE:
|
||||
s.MixKey(s.cs.DH(s.e.Private, s.re))
|
||||
@ -234,6 +237,9 @@ func (s *HandshakeState) ReadMessage(out, message []byte) ([]byte, *CipherState,
|
||||
case MessagePatternE:
|
||||
s.re, err = s.DecryptAndHash(s.re[:0], message[:expected])
|
||||
case MessagePatternS:
|
||||
if len(s.rs) > 0 {
|
||||
panic("noise: invalid state, rs is not nil")
|
||||
}
|
||||
s.rs, err = s.DecryptAndHash(s.rs[:0], message[:expected])
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user