Skip to content

Commit

Permalink
change interface{} to any, and remove "+build" build tag #77
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Nov 9, 2023
1 parent 79765c7 commit 17a3dd8
Show file tree
Hide file tree
Showing 113 changed files with 41 additions and 145 deletions.
1 change: 0 additions & 1 deletion cipher/xts_amd64.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion cipher/xts_arm64.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build arm64 && !purego
// +build arm64,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion cipher/xts_asm.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build (amd64 && !purego) || (arm64 && !purego)
// +build amd64,!purego arm64,!purego

package cipher

Expand Down
1 change: 0 additions & 1 deletion cipher/xts_asm_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build (amd64 && !purego) || (arm64 && !purego)
// +build amd64,!purego arm64,!purego

package cipher

Expand Down
1 change: 0 additions & 1 deletion cipher/xts_generic.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !amd64 && !arm64 || purego
// +build !amd64,!arm64 purego

package cipher

Expand Down
1 change: 0 additions & 1 deletion internal/bigmod/nat_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !purego
// +build !purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/bigmod/nat_amd64.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Code generated by command: go run nat_amd64_asm.go -out ../nat_amd64.s -pkg bigmod. DO NOT EDIT.

//go:build !purego
// +build !purego

// func addMulVVW256(z *uint, x *uint, y uint) (c uint)
// Requires: ADX, BMI2
Expand Down
1 change: 0 additions & 1 deletion internal/bigmod/nat_arm.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !purego
// +build !purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/bigmod/nat_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !purego
// +build !purego

#include "textflag.h"

Expand Down
2 changes: 0 additions & 2 deletions internal/bigmod/nat_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// license that can be found in the LICENSE file.

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

package bigmod

Expand Down
1 change: 0 additions & 1 deletion internal/bigmod/nat_noasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

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

package bigmod

Expand Down
2 changes: 0 additions & 2 deletions internal/bigmod/nat_ppc64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// license that can be found in the LICENSE file.

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

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/bigmod/nat_s390x.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !purego
// +build !purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/fiat/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

package main

Expand Down
4 changes: 1 addition & 3 deletions internal/sm2ec/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

package main

