mirror of
https://github.com/golang/go
synced 2024-11-21 17:14:45 -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:
parent
8c2a04f169
commit
17bf224a4d
@ -9,7 +9,6 @@ package nistec
|
||||
import (
|
||||
"crypto/internal/nistec/fiat"
|
||||
"crypto/subtle"
|
||||
_ "embed"
|
||||
"errors"
|
||||
"internal/byteorder"
|
||||
"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
|
||||
// sliding window used in ScalarBaseMult, and having each table already
|
||||
// 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
|
||||
|
||||
//go:embed p256_table.bin
|
||||
var p256GeneratorTablesEmbed string
|
||||
|
||||
func init() {
|
||||
p256GeneratorTablesPtr := (*unsafe.Pointer)(unsafe.Pointer(&p256GeneratorTablesEmbed))
|
||||
p256GeneratorTablesPtr := unsafe.Pointer(&p256PrecomputedEmbed)
|
||||
if goarch.BigEndian {
|
||||
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[:])
|
||||
}
|
||||
newTablePtr := unsafe.Pointer(&newTable)
|
||||
p256GeneratorTablesPtr = &newTablePtr
|
||||
p256GeneratorTablesPtr = unsafe.Pointer(&newTable)
|
||||
}
|
||||
p256GeneratorTables = (*[43]p256AffineTable)(*p256GeneratorTablesPtr)
|
||||
p256GeneratorTables = (*[43]p256AffineTable)(p256GeneratorTablesPtr)
|
||||
}
|
||||
|
||||
func boothW6(in uint64) (uint8, int) {
|
||||
|
@ -15,7 +15,6 @@
|
||||
package nistec
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"errors"
|
||||
"internal/byteorder"
|
||||
"math/bits"
|
||||
@ -326,23 +325,19 @@ type p256AffineTable [32]p256AffinePoint
|
||||
// table is the previous table doubled six times. Six is the width of the
|
||||
// sliding window used in p256ScalarBaseMult, and having each table already
|
||||
// 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
|
||||
|
||||
//go:embed p256_table.bin
|
||||
var p256PrecomputedEmbed string
|
||||
|
||||
func init() {
|
||||
p256PrecomputedPtr := (*unsafe.Pointer)(unsafe.Pointer(&p256PrecomputedEmbed))
|
||||
p256PrecomputedPtr := unsafe.Pointer(&p256PrecomputedEmbed)
|
||||
if runtime.GOARCH == "s390x" {
|
||||
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[:])
|
||||
}
|
||||
newTablePtr := unsafe.Pointer(&newTable)
|
||||
p256PrecomputedPtr = &newTablePtr
|
||||
p256PrecomputedPtr = unsafe.Pointer(&newTable)
|
||||
}
|
||||
p256Precomputed = (*[43]p256AffineTable)(*p256PrecomputedPtr)
|
||||
p256Precomputed = (*[43]p256AffineTable)(p256PrecomputedPtr)
|
||||
}
|
||||
|
||||
// p256SelectAffine sets res to the point at index idx in the table.
|
||||
|
Binary file not shown.
10
src/crypto/internal/nistec/p256_table.go
Normal file
10
src/crypto/internal/nistec/p256_table.go
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user