diff options
Diffstat (limited to 'libgo/go/crypto/ripemd160/ripemd160.go')
-rw-r--r-- | libgo/go/crypto/ripemd160/ripemd160.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libgo/go/crypto/ripemd160/ripemd160.go b/libgo/go/crypto/ripemd160/ripemd160.go index c128ee445a5..cd2cc39dbd1 100644 --- a/libgo/go/crypto/ripemd160/ripemd160.go +++ b/libgo/go/crypto/ripemd160/ripemd160.go @@ -83,8 +83,7 @@ func (d *digest) Write(p []byte) (nn int, err error) { func (d0 *digest) Sum(in []byte) []byte { // Make a copy of d0 so that caller can keep writing and summing. - d := new(digest) - *d = *d0 + d := *d0 // Padding. Add a 1 bit and 0 bits until 56 bytes mod 64. tc := d.tc @@ -107,11 +106,13 @@ func (d0 *digest) Sum(in []byte) []byte { panic("d.nx != 0") } - for _, s := range d.s { - in = append(in, byte(s)) - in = append(in, byte(s>>8)) - in = append(in, byte(s>>16)) - in = append(in, byte(s>>24)) + var digest [Size]byte + for i, s := range d.s { + digest[i*4] = byte(s) + digest[i*4+1] = byte(s >> 8) + digest[i*4+2] = byte(s >> 16) + digest[i*4+3] = byte(s >> 24) } - return in + + return append(in, digest[:]...) } |