1
2
3
4
5
6
7 package sha256
8
9 import (
10 "crypto/internal/impl"
11 "internal/cpu"
12 )
13
14 var useAVX2 = cpu.X86.HasAVX2 && cpu.X86.HasBMI2
15 var useSHANI = useAVX2 && cpu.X86.HasSHA
16
17 func init() {
18 impl.Register("crypto/sha256", "AVX2", &useAVX2)
19 impl.Register("crypto/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