Commit 3994762c authored by Jeromy's avatar Jeromy

fix bug

parent 317ca2f8
......@@ -275,7 +275,6 @@ func (s *SecurePipe) handleSecureOut(hashType string, mIV, mCKey, mMKey []byte)
myMac, macSize := makeMac(hashType, mMKey)
basebuf := make([]byte, 1<<22)
for {
var data []byte
ok := true
......@@ -295,23 +294,19 @@ func (s *SecurePipe) handleSecureOut(hashType string, mIV, mCKey, mMKey []byte)
continue
}
buff := basebuf[:len(data)+macSize]
buff := make([]byte, len(data)+macSize)
encData(data, buff, myCipher, myMac)
myCipher.XORKeyStream(buff, data)
myMac.Write(buff[0:len(data)])
copy(buff[len(data):], myMac.Sum(nil))
myMac.Reset()
// log.Debug("[peer %s] secure out [to = %s] %d", s.local, s.remote, len(buff))
s.insecure.Out <- buff
}
}
func encData(data, buff []byte, ciph cipher.Stream, mac hash.Hash) {
ciph.XORKeyStream(buff, data)
mac.Write(buff[0:len(data)])
copy(buff[len(data):], mac.Sum(nil))
mac.Reset()
}
// Determines which algorithm to use. Note: f(a, b) = f(b, a)
func selectBest(myPrefs, theirPrefs string) (string, error) {
// Person with greatest hash gets first choice.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment