Skip to content

Commit

Permalink
crypto: use and test purego tag consistently
Browse files Browse the repository at this point in the history
Fixes #58636
Updates #23172

Change-Id: I578a5597f467be45a7d6fb7582b24855b2e6512b
Reviewed-on: https://go-review.googlesource.com/c/go/+/561935
Reviewed-by: Roland Shoemaker <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Auto-Submit: Filippo Valsorda <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
FiloSottile authored and gopherbot committed Mar 4, 2024
1 parent dff3a00 commit 8a57cc8
Show file tree
Hide file tree
Showing 81 changed files with 194 additions and 38 deletions.
8 changes: 8 additions & 0 deletions src/cmd/dist/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,14 @@ func (t *tester) registerTests() {
})
}

// Check that all crypto packages compile with the purego build tag.
t.registerTest("crypto with tag purego", &goTest{
variant: "purego",
tags: []string{"purego"},
pkg: "crypto/...",
runTests: "^$", // only ensure they compile
})

// Test ios/amd64 for the iOS simulator.
if goos == "darwin" && goarch == "amd64" && t.cgoEnabled {
t.registerTest("GOOS=ios on darwin/amd64",
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/aes/aes_gcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build amd64 || arm64
//go:build (amd64 || arm64) && !purego

package aes

Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/asm_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

#include "textflag.h"

// func encryptBlockAsm(nr int, xk *uint32, dst, src *byte)
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/asm_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

#include "textflag.h"
DATA rotInvSRows<>+0x00(SB)/8, $0x080f0205040b0e01
DATA rotInvSRows<>+0x08(SB)/8, $0x00070a0d0c030609
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/aes/asm_ppc64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build ppc64 || ppc64le
//go:build (ppc64 || ppc64le) && !purego

// Based on CRYPTOGAMS code with the following comment:
// # ====================================================================
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/asm_s390x.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

#include "textflag.h"

// func cryptBlocks(c code, key, dst, src *byte, length int)
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/aes/cbc_ppc64x.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build ppc64 || ppc64le
//go:build (ppc64 || ppc64le) && !purego

package aes

Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/cbc_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

package aes

import (
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/aes/cipher_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build amd64 || arm64 || ppc64 || ppc64le
//go:build (amd64 || arm64 || ppc64 || ppc64le) && !purego

package aes

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/aes/cipher_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !amd64 && !s390x && !ppc64 && !ppc64le && !arm64
//go:build (!amd64 && !s390x && !ppc64 && !ppc64le && !arm64) || purego

package aes

Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/cipher_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

package aes

import (
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/ctr_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

package aes

import (
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/gcm_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

// This is an optimized implementation of AES-GCM using AES-NI and CLMUL-NI
// The implementation uses some optimization as described in:
// [1] Gueron, S., Kounavis, M.E.: Intel® Carry-Less Multiplication
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/gcm_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

#include "textflag.h"

#define B0 V0
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/aes/gcm_ppc64x.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build ppc64le || ppc64
//go:build (ppc64le || ppc64) && !purego

package aes

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/aes/gcm_ppc64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build ppc64 || ppc64le
//go:build (ppc64 || ppc64le) && !purego

// Portions based on CRYPTOGAMS code with the following comment:
// # ====================================================================
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/aes/gcm_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

package aes

import (
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/ecdsa/ecdsa_noasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !s390x
//go:build !s390x || purego

package ecdsa

Expand Down
2 changes: 2 additions & 0 deletions src/crypto/ecdsa/ecdsa_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

package ecdsa

import (
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/ecdsa/ecdsa_s390x.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

#include "textflag.h"

// func kdsa(fc uint64, params *[4096]byte) (errn uint64)
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/ecdsa/ecdsa_s390x_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build s390x
//go:build s390x && !purego

package ecdsa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

func main() {
Package("crypto/internal/edwards25519/field")
ConstraintExpr("amd64,gc,!purego")
ConstraintExpr("!purego")
feMul()
feSquare()
Generate()
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/edwards25519/field/fe_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/crypto/internal/edwards25519/field/fe_amd64.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT.

//go:build amd64 && gc && !purego
//go:build !purego

#include "textflag.h"

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/edwards25519/field/fe_amd64_noasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !amd64 || !gc || purego
//go:build !amd64 || purego

package field

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/edwards25519/field/fe_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build arm64 && gc && !purego
//go:build !purego

package field

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/edwards25519/field/fe_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build arm64 && gc && !purego
//go:build !purego

#include "textflag.h"

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/edwards25519/field/fe_arm64_noasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !arm64 || !gc || purego
//go:build !arm64 || purego

package field

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/nistec/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var curves = []struct {
P: "P256",
Element: "fiat.P256Element",
Params: elliptic.P256().Params(),
BuildTags: "!amd64 && !arm64 && !ppc64le && !s390x",
BuildTags: "(!amd64 && !arm64 && !ppc64le && !s390x) || purego",
},
{
P: "P384",
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/nistec/p256.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/crypto/internal/nistec/p256_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// https://link.springer.com/article/10.1007%2Fs13389-014-0090-x
// https://eprint.iacr.org/2013/816.pdf

//go:build amd64 || arm64 || ppc64le || s390x
//go:build (amd64 || arm64 || ppc64le || s390x) && !purego

package nistec

Expand Down
2 changes: 2 additions & 0 deletions src/crypto/internal/nistec/p256_asm_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

// This file contains constant-time, 64-bit assembly implementation of
// P256. The optimizations performed here are described in detail in:
// S.Gueron and V.Krasnov, "Fast prime field elliptic-curve cryptography with
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/internal/nistec/p256_asm_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

// This file contains constant-time, 64-bit assembly implementation of
// P256. The optimizations performed here are described in detail in:
// S.Gueron and V.Krasnov, "Fast prime field elliptic-curve cryptography with
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/internal/nistec/p256_asm_ppc64le.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

#include "textflag.h"

// This is a port of the s390x asm implementation.
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/internal/nistec/p256_asm_s390x.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !purego

#include "textflag.h"
#include "go_asm.h"

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/nistec/p256_asm_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build amd64 || arm64 || ppc64le || s390x
//go:build !purego && (amd64 || arm64 || ppc64le || s390x)

package nistec

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/nistec/p256_ordinv.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build amd64 || arm64
//go:build (amd64 || arm64) && !purego

package nistec

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/nistec/p256_ordinv_noasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !amd64 && !arm64
//go:build (!amd64 && !arm64) || purego

package nistec

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/nistec/p256_ordinv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build amd64 || arm64
//go:build (amd64 || arm64) && !purego

package nistec_test

Expand Down
2 changes: 2 additions & 0 deletions src/crypto/md5/md5block_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// #defines generating 8a assembly, and adjusted for 386,
// by the Go Authors.

//go:build !purego

#include "textflag.h"

// MD5 optimized for AMD64.
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/md5/md5block_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Translated from Perl generating GNU assembly into
// #defines generating 6a assembly by the Go Authors.

//go:build !purego

#include "textflag.h"

// MD5 optimized for AMD64.
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/md5/md5block_arm.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//
// ARM version of md5block.go

//go:build !purego

#include "textflag.h"

// Register definitions
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/md5/md5block_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// ARM64 version of md5block.go
// derived from crypto/md5/md5block_amd64.s

//go:build !purego

#include "textflag.h"

TEXT ·block(SB),NOSPLIT,$0-32
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/md5/md5block_decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build amd64 || 386 || arm || ppc64le || ppc64 || s390x || arm64
//go:build (amd64 || 386 || arm || ppc64le || ppc64 || s390x || arm64) && !purego

package md5

Expand Down
Loading

0 comments on commit 8a57cc8

Please sign in to comment.