go.crypto/sha3: fix typo; remove 4 million map lookups (5% of "go test"
time); delete some comments that didn't add much and were incorrect anyway (the test specification was tc, not t). R=jcb CC=agl, golang-dev https://golang.org/cl/7665045
This commit is contained in:
+5
-6
@@ -86,7 +86,7 @@ var shortKeccakTestVectors = []testVector{
|
|||||||
// ExtremelyLongMsgKAT taken from http://keccak.noekeon.org/.
|
// ExtremelyLongMsgKAT taken from http://keccak.noekeon.org/.
|
||||||
var longKeccakTestVectors = []testVector{
|
var longKeccakTestVectors = []testVector{
|
||||||
{
|
{
|
||||||
desc: "long-1GiB",
|
desc: "long-64MiB",
|
||||||
input: []byte("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno"),
|
input: []byte("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno"),
|
||||||
repeat: 1024 * 1024,
|
repeat: 1024 * 1024,
|
||||||
want: map[string]string{
|
want: map[string]string{
|
||||||
@@ -106,13 +106,12 @@ func TestKeccakVectors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
for alg, want := range tc.want {
|
for alg, want := range tc.want {
|
||||||
testDigests[alg].Reset()
|
d := testDigests[alg]
|
||||||
// Write input data each digests, based on the test specification t.
|
d.Reset()
|
||||||
for i := 0; i < tc.repeat; i++ {
|
for i := 0; i < tc.repeat; i++ {
|
||||||
testDigests[alg].Write(tc.input)
|
d.Write(tc.input)
|
||||||
}
|
}
|
||||||
// Verify that each algorithm version produced the expected output.
|
got := strings.ToUpper(hex.EncodeToString(d.Sum(nil)))
|
||||||
got := strings.ToUpper(hex.EncodeToString(testDigests[alg].Sum(nil)))
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("%s, alg=%s\ngot %q, want %q", tc.desc, alg, got, want)
|
t.Errorf("%s, alg=%s\ngot %q, want %q", tc.desc, alg, got, want)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user