1 // Copyright 2024 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4 5 //go:build (ppc64 || ppc64le) && !purego
6 7 package sha256
8 9 import (
10 "crypto/internal/fips140deps/godebug"
11 "crypto/internal/impl"
12 )
13 14 // The POWER architecture doesn't have a way to turn off SHA-2 support at
15 // runtime with GODEBUG=cpu.something=off, so introduce a new GODEBUG knob for
16 // that. It's intentionally only checked at init() time, to avoid the
17 // performance overhead of checking it on every block.
18 var ppc64sha2 = godebug.Value("#ppc64sha2") != "off"
19 20 func init() {
21 impl.Register("sha256", "POWER8", &ppc64sha2)
22 }
23 24 //go:noescape
25 func blockPOWER(dig *Digest, p []byte)
26 27 func block(dig *Digest, p []byte) {
28 if ppc64sha2 {
29 blockPOWER(dig, p)
30 } else {
31 blockGeneric(dig, p)
32 }
33 }
34