1
2
3
4
5
6
7 package sha256
8
9 import (
10 "crypto/internal/fips140deps/cpu"
11 "crypto/internal/impl"
12 )
13
14 var useAVX2 = cpu.X86HasAVX && cpu.X86HasAVX2 && cpu.X86HasBMI2
15 var useSHANI = cpu.X86HasAVX && cpu.X86HasSHA && cpu.X86HasSSE41 && cpu.X86HasSSSE3
16
17 func init() {
18 impl.Register("sha256", "AVX2", &useAVX2)
19 impl.Register("sha256", "SHA-NI", &useSHANI)
20 }
21
22
23 func blockAMD64(dig *Digest, p []byte)
24
25
26 func blockAVX2(dig *Digest, p []byte)
27
28
29 func blockSHANI(dig *Digest, p []byte)
30
31 func block(dig *Digest, p []byte) {
32 if useSHANI {
33 blockSHANI(dig, p)
34 } else if useAVX2 {
35 blockAVX2(dig, p)
36 } else {
37 blockAMD64(dig, p)
38 }
39 }
40
View as plain text