summaryrefslogtreecommitdiff
path: root/libgo/go/crypto/hmac/hmac.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/crypto/hmac/hmac.go')
-rw-r--r--libgo/go/crypto/hmac/hmac.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/libgo/go/crypto/hmac/hmac.go b/libgo/go/crypto/hmac/hmac.go
index deaceafb260..6e7dd8762c8 100644
--- a/libgo/go/crypto/hmac/hmac.go
+++ b/libgo/go/crypto/hmac/hmac.go
@@ -49,14 +49,13 @@ func (h *hmac) tmpPad(xor byte) {
}
func (h *hmac) Sum(in []byte) []byte {
- sum := h.inner.Sum(nil)
+ origLen := len(in)
+ in = h.inner.Sum(in)
h.tmpPad(0x5c)
- for i, b := range sum {
- h.tmp[padSize+i] = b
- }
+ copy(h.tmp[padSize:], in[origLen:])
h.outer.Reset()
h.outer.Write(h.tmp)
- return h.outer.Sum(in)
+ return h.outer.Sum(in[:origLen])
}
func (h *hmac) Write(p []byte) (n int, err error) {