|
|
@ -284,8 +284,6 @@ type symmetricState struct {
|
|
|
|
|
|
|
|
|
|
|
|
h [blake2s.Size]byte
|
|
|
|
h [blake2s.Size]byte
|
|
|
|
ck [blake2s.Size]byte
|
|
|
|
ck [blake2s.Size]byte
|
|
|
|
|
|
|
|
|
|
|
|
mixer hash.Hash // for updating h
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *symmetricState) checkFinished() {
|
|
|
|
func (s *symmetricState) checkFinished() {
|
|
|
@ -295,25 +293,21 @@ func (s *symmetricState) checkFinished() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize sets s to the initial handshake state, prior to
|
|
|
|
// Initialize sets s to the initial handshake state, prior to
|
|
|
|
// processing any Noise messages.
|
|
|
|
// processing any handshake messages.
|
|
|
|
func (s *symmetricState) Initialize() {
|
|
|
|
func (s *symmetricState) Initialize() {
|
|
|
|
s.checkFinished()
|
|
|
|
s.checkFinished()
|
|
|
|
if s.mixer != nil {
|
|
|
|
|
|
|
|
panic("symmetricState cannot be reused")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
s.h = blake2s.Sum256([]byte(protocolName))
|
|
|
|
s.h = blake2s.Sum256([]byte(protocolName))
|
|
|
|
s.ck = s.h
|
|
|
|
s.ck = s.h
|
|
|
|
s.mixer = newBLAKE2s()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MixHash updates s.h to be BLAKE2s(s.h || data), where || is
|
|
|
|
// MixHash updates s.h to be BLAKE2s(s.h || data), where || is
|
|
|
|
// concatenation.
|
|
|
|
// concatenation.
|
|
|
|
func (s *symmetricState) MixHash(data []byte) {
|
|
|
|
func (s *symmetricState) MixHash(data []byte) {
|
|
|
|
s.checkFinished()
|
|
|
|
s.checkFinished()
|
|
|
|
s.mixer.Reset()
|
|
|
|
h := newBLAKE2s()
|
|
|
|
s.mixer.Write(s.h[:])
|
|
|
|
h.Write(s.h[:])
|
|
|
|
s.mixer.Write(data)
|
|
|
|
h.Write(data)
|
|
|
|
s.mixer.Sum(s.h[:0])
|
|
|
|
h.Sum(s.h[:0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MixDH updates s.ck with the result of X25519(priv, pub) and returns
|
|
|
|
// MixDH updates s.ck with the result of X25519(priv, pub) and returns
|
|
|
|