]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/internal/bigmod: move to crypto/internal/fips/bigmod
authorFilippo Valsorda <filippo@golang.org>
Sat, 16 Nov 2024 13:14:21 +0000 (14:14 +0100)
committerGopher Robot <gobot@golang.org>
Tue, 19 Nov 2024 23:01:42 +0000 (23:01 +0000)
For #69536

Change-Id: Ic096282c521958083d0ba816d62d908f6fcf7dbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/628676
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Bypass: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
21 files changed:
src/crypto/ecdsa/ecdsa.go
src/crypto/ecdsa/ecdsa_test.go
src/crypto/internal/fips/bigmod/_asm/go.mod [moved from src/crypto/internal/bigmod/_asm/go.mod with 86% similarity]
src/crypto/internal/fips/bigmod/_asm/go.sum [moved from src/crypto/internal/bigmod/_asm/go.sum with 100% similarity]
src/crypto/internal/fips/bigmod/_asm/nat_amd64_asm.go [moved from src/crypto/internal/bigmod/_asm/nat_amd64_asm.go with 98% similarity]
src/crypto/internal/fips/bigmod/nat.go [moved from src/crypto/internal/bigmod/nat.go with 99% similarity]
src/crypto/internal/fips/bigmod/nat_386.s [moved from src/crypto/internal/bigmod/nat_386.s with 100% similarity]
src/crypto/internal/fips/bigmod/nat_amd64.s [moved from src/crypto/internal/bigmod/nat_amd64.s with 100% similarity]
src/crypto/internal/fips/bigmod/nat_arm.s [moved from src/crypto/internal/bigmod/nat_arm.s with 100% similarity]
src/crypto/internal/fips/bigmod/nat_arm64.s [moved from src/crypto/internal/bigmod/nat_arm64.s with 100% similarity]
src/crypto/internal/fips/bigmod/nat_asm.go [moved from src/crypto/internal/bigmod/nat_asm.go with 81% similarity]
src/crypto/internal/fips/bigmod/nat_loong64.s [moved from src/crypto/internal/bigmod/nat_loong64.s with 97% similarity]
src/crypto/internal/fips/bigmod/nat_noasm.go [moved from src/crypto/internal/bigmod/nat_noasm.go with 100% similarity]
src/crypto/internal/fips/bigmod/nat_ppc64x.s [moved from src/crypto/internal/bigmod/nat_ppc64x.s with 100% similarity]
src/crypto/internal/fips/bigmod/nat_riscv64.s [moved from src/crypto/internal/bigmod/nat_riscv64.s with 100% similarity]
src/crypto/internal/fips/bigmod/nat_s390x.s [moved from src/crypto/internal/bigmod/nat_s390x.s with 100% similarity]
src/crypto/internal/fips/bigmod/nat_test.go [moved from src/crypto/internal/bigmod/nat_test.go with 100% similarity]
src/crypto/internal/fips/bigmod/nat_wasm.go [moved from src/crypto/internal/bigmod/nat_wasm.go with 100% similarity]
src/crypto/internal/fipsdeps/cpu/cpu.go
src/crypto/rsa/rsa.go
src/go/build/deps_test.go

