sha3: disable s390x assembly

It was integrated in such a way that it made devirtualization
impossible, leading to allocations on every platform.

It can be reintroduced according to AssemblyPolicy and TargetSpecific.

Updates #64897

Change-Id: I3a4edc91185c2928b2c9b80655a2bc8daa6b44e3
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/544816
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
diff --git a/sha3/hashes.go b/sha3/hashes.go
index 0d8043f..1e815c9 100644
--- a/sha3/hashes.go
+++ b/sha3/hashes.go
@@ -16,9 +16,6 @@
 // Its generic security strength is 224 bits against preimage attacks,
 // and 112 bits against collision attacks.
 func New224() hash.Hash {
-	if h := new224Asm(); h != nil {
-		return h
-	}
 	return &state{rate: 144, outputLen: 28, dsbyte: 0x06}
 }
 
@@ -26,9 +23,6 @@
 // Its generic security strength is 256 bits against preimage attacks,
 // and 128 bits against collision attacks.
 func New256() hash.Hash {
-	if h := new256Asm(); h != nil {
-		return h
-	}
 	return &state{rate: 136, outputLen: 32, dsbyte: 0x06}
 }
 
@@ -36,9 +30,6 @@
 // Its generic security strength is 384 bits against preimage attacks,
 // and 192 bits against collision attacks.
 func New384() hash.Hash {
-	if h := new384Asm(); h != nil {
-		return h
-	}
 	return &state{rate: 104, outputLen: 48, dsbyte: 0x06}
 }
 
@@ -46,9 +37,6 @@
 // Its generic security strength is 512 bits against preimage attacks,
 // and 256 bits against collision attacks.
 func New512() hash.Hash {
-	if h := new512Asm(); h != nil {
-		return h
-	}
 	return &state{rate: 72, outputLen: 64, dsbyte: 0x06}
 }
 
diff --git a/sha3/hashes_generic.go b/sha3/hashes_generic.go
deleted file mode 100644
index fe8c847..0000000
--- a/sha3/hashes_generic.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !gc || purego || !s390x
-
-package sha3
-
-import (
-	"hash"
-)
-
-// new224Asm returns an assembly implementation of SHA3-224 if available,
-// otherwise it returns nil.
-func new224Asm() hash.Hash { return nil }
-
-// new256Asm returns an assembly implementation of SHA3-256 if available,
-// otherwise it returns nil.
-func new256Asm() hash.Hash { return nil }
-
-// new384Asm returns an assembly implementation of SHA3-384 if available,
-// otherwise it returns nil.
-func new384Asm() hash.Hash { return nil }
-
-// new512Asm returns an assembly implementation of SHA3-512 if available,
-// otherwise it returns nil.
-func new512Asm() hash.Hash { return nil }
diff --git a/sha3/sha3_s390x.go b/sha3/sha3_s390x.go
index b4fbbf8..26b728b 100644
--- a/sha3/sha3_s390x.go
+++ b/sha3/sha3_s390x.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build gc && !purego
+//go:build gc && !purego && ignore
 
 package sha3
 
diff --git a/sha3/sha3_s390x.s b/sha3/sha3_s390x.s
index 826b862..df51683 100644
--- a/sha3/sha3_s390x.s
+++ b/sha3/sha3_s390x.s
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build gc && !purego
+//go:build gc && !purego && ignore
 
 #include "textflag.h"
 
diff --git a/sha3/shake.go b/sha3/shake.go
index bb69984..a31bcf8 100644
--- a/sha3/shake.go
+++ b/sha3/shake.go
@@ -115,9 +115,6 @@
 // Its generic security strength is 128 bits against all attacks if at
 // least 32 bytes of its output are used.
 func NewShake128() ShakeHash {
-	if h := newShake128Asm(); h != nil {
-		return h
-	}
 	return &state{rate: rate128, outputLen: 32, dsbyte: dsbyteShake}
 }
 
@@ -125,9 +122,6 @@
 // Its generic security strength is 256 bits against all attacks if
 // at least 64 bytes of its output are used.
 func NewShake256() ShakeHash {
-	if h := newShake256Asm(); h != nil {
-		return h
-	}
 	return &state{rate: rate256, outputLen: 64, dsbyte: dsbyteShake}
 }
 
diff --git a/sha3/shake_generic.go b/sha3/shake_generic.go
deleted file mode 100644
index 8d31cf5..0000000
--- a/sha3/shake_generic.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !gc || purego || !s390x
-
-package sha3
-
-// newShake128Asm returns an assembly implementation of SHAKE-128 if available,
-// otherwise it returns nil.
-func newShake128Asm() ShakeHash {
-	return nil
-}
-
-// newShake256Asm returns an assembly implementation of SHAKE-256 if available,
-// otherwise it returns nil.
-func newShake256Asm() ShakeHash {
-	return nil
-}