Expand Down Expand Up @@ -71,7 +70,7 @@ func main() {
}
defer f.Close()
buf := &bytes.Buffer{}
if err := t.Execute(buf, map[string]interface{}{
if err := t.Execute(buf, map[string]any{
"P": c.P, "p": p, "B": B, "Gx": Gx, "Gy": Gy,
"Element": c.Element, "ElementLen": elementLen,
"BuildTags": c.BuildTags,
Expand Down Expand Up @@ -134,7 +133,6 @@ const tmplNISTEC = `// Copyright 2022 The Go Authors. All rights reserved.
{{ if .BuildTags }}
//go:build {{ .BuildTags }}
// +build {{ .BuildTags }}
{{ end }}
package sm2ec
Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/p256_asm_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// https://link.springer.com/article/10.1007%2Fs13389-014-0090-x
// https://eprint.iacr.org/2013/816.pdf
//go:build amd64 && !purego && !plugin
// +build amd64,!purego,!plugin

#include "textflag.h"
#include "p256_macros_amd64.s"
Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/p256_asm_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// http://link.springer.com/article/10.1007%2Fs13389-014-0090-x
// https://eprint.iacr.org/2013/816.pdf
//go:build arm64 && !purego
// +build arm64,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/p256_asm_ord.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build (amd64 && !purego) || (arm64 && !purego)
// +build amd64,!purego arm64,!purego

package sm2ec

Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/p256_asm_table_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build (amd64 && !purego && !plugin) || (arm64 && !purego)
// +build amd64,!purego,!plugin arm64,!purego

package sm2ec

Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/p256_common_amd64.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/p256_plugin_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// https://link.springer.com/article/10.1007%2Fs13389-014-0090-x
// https://eprint.iacr.org/2013/816.pdf
//go:build amd64 && !purego && plugin
// +build amd64,!purego,plugin

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/sm2p256.go

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

1 change: 0 additions & 1 deletion internal/sm2ec/sm2p256_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// https://link.springer.com/article/10.1007%2Fs13389-014-0090-x
// https://eprint.iacr.org/2013/816.pdf
//go:build (amd64 && !purego) || (arm64 && !purego)
// +build amd64,!purego arm64,!purego

package sm2ec

Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/sm2p256_asm_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build (amd64 && !purego) || (arm64 && !purego)
// +build amd64,!purego arm64,!purego

package sm2ec

Expand Down
1 change: 0 additions & 1 deletion internal/sm2ec/sm2p256_ord.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build (!amd64 && !arm64) || purego
// +build !amd64,!arm64 purego

package sm2ec

Expand Down
1 change: 0 additions & 1 deletion internal/subtle/xor_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//
//go:build amd64 && !purego
// +build amd64,!purego

package subtle

Expand Down
1 change: 0 additions & 1 deletion internal/subtle/xor_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/subtle/xor_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//
//go:build arm64 && !purego
// +build arm64,!purego

package subtle

Expand Down
1 change: 0 additions & 1 deletion internal/subtle/xor_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//
//go:build arm64 && !purego
// +build arm64,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion internal/subtle/xor_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//
//go:build !amd64 && !arm64 || purego
// +build !amd64,!arm64 purego

package subtle

Expand Down
2 changes: 1 addition & 1 deletion pkcs7/ber.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,6 @@ func isIndefiniteTermination(ber []byte, offset int) (bool, error) {
return bytes.Index(ber[offset:], []byte{0x0, 0x0}) == 0, nil
}

func debugprint(format string, a ...interface{}) {
func debugprint(format string, a ...any) {
//fmt.Printf(format, a)
}
10 changes: 5 additions & 5 deletions pkcs7/pkcs7.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type PKCS7 struct {
Certificates []*smx509.Certificate
CRLs []pkix.CertificateList
Signers []signerInfo
raw interface{}
raw any
}

type contentInfo struct {
Expand Down Expand Up @@ -152,7 +152,7 @@ func getDigestOIDForSignatureAlgorithm(digestAlg x509.SignatureAlgorithm) (asn1.

// getOIDForEncryptionAlgorithm takes the public or private key type of the signer and
// the OID of a digest algorithm to return the appropriate signerInfo.DigestEncryptionAlgorithm
func getOIDForEncryptionAlgorithm(pkey interface{}, OIDDigestAlg asn1.ObjectIdentifier) (asn1.ObjectIdentifier, error) {
func getOIDForEncryptionAlgorithm(pkey any, OIDDigestAlg asn1.ObjectIdentifier) (asn1.ObjectIdentifier, error) {
switch k := pkey.(type) {
case *rsa.PrivateKey, *rsa.PublicKey:
switch {
Expand Down Expand Up @@ -269,16 +269,16 @@ func isCertMatchForIssuerAndSerial(cert *smx509.Certificate, ias issuerAndSerial
// `encoding/asn1`
type Attribute struct {
Type asn1.ObjectIdentifier
Value interface{}
Value any
}

type attributes struct {
types []asn1.ObjectIdentifier
values []interface{}
values []any
}

// Add adds the attribute, maintaining insertion order
func (attrs *attributes) Add(attrType asn1.ObjectIdentifier, value interface{}) {
func (attrs *attributes) Add(attrType asn1.ObjectIdentifier, value any) {
attrs.types = append(attrs.types, attrType)
attrs.values = append(attrs.values, value)
}
Expand Down
4 changes: 2 additions & 2 deletions pkcs7/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (p7 *PKCS7) GetOnlySigner() *smx509.Certificate {
}

// UnmarshalSignedAttribute decodes a single attribute from the signer info
func (p7 *PKCS7) UnmarshalSignedAttribute(attributeType asn1.ObjectIdentifier, out interface{}) error {
func (p7 *PKCS7) UnmarshalSignedAttribute(attributeType asn1.ObjectIdentifier, out any) error {
sd, ok := p7.raw.(signedData)
if !ok {
return errors.New("pkcs7: payload is not signedData content")
Expand Down Expand Up @@ -278,7 +278,7 @@ func getCertFromCertsByIssuerAndSerial(certs []*smx509.Certificate, ias issuerAn
return nil
}

func unmarshalAttribute(attrs []attribute, attributeType asn1.ObjectIdentifier, out interface{}) error {
func unmarshalAttribute(attrs []attribute, attributeType asn1.ObjectIdentifier, out any) error {
for _, attr := range attrs {
if attr.Type.Equal(attributeType) {
_, err := asn1.Unmarshal(attr.Value.Bytes, out)
Expand Down
8 changes: 4 additions & 4 deletions pkcs8/pkcs8.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func parseKeyDerivationFunc(keyDerivationFunc pkix.AlgorithmIdentifier) (KDFPara
// ParsePrivateKey parses a DER-encoded PKCS#8 private key.
// Password can be nil.
// This is equivalent to ParsePKCS8PrivateKey.
func ParsePrivateKey(der []byte, password []byte) (interface{}, KDFParameters, error) {
func ParsePrivateKey(der []byte, password []byte) (any, KDFParameters, error) {
// No password provided, assume the private key is unencrypted
if len(password) == 0 {
privateKey, err := smx509.ParsePKCS8PrivateKey(der)
Expand Down Expand Up @@ -198,7 +198,7 @@ func ParsePrivateKey(der []byte, password []byte) (interface{}, KDFParameters, e

// MarshalPrivateKey encodes a private key into DER-encoded PKCS#8 with the given options.
// Password can be nil.
func MarshalPrivateKey(priv interface{}, password []byte, opts *Opts) ([]byte, error) {
func MarshalPrivateKey(priv any, password []byte, opts *Opts) ([]byte, error) {
if len(password) == 0 {
return smx509.MarshalPKCS8PrivateKey(priv)
}
Expand Down Expand Up @@ -262,7 +262,7 @@ func MarshalPrivateKey(priv interface{}, password []byte, opts *Opts) ([]byte, e

// ParsePKCS8PrivateKey parses encrypted/unencrypted private keys in PKCS#8 format.
// To parse encrypted private keys, a password of []byte type should be provided to the function as the second parameter.
func ParsePKCS8PrivateKey(der []byte, v ...[]byte) (interface{}, error) {
func ParsePKCS8PrivateKey(der []byte, v ...[]byte) (any, error) {
var password []byte
if len(v) > 0 {
password = v[0]
Expand Down Expand Up @@ -371,7 +371,7 @@ func ParseSM9EncryptPrivateKey(der []byte, v ...[]byte) (*sm9.EncryptPrivateKey,

// ConvertPrivateKeyToPKCS8 converts the private key into PKCS#8 format.
// To encrypt the private key, the password of []byte type should be provided as the second parameter.
func ConvertPrivateKeyToPKCS8(priv interface{}, v ...[]byte) ([]byte, error) {
func ConvertPrivateKeyToPKCS8(priv any, v ...[]byte) ([]byte, error) {
var password []byte
if len(v) > 0 {
password = v[0]
Expand Down
1 change: 0 additions & 1 deletion pkcs8/pkcs8_norace_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !race
// +build !race

package pkcs8_test

Expand Down
2 changes: 1 addition & 1 deletion sm2/sm2.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ func hashToNat(c *sm2Curve, e *bigmod.Nat, hash []byte) {
}

// IsSM2PublicKey check if given public key is a SM2 public key or not
func IsSM2PublicKey(publicKey interface{}) bool {
func IsSM2PublicKey(publicKey any) bool {
pub, ok := publicKey.(*ecdsa.PublicKey)
return ok && pub.Curve == sm2ec.P256()
}
Expand Down
2 changes: 0 additions & 2 deletions sm3/gen_sm3block_ni.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// go run gen_sm3block_ni.go

//go:build ignore
// +build ignore

package main

Expand Down Expand Up @@ -128,7 +127,6 @@ func main() {
fmt.Fprint(buf, `
// Generated by gen_sm3block_ni.go. DO NOT EDIT.
//go:build arm64 && !purego
// +build arm64,!purego
#include "textflag.h"
Expand Down
1 change: 0 additions & 1 deletion sm3/sm3block_amd64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build amd64 && !purego
// +build amd64,!purego

package sm3

Expand Down
1 change: 0 additions & 1 deletion sm3/sm3block_amd64.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion sm3/sm3block_arm64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build arm64 && !purego
// +build arm64,!purego

package sm3

Expand Down
1 change: 0 additions & 1 deletion sm3/sm3block_arm64.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build arm64 && !purego
// +build arm64,!purego

#include "textflag.h"

Expand Down
1 change: 0 additions & 1 deletion sm3/sm3block_avx2_amd64.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"

Expand Down
Loading

0 comments on commit 17a3dd8

Please sign in to comment.