go version)?go version devel +39d4178 Wed Jul 31 05:45:43 2019 +0000 linux/amd64
Yes
go env)?GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jhg/.cache/go-build"
GOENV="/home/jhg/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jhg/cfmbed/cryptofuzz/modules/golang/test/go/packages"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/jhg/cfmbed/cryptofuzz/modules/golang/test/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jhg/cfmbed/cryptofuzz/modules/golang/test/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build882554262=/tmp/go-build -gno-record-gcc-switches"
https://play.golang.org/p/PiX7cpLO5er
Compare:
echo -en "\x00" | openssl ripemd160
Found with Cryptofuzz https://github.com/guidovranken/cryptofuzz
Thank you for this report @guidovranken!
I shall ping some cryptography experts @FiloSottile @agl @veorq to take a look.
You鈥檙e holding it wrong. Take a look at the hash.Hash docs and this playground link: https://play.golang.org/p/5JWW7P4L7lJ.
Ahh. Sorry for the false positive.
Thank you @tmthrgd!
@guidovranken in deed, you need to firstly write
h.Write([]byte("\x00"))
and then for the final checksum
h.Sum(nil)
otherwise by passing in []byte{0x00} to h.Sum you are asking it to append those bytes to the current hash and return the resulting slice
// Sum appends the current hash to b and returns the resulting slice.
// It does not change the underlying hash state.
Sum(b []byte) []byte
as @tmthrgd linked.
Most helpful comment
Thank you @tmthrgd!
@guidovranken in deed, you need to firstly write
and then for the final checksum
otherwise by passing in
[]byte{0x00}toh.Sumyou are asking it to append those bytes to the current hash and return the resulting sliceas @tmthrgd linked.