summaryrefslogtreecommitdiff
path: root/libgo/go/crypto/sha256/sha256_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/crypto/sha256/sha256_test.go')
-rw-r--r--libgo/go/crypto/sha256/sha256_test.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/libgo/go/crypto/sha256/sha256_test.go b/libgo/go/crypto/sha256/sha256_test.go
index 1d883d39059..279cf5ad407 100644
--- a/libgo/go/crypto/sha256/sha256_test.go
+++ b/libgo/go/crypto/sha256/sha256_test.go
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// SHA256 hash algorithm. See FIPS 180-2.
+// SHA256 hash algorithm. See FIPS 180-2.
package sha256
import (
+ "crypto/rand"
"fmt"
"io"
"testing"
@@ -150,6 +151,18 @@ func TestBlockSize(t *testing.T) {
}
}
+// Tests that blockGeneric (pure Go) and block (in assembly for some architectures) match.
+func TestBlockGeneric(t *testing.T) {
+ gen, asm := New().(*digest), New().(*digest)
+ buf := make([]byte, BlockSize*20) // arbitrary factor
+ rand.Read(buf)
+ blockGeneric(gen, buf)
+ block(asm, buf)
+ if *gen != *asm {
+ t.Error("block and blockGeneric resulted in different states")
+ }
+}
+
var bench = New()
var buf = make([]byte, 8192)