• Russ Cox's avatar
    hash: add MarshalBinary/UnmarshalBinary round trip + golden test for all implementations · 1d547e4a
    Russ Cox authored
    There are some basic tests in the packages implementing the hashes,
    but this one is meant to be comprehensive for the standard library
    as a whole.
    
    Most importantly, it locks in the current representations and makes
    sure that they do not change from release to release (and also, as a
    result, that future releases can parse the representations generated
    by older releases).
    
    The crypto/* MarshalBinary implementations are being changed
    in this CL to write only d.x[:d.nx] to the encoding, with zeros for
    the remainder of the slice d.x[d.nx:]. The old encoding wrote the
    whole d.x, but that exposed an internal detail: whether d.x is
    cleared after a full buffer is accumulated, and also whether d.x was
    used at all for previous blocks (consider 1-byte writes vs 1024-byte writes).
    The new encoding writes only what the decoder needs to know,
    nothing more.
    
    In fact the old encodings were arguably also a security hole,
    because they exposed data written even before the most recent
    call to the Reset method, data that clearly has no impact on the
    current hash and clearly should not be exposed. The leakage
    is clearly visible in the old crypto/sha1 golden test tables also
    being modified in this CL.
    
    Change-Id: I4e9193a3ec5f91d27ce7d0aa24c19b3923741416
    Reviewed-on: https://go-review.googlesource.com/82136
    Run-TryBot: Russ Cox <rsc@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
    1d547e4a
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
context Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
plugin Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang_org/x Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
cmp.bash Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
naclmake.bash Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...