index 45215abed0301730715fa30d4c3b6b933b0e64a9..0973f8209847038ef6088627161d27ae8df10caf 100644 (file)
@@ -30,9 +30,9 @@ import (
        "crypto/cipher"
        "crypto/ecdh"
        "crypto/elliptic"
-       "crypto/internal/bigmod"
        "crypto/internal/boring"
        "crypto/internal/boring/bbig"
+       "crypto/internal/fips/bigmod"
        "crypto/internal/fips/nistec"
        "crypto/internal/randutil"
        "crypto/sha512"
index ae9fd81f93173662faaa31610a347e2c65b89441..25ccc52dad51b4d10dae899f36e96cf40e34e12d 100644 (file)
@@ -9,7 +9,7 @@ import (
        "bytes"
        "compress/bzip2"
        "crypto/elliptic"
-       "crypto/internal/bigmod"
+       "crypto/internal/fips/bigmod"
        "crypto/rand"
        "crypto/sha1"
        "crypto/sha256"
similarity index 86%
rename from src/crypto/internal/bigmod/_asm/go.mod
rename to src/crypto/internal/fips/bigmod/_asm/go.mod
index 7600a4abbe13ce0b3defa6ff4afdece13bf36e71..2193dc80d9c4b36015efab9b53897001472d64bd 100644 (file)
@@ -1,4 +1,4 @@
-module std/crypto/internal/bigmod/_asm
+module std/crypto/internal/fips/bigmod/_asm
 
 go 1.19
 
similarity index 98%
rename from src/crypto/internal/bigmod/_asm/nat_amd64_asm.go
rename to src/crypto/internal/fips/bigmod/_asm/nat_amd64_asm.go
index bf64565d5c9fc84a7a09fb12fe30f6a47e9bb7ba..8c1bedcc782e18a004d1068223222f831ba887ab 100644 (file)
@@ -15,7 +15,7 @@ import (
 //go:generate go run . -out ../nat_amd64.s -pkg bigmod
 
 func main() {
-       Package("crypto/internal/bigmod")
+       Package("crypto/internal/fips/bigmod")
        ConstraintExpr("!purego")
 
        addMulVVW(1024)
similarity index 99%
rename from src/crypto/internal/bigmod/nat.go
rename to src/crypto/internal/fips/bigmod/nat.go
index 7bd09b37ac90216eeb82be32ce99ec7bb377fa7b..49000f1e74338264c8fae68c0c64e52ce711283e 100644 (file)
@@ -5,8 +5,8 @@
 package bigmod
 
 import (
+       "crypto/internal/fipsdeps/byteorder"
        "errors"
-       "internal/byteorder"
        "math/bits"
 )
 
@@ -179,9 +179,9 @@ func (x *Nat) SetOverflowingBytes(b []byte, m *Modulus) (*Nat, error) {
 // big-endian encoded uint value.
 func bigEndianUint(buf []byte) uint {
        if _W == 64 {
-               return uint(byteorder.BeUint64(buf))
+               return uint(byteorder.BEUint64(buf))
        }
-       return uint(byteorder.BeUint32(buf))
+       return uint(byteorder.BEUint32(buf))
 }
 
 func (x *Nat) setBytes(b []byte) error {
similarity index 81%
rename from src/crypto/internal/bigmod/nat_asm.go
rename to src/crypto/internal/fips/bigmod/nat_asm.go
index dd5419cb91b11bc5f739ff851beb84e5fa96bf90..78ee32ac096dd93f9db1b357ac19b972b55b5da9 100644 (file)
@@ -6,7 +6,10 @@
 
 package bigmod
 
-import "internal/cpu"
+import (
+       "crypto/internal/fipsdeps/cpu"
+       "crypto/internal/impl"
+)
 
 // amd64 assembly uses ADCX/ADOX/MULX if ADX is available to run two carry
 // chains in the flags in parallel across the whole operation, and aggressively
@@ -16,7 +19,13 @@ import "internal/cpu"
 // amd64 without ADX, perform better than the compiler output.
 // TODO(filippo): file cmd/compile performance issue.
 
-var supportADX = cpu.X86.HasADX && cpu.X86.HasBMI2
+var supportADX = cpu.X86HasADX && cpu.X86HasBMI2
+
+func init() {
+       if cpu.AMD64 {
+               impl.Register("aes", "ADX", &supportADX)
+       }
+}
 
 //go:noescape
 func addMulVVW1024(z, x *uint, y uint) (c uint)
similarity index 97%
rename from src/crypto/internal/bigmod/nat_loong64.s
rename to src/crypto/internal/fips/bigmod/nat_loong64.s
index 3423bd0b176380a8ac2901b451b29a60c6d624db..d88deb65b1fbecb122ce838f5ad502ba2d90cd64 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// derived from crypto/internal/bigmod/nat_riscv64.s
+// derived from crypto/internal/fips/bigmod/nat_riscv64.s
 
 //go:build !purego
 
index a2b200b782ef49f29e4e1567be03ae3d4d3bb6f7..3ad35f5e9ebf4956f9948c79bd79ec3c57ce457a 100644 (file)
@@ -28,6 +28,7 @@ var S390XHasSHA256 = cpu.S390X.HasSHA256
 var S390XHasSHA3 = cpu.S390X.HasSHA3
 var S390XHasSHA512 = cpu.S390X.HasSHA512
 var X86HasAES = cpu.X86.HasAES
+var X86HasADX = cpu.X86.HasADX
 var X86HasAVX = cpu.X86.HasAVX
 var X86HasAVX2 = cpu.X86.HasAVX2
 var X86HasBMI2 = cpu.X86.HasBMI2
index 3764e0212781804ef4b9876a63277eff0d83fb35..24768563829b599fb60fd4bcc2e39b86c17d69b2 100644 (file)
@@ -26,9 +26,9 @@ package rsa
 
 import (
        "crypto"
-       "crypto/internal/bigmod"
        "crypto/internal/boring"
        "crypto/internal/boring/bbig"
+       "crypto/internal/fips/bigmod"
        "crypto/internal/randutil"
        "crypto/rand"
        "crypto/subtle"
index b762fd79e1596132502fda662d8df00028d97a35..6babcce406676fbf1b8d476ae39bd33f6a8e574e 100644 (file)
@@ -475,6 +475,7 @@ var depsRules = `
        < crypto/internal/fips/ssh
        < crypto/internal/fips/tls12
        < crypto/internal/fips/tls13
+       < crypto/internal/fips/bigmod
        < crypto/internal/fips/nistec/fiat
        < crypto/internal/fips/nistec
        < crypto/internal/fips/ecdh
@@ -539,7 +540,6 @@ var depsRules = `
        < encoding/asn1
        < golang.org/x/crypto/cryptobyte/asn1
        < golang.org/x/crypto/cryptobyte
-       < crypto/internal/bigmod
        < crypto/dsa, crypto/elliptic, crypto/rsa
        < crypto/ecdsa
        < CRYPTO-MATH;