diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-14 15:41:54 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-14 15:41:54 +0000 |
commit | 7da93e24295c8b313ecdcedee0b8bde70b335e61 (patch) | |
tree | e3de46cbc89d82ca1f49843fe2e1e670db67795e /libgo/go/crypto/openpgp/s2k/s2k.go | |
parent | f86a7907050666ce7cab2890b353619f83d6c98b (diff) | |
download | ppe42-gcc-7da93e24295c8b313ecdcedee0b8bde70b335e61.tar.gz ppe42-gcc-7da93e24295c8b313ecdcedee0b8bde70b335e61.zip |
libgo: Update to weekly.2011-12-06.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182338 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/crypto/openpgp/s2k/s2k.go')
-rw-r--r-- | libgo/go/crypto/openpgp/s2k/s2k.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libgo/go/crypto/openpgp/s2k/s2k.go b/libgo/go/crypto/openpgp/s2k/s2k.go index 83673e17335..8bc0bb320bb 100644 --- a/libgo/go/crypto/openpgp/s2k/s2k.go +++ b/libgo/go/crypto/openpgp/s2k/s2k.go @@ -26,6 +26,7 @@ var zero [1]byte // 4880, section 3.7.1.2) using the given hash, input passphrase and salt. func Salted(out []byte, h hash.Hash, in []byte, salt []byte) { done := 0 + var digest []byte for i := 0; done < len(out); i++ { h.Reset() @@ -34,7 +35,8 @@ func Salted(out []byte, h hash.Hash, in []byte, salt []byte) { } h.Write(salt) h.Write(in) - n := copy(out[done:], h.Sum(nil)) + digest = h.Sum(digest[:0]) + n := copy(out[done:], digest) done += n } } @@ -52,6 +54,7 @@ func Iterated(out []byte, h hash.Hash, in []byte, salt []byte, count int) { } done := 0 + var digest []byte for i := 0; done < len(out); i++ { h.Reset() for j := 0; j < i; j++ { @@ -68,7 +71,8 @@ func Iterated(out []byte, h hash.Hash, in []byte, salt []byte, count int) { written += len(combined) } } - n := copy(out[done:], h.Sum(nil)) + digest = h.Sum(digest[:0]) + n := copy(out[done:], digest) done += n } } |