Commit 54d04c2f authored by Joe Kyo's avatar Joe Kyo Committed by Filippo Valsorda

crypto/tls: remove bookkeeping code from pHash function

Since copy function can figure out how many bytes of data to copy when
two slices have different length, it is not necessary to check how many
bytes need to copy each time before copying the data.

Change-Id: I5151ddfe46af5575566fe9c9a2648e111575ec3d
Reviewed-on: https://go-review.googlesource.com/71090Reviewed-by: 's avatarFilippo Valsorda <hi@filippo.io>
Run-TryBot: Filippo Valsorda <hi@filippo.io>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 622cfd88
......@@ -35,12 +35,8 @@ func pHash(result, secret, seed []byte, hash func() hash.Hash) {
h.Write(a)
h.Write(seed)
b := h.Sum(nil)
todo := len(b)
if j+todo > len(result) {
todo = len(result) - j
}
copy(result[j:j+todo], b)
j += todo
copy(result[j:], b)
j += len(b)
h.Reset()
h.Write(a)
......
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