1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:24:41 -07:00

crypto/internal/nistec: don't use go:embed

For #69536

Change-Id: I8ff3fdd70f540559d83abe006985bcee11ffde91
Reviewed-on: https://go-review.googlesource.com/c/go/+/628775
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Filippo Valsorda 2024-11-17 13:03:16 +01:00 committed by Gopher Robot
parent 8c2a04f169
commit 17bf224a4d
4 changed files with 20 additions and 20 deletions

View File

@ -9,7 +9,6 @@ package nistec
import ( import (
"crypto/internal/nistec/fiat" "crypto/internal/nistec/fiat"
"crypto/subtle" "crypto/subtle"
_ "embed"
"errors" "errors"
"internal/byteorder" "internal/byteorder"
"internal/goarch" "internal/goarch"
@ -566,23 +565,19 @@ func (table *p256AffineTable) Select(p *p256AffinePoint, n uint8) {
// table is the previous table doubled six times. Six is the width of the // table is the previous table doubled six times. Six is the width of the
// sliding window used in ScalarBaseMult, and having each table already // sliding window used in ScalarBaseMult, and having each table already
// pre-doubled lets us avoid the doublings between windows entirely. This table // pre-doubled lets us avoid the doublings between windows entirely. This table
// MUST NOT be modified, as it aliases into p256GeneratorTablesEmbed below. // aliases into p256PrecomputedEmbed.
var p256GeneratorTables *[43]p256AffineTable var p256GeneratorTables *[43]p256AffineTable
//go:embed p256_table.bin
var p256GeneratorTablesEmbed string
func init() { func init() {
p256GeneratorTablesPtr := (*unsafe.Pointer)(unsafe.Pointer(&p256GeneratorTablesEmbed)) p256GeneratorTablesPtr := unsafe.Pointer(&p256PrecomputedEmbed)
if goarch.BigEndian { if goarch.BigEndian {
var newTable [43 * 32 * 2 * 4]uint64 var newTable [43 * 32 * 2 * 4]uint64
for i, x := range (*[43 * 32 * 2 * 4][8]byte)(*p256GeneratorTablesPtr) { for i, x := range (*[43 * 32 * 2 * 4][8]byte)(p256GeneratorTablesPtr) {
newTable[i] = byteorder.LeUint64(x[:]) newTable[i] = byteorder.LeUint64(x[:])
} }
newTablePtr := unsafe.Pointer(&newTable) p256GeneratorTablesPtr = unsafe.Pointer(&newTable)
p256GeneratorTablesPtr = &newTablePtr
} }
p256GeneratorTables = (*[43]p256AffineTable)(*p256GeneratorTablesPtr) p256GeneratorTables = (*[43]p256AffineTable)(p256GeneratorTablesPtr)
} }
func boothW6(in uint64) (uint8, int) { func boothW6(in uint64) (uint8, int) {

View File

@ -15,7 +15,6 @@
package nistec package nistec
import ( import (
_ "embed"
"errors" "errors"
"internal/byteorder" "internal/byteorder"
"math/bits" "math/bits"
@ -326,23 +325,19 @@ type p256AffineTable [32]p256AffinePoint
// table is the previous table doubled six times. Six is the width of the // table is the previous table doubled six times. Six is the width of the
// sliding window used in p256ScalarBaseMult, and having each table already // sliding window used in p256ScalarBaseMult, and having each table already
// pre-doubled lets us avoid the doublings between windows entirely. This table // pre-doubled lets us avoid the doublings between windows entirely. This table
// MUST NOT be modified, as it aliases into p256PrecomputedEmbed below. // aliases into p256PrecomputedEmbed.
var p256Precomputed *[43]p256AffineTable var p256Precomputed *[43]p256AffineTable
//go:embed p256_table.bin
var p256PrecomputedEmbed string
func init() { func init() {
p256PrecomputedPtr := (*unsafe.Pointer)(unsafe.Pointer(&p256PrecomputedEmbed)) p256PrecomputedPtr := unsafe.Pointer(&p256PrecomputedEmbed)
if runtime.GOARCH == "s390x" { if runtime.GOARCH == "s390x" {
var newTable [43 * 32 * 2 * 4]uint64 var newTable [43 * 32 * 2 * 4]uint64
for i, x := range (*[43 * 32 * 2 * 4][8]byte)(*p256PrecomputedPtr) { for i, x := range (*[43 * 32 * 2 * 4][8]byte)(p256PrecomputedPtr) {
newTable[i] = byteorder.LeUint64(x[:]) newTable[i] = byteorder.LeUint64(x[:])
} }
newTablePtr := unsafe.Pointer(&newTable) p256PrecomputedPtr = unsafe.Pointer(&newTable)
p256PrecomputedPtr = &newTablePtr
} }
p256Precomputed = (*[43]p256AffineTable)(*p256PrecomputedPtr) p256Precomputed = (*[43]p256AffineTable)(p256PrecomputedPtr)
} }
// p256SelectAffine sets res to the point at index idx in the table. // p256SelectAffine sets res to the point at index idx in the table.

File diff suppressed because one or more lines are too long