diff --git a/cipher/xts_amd64.s b/cipher/xts_amd64.s index 55c0511..4595b6c 100644 --- a/cipher/xts_amd64.s +++ b/cipher/xts_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/cipher/xts_arm64.s b/cipher/xts_arm64.s index 3105e5c..61b3582 100644 --- a/cipher/xts_arm64.s +++ b/cipher/xts_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/cipher/xts_asm.go b/cipher/xts_asm.go index 3606e6a..6917a11 100644 --- a/cipher/xts_asm.go +++ b/cipher/xts_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package cipher diff --git a/cipher/xts_asm_test.go b/cipher/xts_asm_test.go index 09e7368..236d8bf 100644 --- a/cipher/xts_asm_test.go +++ b/cipher/xts_asm_test.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package cipher diff --git a/cipher/xts_generic.go b/cipher/xts_generic.go index 6c17d6a..b3bd411 100644 --- a/cipher/xts_generic.go +++ b/cipher/xts_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 && !arm64 || purego -// +build !amd64,!arm64 purego package cipher diff --git a/internal/bigmod/nat_386.s b/internal/bigmod/nat_386.s index d988a00..81f73b8 100644 --- a/internal/bigmod/nat_386.s +++ b/internal/bigmod/nat_386.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/internal/bigmod/nat_amd64.s b/internal/bigmod/nat_amd64.s index c173ea5..e3fc12f 100644 --- a/internal/bigmod/nat_amd64.s +++ b/internal/bigmod/nat_amd64.s @@ -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 diff --git a/internal/bigmod/nat_arm.s b/internal/bigmod/nat_arm.s index b4ca023..fab1eaf 100644 --- a/internal/bigmod/nat_arm.s +++ b/internal/bigmod/nat_arm.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/internal/bigmod/nat_arm64.s b/internal/bigmod/nat_arm64.s index 06a59b0..ba0fef4 100644 --- a/internal/bigmod/nat_arm64.s +++ b/internal/bigmod/nat_arm64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/internal/bigmod/nat_asm.go b/internal/bigmod/nat_asm.go index 2ba9c72..97bbbe6 100644 --- a/internal/bigmod/nat_asm.go +++ b/internal/bigmod/nat_asm.go @@ -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 diff --git a/internal/bigmod/nat_noasm.go b/internal/bigmod/nat_noasm.go index 429700b..415d210 100644 --- a/internal/bigmod/nat_noasm.go +++ b/internal/bigmod/nat_noasm.go @@ -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 diff --git a/internal/bigmod/nat_ppc64x.s b/internal/bigmod/nat_ppc64x.s index 99c6a1e..7b37fa4 100644 --- a/internal/bigmod/nat_ppc64x.s +++ b/internal/bigmod/nat_ppc64x.s @@ -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" diff --git a/internal/bigmod/nat_s390x.s b/internal/bigmod/nat_s390x.s index 94f70ff..1a1dadd 100644 --- a/internal/bigmod/nat_s390x.s +++ b/internal/bigmod/nat_s390x.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/internal/sm2ec/fiat/generate.go b/internal/sm2ec/fiat/generate.go index 8ecce9d..d090704 100644 --- a/internal/sm2ec/fiat/generate.go +++ b/internal/sm2ec/fiat/generate.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/internal/sm2ec/generate.go b/internal/sm2ec/generate.go index 1a0b614..57a27b5 100644 --- a/internal/sm2ec/generate.go +++ b/internal/sm2ec/generate.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main @@ -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, @@ -134,7 +133,6 @@ const tmplNISTEC = `// Copyright 2022 The Go Authors. All rights reserved. {{ if .BuildTags }} //go:build {{ .BuildTags }} -// +build {{ .BuildTags }} {{ end }} package sm2ec diff --git a/internal/sm2ec/p256_asm_amd64.s b/internal/sm2ec/p256_asm_amd64.s index c63c133..43f1a20 100644 --- a/internal/sm2ec/p256_asm_amd64.s +++ b/internal/sm2ec/p256_asm_amd64.s @@ -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" diff --git a/internal/sm2ec/p256_asm_arm64.s b/internal/sm2ec/p256_asm_arm64.s index 697716e..8353e66 100644 --- a/internal/sm2ec/p256_asm_arm64.s +++ b/internal/sm2ec/p256_asm_arm64.s @@ -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" diff --git a/internal/sm2ec/p256_asm_ord.go b/internal/sm2ec/p256_asm_ord.go index 2dd7fee..dffe6bb 100644 --- a/internal/sm2ec/p256_asm_ord.go +++ b/internal/sm2ec/p256_asm_ord.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm2ec diff --git a/internal/sm2ec/p256_asm_table_test.go b/internal/sm2ec/p256_asm_table_test.go index 991601b..8e1bc49 100644 --- a/internal/sm2ec/p256_asm_table_test.go +++ b/internal/sm2ec/p256_asm_table_test.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego && !plugin) || (arm64 && !purego) -// +build amd64,!purego,!plugin arm64,!purego package sm2ec diff --git a/internal/sm2ec/p256_common_amd64.s b/internal/sm2ec/p256_common_amd64.s index 5dca464..32e874d 100644 --- a/internal/sm2ec/p256_common_amd64.s +++ b/internal/sm2ec/p256_common_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/internal/sm2ec/p256_plugin_amd64.s b/internal/sm2ec/p256_plugin_amd64.s index b6df6e0..8594ca8 100644 --- a/internal/sm2ec/p256_plugin_amd64.s +++ b/internal/sm2ec/p256_plugin_amd64.s @@ -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" diff --git a/internal/sm2ec/sm2p256.go b/internal/sm2ec/sm2p256.go index cbd5638..d7b31eb 100644 --- a/internal/sm2ec/sm2p256.go +++ b/internal/sm2ec/sm2p256.go @@ -5,7 +5,6 @@ // Code generated by generate.go. DO NOT EDIT. //go:build !amd64 && !arm64 || purego -// +build !amd64,!arm64 purego package sm2ec diff --git a/internal/sm2ec/sm2p256_asm.go b/internal/sm2ec/sm2p256_asm.go index 96b5c30..a901bb1 100644 --- a/internal/sm2ec/sm2p256_asm.go +++ b/internal/sm2ec/sm2p256_asm.go @@ -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 diff --git a/internal/sm2ec/sm2p256_asm_test.go b/internal/sm2ec/sm2p256_asm_test.go index f467825..576b82f 100644 --- a/internal/sm2ec/sm2p256_asm_test.go +++ b/internal/sm2ec/sm2p256_asm_test.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm2ec diff --git a/internal/sm2ec/sm2p256_ord.go b/internal/sm2ec/sm2p256_ord.go index 1f3a5e7..7eeb067 100644 --- a/internal/sm2ec/sm2p256_ord.go +++ b/internal/sm2ec/sm2p256_ord.go @@ -1,5 +1,4 @@ //go:build (!amd64 && !arm64) || purego -// +build !amd64,!arm64 purego package sm2ec diff --git a/internal/subtle/xor_amd64.go b/internal/subtle/xor_amd64.go index 3ee7e67..bb4d85c 100644 --- a/internal/subtle/xor_amd64.go +++ b/internal/subtle/xor_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build amd64 && !purego -// +build amd64,!purego package subtle diff --git a/internal/subtle/xor_amd64.s b/internal/subtle/xor_amd64.s index 47b346d..9e57e81 100644 --- a/internal/subtle/xor_amd64.s +++ b/internal/subtle/xor_amd64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/internal/subtle/xor_arm64.go b/internal/subtle/xor_arm64.go index 28664d9..15fcb5f 100644 --- a/internal/subtle/xor_arm64.go +++ b/internal/subtle/xor_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build arm64 && !purego -// +build arm64,!purego package subtle diff --git a/internal/subtle/xor_arm64.s b/internal/subtle/xor_arm64.s index 0abcdc3..1454ab1 100644 --- a/internal/subtle/xor_arm64.s +++ b/internal/subtle/xor_arm64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/internal/subtle/xor_generic.go b/internal/subtle/xor_generic.go index 2128400..05033c1 100644 --- a/internal/subtle/xor_generic.go +++ b/internal/subtle/xor_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build !amd64 && !arm64 || purego -// +build !amd64,!arm64 purego package subtle diff --git a/pkcs7/ber.go b/pkcs7/ber.go index cf75597..b53e1cb 100644 --- a/pkcs7/ber.go +++ b/pkcs7/ber.go @@ -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) } diff --git a/pkcs7/pkcs7.go b/pkcs7/pkcs7.go index 50fc7e0..7394e15 100644 --- a/pkcs7/pkcs7.go +++ b/pkcs7/pkcs7.go @@ -26,7 +26,7 @@ type PKCS7 struct { Certificates []*smx509.Certificate CRLs []pkix.CertificateList Signers []signerInfo - raw interface{} + raw any } type contentInfo struct { @@ -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 { @@ -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) } diff --git a/pkcs7/verify.go b/pkcs7/verify.go index 45fac22..4dc40b1 100644 --- a/pkcs7/verify.go +++ b/pkcs7/verify.go @@ -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") @@ -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) diff --git a/pkcs8/pkcs8.go b/pkcs8/pkcs8.go index 474e2ec..5d1a2b1 100644 --- a/pkcs8/pkcs8.go +++ b/pkcs8/pkcs8.go @@ -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) @@ -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) } @@ -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] @@ -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] diff --git a/pkcs8/pkcs8_norace_test.go b/pkcs8/pkcs8_norace_test.go index 22e195c..2bcaa1b 100644 --- a/pkcs8/pkcs8_norace_test.go +++ b/pkcs8/pkcs8_norace_test.go @@ -1,5 +1,4 @@ //go:build !race -// +build !race package pkcs8_test diff --git a/sm2/sm2.go b/sm2/sm2.go index 6f513de..f4c18fb 100644 --- a/sm2/sm2.go +++ b/sm2/sm2.go @@ -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() } diff --git a/sm3/gen_sm3block_ni.go b/sm3/gen_sm3block_ni.go index 9145b82..adedae8 100644 --- a/sm3/gen_sm3block_ni.go +++ b/sm3/gen_sm3block_ni.go @@ -2,7 +2,6 @@ // go run gen_sm3block_ni.go //go:build ignore -// +build ignore package main @@ -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" diff --git a/sm3/sm3block_amd64.go b/sm3/sm3block_amd64.go index d128f02..9754652 100644 --- a/sm3/sm3block_amd64.go +++ b/sm3/sm3block_amd64.go @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego package sm3 diff --git a/sm3/sm3block_amd64.s b/sm3/sm3block_amd64.s index b21bfb8..41312dd 100644 --- a/sm3/sm3block_amd64.s +++ b/sm3/sm3block_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm3/sm3block_arm64.go b/sm3/sm3block_arm64.go index 39eaaf2..4f739da 100644 --- a/sm3/sm3block_arm64.go +++ b/sm3/sm3block_arm64.go @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego package sm3 diff --git a/sm3/sm3block_arm64.s b/sm3/sm3block_arm64.s index 9ee2707..391b40e 100644 --- a/sm3/sm3block_arm64.s +++ b/sm3/sm3block_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm3/sm3block_avx2_amd64.s b/sm3/sm3block_avx2_amd64.s index d892d1d..615371b 100644 --- a/sm3/sm3block_avx2_amd64.s +++ b/sm3/sm3block_avx2_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm3/sm3block_generic.go b/sm3/sm3block_generic.go index e6ee6ca..c5d47e6 100644 --- a/sm3/sm3block_generic.go +++ b/sm3/sm3block_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 && !arm64 || purego -// +build !amd64,!arm64 purego package sm3 diff --git a/sm3/sm3block_simd_amd64.s b/sm3/sm3block_simd_amd64.s index b028d90..4ce2f55 100644 --- a/sm3/sm3block_simd_amd64.s +++ b/sm3/sm3block_simd_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm3/sm3blockni_arm64.s b/sm3/sm3blockni_arm64.s index 5de8050..8d7df9e 100644 --- a/sm3/sm3blockni_arm64.s +++ b/sm3/sm3blockni_arm64.s @@ -1,6 +1,5 @@ // Generated by gen_sm3block_ni.go. DO NOT EDIT. //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm4/asm_amd64.s b/sm4/asm_amd64.s index 90265c7..531b65d 100644 --- a/sm4/asm_amd64.s +++ b/sm4/asm_amd64.s @@ -1,6 +1,5 @@ // This SM4 implementation referenced https://github.com/mjosaarinen/sm4ni/blob/master/sm4ni.c //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm4/asm_arm64.s b/sm4/asm_arm64.s index 98fccbe..e8a6440 100644 --- a/sm4/asm_arm64.s +++ b/sm4/asm_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm4/cbc_amd64.s b/sm4/cbc_amd64.s index e256caa..3dad037 100644 --- a/sm4/cbc_amd64.s +++ b/sm4/cbc_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm4/cbc_arm64.s b/sm4/cbc_arm64.s index b4e6c7a..948073c 100644 --- a/sm4/cbc_arm64.s +++ b/sm4/cbc_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm4/cbc_cipher_asm.go b/sm4/cbc_cipher_asm.go index 582b051..c85358d 100644 --- a/sm4/cbc_cipher_asm.go +++ b/sm4/cbc_cipher_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/cbc_cipher_test.go b/sm4/cbc_cipher_test.go index f882e71..71b4532 100644 --- a/sm4/cbc_cipher_test.go +++ b/sm4/cbc_cipher_test.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/cipher_asm.go b/sm4/cipher_asm.go index ca72860..d701885 100644 --- a/sm4/cipher_asm.go +++ b/sm4/cipher_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/cipher_asm_fuzzy_test.go b/sm4/cipher_asm_fuzzy_test.go index 4bf9987..05b3082 100644 --- a/sm4/cipher_asm_fuzzy_test.go +++ b/sm4/cipher_asm_fuzzy_test.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/cipher_asm_test.go b/sm4/cipher_asm_test.go index 4c91a67..eb6069e 100644 --- a/sm4/cipher_asm_test.go +++ b/sm4/cipher_asm_test.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/cipher_generic.go b/sm4/cipher_generic.go index f1e28a5..ce05b99 100644 --- a/sm4/cipher_generic.go +++ b/sm4/cipher_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 && !arm64 || purego -// +build !amd64,!arm64 purego package sm4 diff --git a/sm4/cipher_ni.go b/sm4/cipher_ni.go index 6e9865b..b9cd84e 100644 --- a/sm4/cipher_ni.go +++ b/sm4/cipher_ni.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/ctr_cipher_asm.go b/sm4/ctr_cipher_asm.go index 6e1b9af..fd222b3 100644 --- a/sm4/ctr_cipher_asm.go +++ b/sm4/ctr_cipher_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/ecb_amd64.s b/sm4/ecb_amd64.s index f637841..75f8d0e 100644 --- a/sm4/ecb_amd64.s +++ b/sm4/ecb_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm4/ecb_arm64.s b/sm4/ecb_arm64.s index 5abd26e..602a07c 100644 --- a/sm4/ecb_arm64.s +++ b/sm4/ecb_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm4/ecb_cipher_asm.go b/sm4/ecb_cipher_asm.go index 2c0458f..b985233 100644 --- a/sm4/ecb_cipher_asm.go +++ b/sm4/ecb_cipher_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/gcm_amd64.s b/sm4/gcm_amd64.s index f46d163..8529adb 100644 --- a/sm4/gcm_amd64.s +++ b/sm4/gcm_amd64.s @@ -5,7 +5,6 @@ // [2] Gueron, S., Krasnov, V.: Speeding up Counter Mode in Software and // Hardware //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm4/gcm_arm64.s b/sm4/gcm_arm64.s index 4c2edb7..e4b6c78 100644 --- a/sm4/gcm_arm64.s +++ b/sm4/gcm_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm4/gcm_cipher_asm.go b/sm4/gcm_cipher_asm.go index 62c3e0b..2471b6a 100644 --- a/sm4/gcm_cipher_asm.go +++ b/sm4/gcm_cipher_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/gcm_sm4ni_arm64.s b/sm4/gcm_sm4ni_arm64.s index 33bb412..492e505 100644 --- a/sm4/gcm_sm4ni_arm64.s +++ b/sm4/gcm_sm4ni_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm4/gen_arm64_ni.go b/sm4/gen_arm64_ni.go index 46eb3ae..133e310 100644 --- a/sm4/gen_arm64_ni.go +++ b/sm4/gen_arm64_ni.go @@ -2,7 +2,6 @@ // go run gen_arm64_ni.go //go:build ignore -// +build ignore package main diff --git a/sm4/sm4_gcm_asm.go b/sm4/sm4_gcm_asm.go index 42b564b..c46feeb 100644 --- a/sm4/sm4_gcm_asm.go +++ b/sm4/sm4_gcm_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/sm4_xts.go b/sm4/sm4_xts.go index 112cbbb..60aeb8a 100644 --- a/sm4/sm4_xts.go +++ b/sm4/sm4_xts.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/sm4ni_gcm_asm.go b/sm4/sm4ni_gcm_asm.go index e3d2cd1..3f2640b 100644 --- a/sm4/sm4ni_gcm_asm.go +++ b/sm4/sm4ni_gcm_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package sm4 diff --git a/sm4/sm4ni_xts.go b/sm4/sm4ni_xts.go index 434f8c9..6581211 100644 --- a/sm4/sm4ni_xts.go +++ b/sm4/sm4ni_xts.go @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego package sm4 diff --git a/sm4/xts_amd64.s b/sm4/xts_amd64.s index 8f1e582..d66988c 100644 --- a/sm4/xts_amd64.s +++ b/sm4/xts_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm4/xts_arm64.s b/sm4/xts_arm64.s index 4399395..c2154a7 100644 --- a/sm4/xts_arm64.s +++ b/sm4/xts_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm4/xts_sm4ni_arm64.s b/sm4/xts_sm4ni_arm64.s index 5c46c6b..a336876 100644 --- a/sm4/xts_sm4ni_arm64.s +++ b/sm4/xts_sm4ni_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm9/bn256/generate.go b/sm9/bn256/generate.go index 145cb20..7f6fe06 100644 --- a/sm9/bn256/generate.go +++ b/sm9/bn256/generate.go @@ -1,5 +1,4 @@ //go:build ignore -// +build ignore package main diff --git a/sm9/bn256/gfp2_g1_amd64.s b/sm9/bn256/gfp2_g1_amd64.s index 4770464..dc44d77 100644 --- a/sm9/bn256/gfp2_g1_amd64.s +++ b/sm9/bn256/gfp2_g1_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego && !plugin -// +build amd64,!purego,!plugin #include "textflag.h" diff --git a/sm9/bn256/gfp2_g1_arm64.s b/sm9/bn256/gfp2_g1_arm64.s index 37ef8b2..6bbaee3 100644 --- a/sm9/bn256/gfp2_g1_arm64.s +++ b/sm9/bn256/gfp2_g1_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm9/bn256/gfp2_g1_decl.go b/sm9/bn256/gfp2_g1_decl.go index a572bbb..e397dc9 100644 --- a/sm9/bn256/gfp2_g1_decl.go +++ b/sm9/bn256/gfp2_g1_decl.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego && !plugin) || (arm64 && !purego) -// +build amd64,!purego,!plugin arm64,!purego package bn256 diff --git a/sm9/bn256/gfp2_g1_generic.go b/sm9/bn256/gfp2_g1_generic.go index bff3831..72e7649 100644 --- a/sm9/bn256/gfp2_g1_generic.go +++ b/sm9/bn256/gfp2_g1_generic.go @@ -1,5 +1,4 @@ //go:build (!amd64 && !arm64) || purego || plugin -// +build !amd64,!arm64 purego plugin package bn256 diff --git a/sm9/bn256/gfp_amd64.s b/sm9/bn256/gfp_amd64.s index f36e191..5fc3e4e 100644 --- a/sm9/bn256/gfp_amd64.s +++ b/sm9/bn256/gfp_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego && !plugin -// +build amd64,!purego,!plugin #include "textflag.h" #include "gfp_macros_amd64.s" diff --git a/sm9/bn256/gfp_arm64.s b/sm9/bn256/gfp_arm64.s index 96b8b25..5e0b364 100644 --- a/sm9/bn256/gfp_arm64.s +++ b/sm9/bn256/gfp_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm9/bn256/gfp_cmn_amd64.s b/sm9/bn256/gfp_cmn_amd64.s index 4af2efe..1fa43a2 100644 --- a/sm9/bn256/gfp_cmn_amd64.s +++ b/sm9/bn256/gfp_cmn_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm9/bn256/gfp_decl.go b/sm9/bn256/gfp_decl.go index 589bd3f..eddd793 100644 --- a/sm9/bn256/gfp_decl.go +++ b/sm9/bn256/gfp_decl.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package bn256 diff --git a/sm9/bn256/gfp_generic.go b/sm9/bn256/gfp_generic.go index 29264f0..08608bd 100644 --- a/sm9/bn256/gfp_generic.go +++ b/sm9/bn256/gfp_generic.go @@ -1,5 +1,4 @@ //go:build (!amd64 && !arm64) || purego -// +build !amd64,!arm64 purego package bn256 diff --git a/sm9/bn256/gfp_plugin_amd64.s b/sm9/bn256/gfp_plugin_amd64.s index 5ca3ed4..e6f0c3d 100644 --- a/sm9/bn256/gfp_plugin_amd64.s +++ b/sm9/bn256/gfp_plugin_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego && plugin -// +build amd64,!purego,plugin #include "textflag.h" #include "gfp_macros_amd64.s" diff --git a/sm9/bn256/select_amd64.s b/sm9/bn256/select_amd64.s index 9bc2616..b04b821 100644 --- a/sm9/bn256/select_amd64.s +++ b/sm9/bn256/select_amd64.s @@ -1,5 +1,4 @@ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/sm9/bn256/select_arm64.s b/sm9/bn256/select_arm64.s index 09f6cd8..77c4be1 100644 --- a/sm9/bn256/select_arm64.s +++ b/sm9/bn256/select_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/sm9/bn256/select_decl.go b/sm9/bn256/select_decl.go index cb84269..92f8ad3 100644 --- a/sm9/bn256/select_decl.go +++ b/sm9/bn256/select_decl.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package bn256 diff --git a/sm9/bn256/select_generic.go b/sm9/bn256/select_generic.go index 275a34d..4af7241 100644 --- a/sm9/bn256/select_generic.go +++ b/sm9/bn256/select_generic.go @@ -1,5 +1,4 @@ //go:build (!amd64 && !arm64) || purego -// +build !amd64,!arm64 purego package bn256 diff --git a/smx509/name_constraints_test.go b/smx509/name_constraints_test.go index 64cd4ec..d260099 100644 --- a/smx509/name_constraints_test.go +++ b/smx509/name_constraints_test.go @@ -1850,7 +1850,7 @@ func parseEKUs(ekuStrs []string) (ekus []ExtKeyUsage, unknowns []asn1.ObjectIden func TestConstraintCases(t *testing.T) { privateKeys := sync.Pool{ - New: func() interface{} { + New: func() any { priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { panic(err) diff --git a/smx509/parser.go b/smx509/parser.go index 58f24b8..f5f8133 100644 --- a/smx509/parser.go +++ b/smx509/parser.go @@ -233,7 +233,7 @@ func parseExtension(der cryptobyte.String) (pkix.Extension, error) { return ext, nil } -func parsePublicKey(keyData *publicKeyInfo) (interface{}, error) { +func parsePublicKey(keyData *publicKeyInfo) (any, error) { oid := keyData.Algorithm.Algorithm params := keyData.Algorithm.Parameters der := cryptobyte.String(keyData.PublicKey.RightAlign()) diff --git a/smx509/pkcs8.go b/smx509/pkcs8.go index 0ce6bd6..76af088 100644 --- a/smx509/pkcs8.go +++ b/smx509/pkcs8.go @@ -35,7 +35,7 @@ type pkcs8 struct { // More types might be supported in the future. // // This kind of key is commonly encoded in PEM blocks of type "PRIVATE KEY". -func ParsePKCS8PrivateKey(der []byte) (key interface{}, err error) { +func ParsePKCS8PrivateKey(der []byte) (key any, err error) { var privKey pkcs8 if _, err := asn1.Unmarshal(der, &privKey); err != nil { if _, err := asn1.Unmarshal(der, &ecPrivateKey{}); err == nil { @@ -69,7 +69,7 @@ func ParsePKCS8PrivateKey(der []byte) (key interface{}, err error) { return key, err } -func parseSM9PrivateKey(privKey pkcs8) (key interface{}, err error) { +func parseSM9PrivateKey(privKey pkcs8) (key any, err error) { switch { case privKey.Algo.Algorithm.Equal(oidSM9Sign): sm9SignKey := new(sm9.SignPrivateKey) @@ -123,7 +123,7 @@ func parseSM9PrivateKey(privKey pkcs8) (key interface{}, err error) { // and ed25519.PrivateKey. Unsupported key types result in an error. // // This kind of key is commonly encoded in PEM blocks of type "PRIVATE KEY". -func MarshalPKCS8PrivateKey(key interface{}) ([]byte, error) { +func MarshalPKCS8PrivateKey(key any) ([]byte, error) { switch k := key.(type) { case *sm2.PrivateKey: return marshalPKCS8ECPrivateKey(&k.PrivateKey) diff --git a/smx509/root_bsd.go b/smx509/root_bsd.go index e3f082d..a5a7a69 100644 --- a/smx509/root_bsd.go +++ b/smx509/root_bsd.go @@ -1,5 +1,4 @@ //go:build dragonfly || freebsd || netbsd || openbsd -// +build dragonfly freebsd netbsd openbsd package smx509 diff --git a/smx509/root_js.go b/smx509/root_js.go index 0eb8776..2fde43a 100644 --- a/smx509/root_js.go +++ b/smx509/root_js.go @@ -1,5 +1,4 @@ //go:build js && wasm -// +build js,wasm package smx509 diff --git a/smx509/root_plan9.go b/smx509/root_plan9.go index d71d69b..bc030c9 100644 --- a/smx509/root_plan9.go +++ b/smx509/root_plan9.go @@ -1,5 +1,4 @@ //go:build plan9 -// +build plan9 package smx509 diff --git a/smx509/root_unix.go b/smx509/root_unix.go index b31fb5f..19b8d44 100644 --- a/smx509/root_unix.go +++ b/smx509/root_unix.go @@ -1,5 +1,4 @@ //go:build aix || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix dragonfly freebsd js,wasm linux netbsd openbsd solaris package smx509 diff --git a/smx509/sec1.go b/smx509/sec1.go index 126a0c5..19fb504 100644 --- a/smx509/sec1.go +++ b/smx509/sec1.go @@ -48,7 +48,7 @@ func ParseSM2PrivateKey(der []byte) (*sm2.PrivateKey, error) { // It returns a *ecdsa.PrivateKey or a *sm2.PrivateKey. // // This kind of key is commonly encoded in PEM blocks of type "EC PRIVATE KEY". -func ParseTypedECPrivateKey(der []byte) (interface{}, error) { +func ParseTypedECPrivateKey(der []byte) (any, error) { key, err := parseECPrivateKey(nil, der) if err != nil { return nil, err diff --git a/smx509/verify.go b/smx509/verify.go index e5cb015..9c5a3c1 100644 --- a/smx509/verify.go +++ b/smx509/verify.go @@ -392,9 +392,9 @@ func (c *Certificate) checkNameConstraints(count *int, maxConstraintComparisons int, nameType string, name string, - parsedName interface{}, - match func(parsedName, constraint interface{}) (match bool, err error), - permitted, excluded interface{}) error { + parsedName any, + match func(parsedName, constraint any) (match bool, err error), + permitted, excluded any) error { excludedValue := reflect.ValueOf(excluded) @@ -506,7 +506,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } if err := c.checkNameConstraints(&comparisonCount, maxConstraintComparisons, "email address", name, mailbox, - func(parsedName, constraint interface{}) (bool, error) { + func(parsedName, constraint any) (bool, error) { return matchEmailConstraint(parsedName.(rfc2821Mailbox), constraint.(string)) }, c.PermittedEmailAddresses, c.ExcludedEmailAddresses); err != nil { return err @@ -519,7 +519,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } if err := c.checkNameConstraints(&comparisonCount, maxConstraintComparisons, "DNS name", name, name, - func(parsedName, constraint interface{}) (bool, error) { + func(parsedName, constraint any) (bool, error) { return matchDomainConstraint(parsedName.(string), constraint.(string)) }, c.PermittedDNSDomains, c.ExcludedDNSDomains); err != nil { return err @@ -533,7 +533,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } if err := c.checkNameConstraints(&comparisonCount, maxConstraintComparisons, "URI", name, uri, - func(parsedName, constraint interface{}) (bool, error) { + func(parsedName, constraint any) (bool, error) { return matchURIConstraint(parsedName.(*url.URL), constraint.(string)) }, c.PermittedURIDomains, c.ExcludedURIDomains); err != nil { return err @@ -546,7 +546,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } if err := c.checkNameConstraints(&comparisonCount, maxConstraintComparisons, "IP address", ip.String(), ip, - func(parsedName, constraint interface{}) (bool, error) { + func(parsedName, constraint any) (bool, error) { return matchIPConstraint(parsedName.(net.IP), constraint.(*net.IPNet)) }, c.PermittedIPRanges, c.ExcludedIPRanges); err != nil { return err diff --git a/smx509/x509.go b/smx509/x509.go index 22590f1..24ac674 100644 --- a/smx509/x509.go +++ b/smx509/x509.go @@ -69,7 +69,7 @@ type pkixPublicKey struct { // ed25519.PublicKey. More types might be supported in the future. // // This kind of key is commonly encoded in PEM blocks of type "PUBLIC KEY". -func ParsePKIXPublicKey(derBytes []byte) (interface{}, error) { +func ParsePKIXPublicKey(derBytes []byte) (any, error) { var pki publicKeyInfo if rest, err := asn1.Unmarshal(derBytes, &pki); err != nil { if _, err := asn1.Unmarshal(derBytes, &pkcs1PublicKey{}); err == nil { @@ -82,7 +82,7 @@ func ParsePKIXPublicKey(derBytes []byte) (interface{}, error) { return parsePublicKey(&pki) } -func marshalPublicKey(pub interface{}) (publicKeyBytes []byte, publicKeyAlgorithm pkix.AlgorithmIdentifier, err error) { +func marshalPublicKey(pub any) (publicKeyBytes []byte, publicKeyAlgorithm pkix.AlgorithmIdentifier, err error) { switch pub := pub.(type) { case *rsa.PublicKey: publicKeyBytes, err = asn1.Marshal(pkcs1PublicKey{ @@ -144,7 +144,7 @@ func marshalPublicKey(pub interface{}) (publicKeyBytes []byte, publicKeyAlgorith // and ed25519.PublicKey. Unsupported key types result in an error. // // This kind of key is commonly encoded in PEM blocks of type "PUBLIC KEY". -func MarshalPKIXPublicKey(pub interface{}) ([]byte, error) { +func MarshalPKIXPublicKey(pub any) ([]byte, error) { var publicKeyBytes []byte var publicKeyAlgorithm pkix.AlgorithmIdentifier var err error @@ -726,7 +726,7 @@ func (c *Certificate) getSANExtension() []byte { return nil } -func signaturePublicKeyAlgoMismatchError(expectedPubKeyAlgo PublicKeyAlgorithm, pubKey interface{}) error { +func signaturePublicKeyAlgoMismatchError(expectedPubKeyAlgo PublicKeyAlgorithm, pubKey any) error { return fmt.Errorf("x509: signature algorithm specifies an %s public key, but have public key of type %T", expectedPubKeyAlgo.String(), pubKey) } @@ -1257,7 +1257,7 @@ func subjectBytes(cert *x509.Certificate) ([]byte, error) { // signingParamsForPublicKey returns the parameters to use for signing with // priv. If requestedSigAlgo is not zero then it overrides the default // signature algorithm. -func signingParamsForPublicKey(pub interface{}, requestedSigAlgo SignatureAlgorithm) (hashFunc crypto.Hash, sigAlgo pkix.AlgorithmIdentifier, err error) { +func signingParamsForPublicKey(pub any, requestedSigAlgo SignatureAlgorithm) (hashFunc crypto.Hash, sigAlgo pkix.AlgorithmIdentifier, err error) { var pubType PublicKeyAlgorithm switch pub := pub.(type) { @@ -1391,7 +1391,7 @@ var emptyASN1Subject = []byte{0x30, 0} // // If SubjectKeyId from template is empty and the template is a CA, SubjectKeyId // will be generated from the hash of the public key. -func CreateCertificate(rand io.Reader, template, parent, pub, priv interface{}) ([]byte, error) { +func CreateCertificate(rand io.Reader, template, parent, pub, priv any) ([]byte, error) { realTemplate, err := toCertificate(template) if err != nil { return nil, fmt.Errorf("x509: unsupported template parameter type: %T", template) @@ -1537,7 +1537,7 @@ func CreateCertificate(rand io.Reader, template, parent, pub, priv interface{}) return signedCert, nil } -func toCertificate(in interface{}) (*x509.Certificate, error) { +func toCertificate(in any) (*x509.Certificate, error) { switch c := in.(type) { case *x509.Certificate: return c, nil @@ -1566,7 +1566,7 @@ func ParseDERCRL(derBytes []byte) (*pkix.CertificateList, error) { // // Note: this method does not generate an RFC 5280 conformant X.509 v2 CRL. // To generate a standards compliant CRL, use CreateRevocationList instead. -func (c *Certificate) CreateCRL(rand io.Reader, priv interface{}, revokedCerts []pkix.RevokedCertificate, now, expiry time.Time) (crlBytes []byte, err error) { +func (c *Certificate) CreateCRL(rand io.Reader, priv any, revokedCerts []pkix.RevokedCertificate, now, expiry time.Time) (crlBytes []byte, err error) { key, ok := priv.(crypto.Signer) if !ok { return nil, errors.New("x509: certificate private key does not implement crypto.Signer") @@ -1757,7 +1757,7 @@ func parseCSRExtensions(rawAttributes []asn1.RawValue) ([]pkix.Extension, error) // ed25519.PrivateKey satisfies this.) // // The returned slice is the certificate request in DER encoding. -func CreateCertificateRequest(rand io.Reader, template *x509.CertificateRequest, priv interface{}) (csr []byte, err error) { +func CreateCertificateRequest(rand io.Reader, template *x509.CertificateRequest, priv any) (csr []byte, err error) { key, ok := priv.(crypto.Signer) if !ok { return nil, errors.New("x509: certificate private key does not implement crypto.Signer") diff --git a/smx509/x509_additional_test.go b/smx509/x509_additional_test.go index 34c0a5c..7d21df7 100644 --- a/smx509/x509_additional_test.go +++ b/smx509/x509_additional_test.go @@ -103,7 +103,7 @@ func TestSignByCloudVerifyAtLocal(t *testing.T) { } } -func getPublicKey(pemContent []byte) (interface{}, error) { +func getPublicKey(pemContent []byte) (any, error) { block, _ := pem.Decode(pemContent) if block == nil { return nil, errors.New("Failed to parse PEM block") diff --git a/smx509/x509_test.go b/smx509/x509_test.go index 96e9aa5..f79a8c6 100644 --- a/smx509/x509_test.go +++ b/smx509/x509_test.go @@ -42,7 +42,7 @@ func TestMarshalInvalidPublicKey(t *testing.T) { } } -func testParsePKIXPublicKey(t *testing.T, pemBytes string) (pub interface{}) { +func testParsePKIXPublicKey(t *testing.T, pemBytes string) (pub any) { block, _ := pem.Decode([]byte(pemBytes)) pub, err := ParsePKIXPublicKey(block.Bytes) if err != nil { @@ -409,7 +409,7 @@ func TestCreateSelfSignedCertificate(t *testing.T) { tests := []struct { name string - pub, priv interface{} + pub, priv any checkSig bool sigAlgo SignatureAlgorithm }{ @@ -1060,7 +1060,7 @@ func TestCRLCreation(t *testing.T) { tests := []struct { name string - priv interface{} + priv any cert *Certificate }{ {"RSA CA", privRSA, certRSA}, @@ -1206,7 +1206,7 @@ func TestCreateCertificateRequest(t *testing.T) { tests := []struct { name string - priv interface{} + priv any sigAlgo SignatureAlgorithm }{ {"RSA", testPrivateKey, SHA1WithRSA}, diff --git a/zuc/asm_amd64.s b/zuc/asm_amd64.s index c7602ce..d50addc 100644 --- a/zuc/asm_amd64.s +++ b/zuc/asm_amd64.s @@ -2,7 +2,6 @@ // https://github.com/intel/intel-ipsec-mb/ // https://gist.github.com/emmansun/15d2fce6659ab97ffaf7ab66e278caee //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/zuc/asm_arm64.s b/zuc/asm_arm64.s index 42a2416..63844be 100644 --- a/zuc/asm_arm64.s +++ b/zuc/asm_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/zuc/core_asm.go b/zuc/core_asm.go index a396ba7..8953dd9 100644 --- a/zuc/core_asm.go +++ b/zuc/core_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package zuc diff --git a/zuc/core_generic.go b/zuc/core_generic.go index 4c75066..9db91ba 100644 --- a/zuc/core_generic.go +++ b/zuc/core_generic.go @@ -1,5 +1,4 @@ //go:build (!amd64 && !arm64) || purego -// +build !amd64,!arm64 purego package zuc diff --git a/zuc/eea_asm.go b/zuc/eea_asm.go index 72e45bb..0af0dae 100644 --- a/zuc/eea_asm.go +++ b/zuc/eea_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package zuc diff --git a/zuc/eea_generic.go b/zuc/eea_generic.go index 2fb9c22..d701552 100644 --- a/zuc/eea_generic.go +++ b/zuc/eea_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 && !arm64 || purego -// +build !amd64,!arm64 purego package zuc diff --git a/zuc/eia256_asm.go b/zuc/eia256_asm.go index d5a3afd..bb369f4 100644 --- a/zuc/eia256_asm.go +++ b/zuc/eia256_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package zuc diff --git a/zuc/eia256_asm_amd64.s b/zuc/eia256_asm_amd64.s index 12b3e4d..3e016a2 100644 --- a/zuc/eia256_asm_amd64.s +++ b/zuc/eia256_asm_amd64.s @@ -1,7 +1,6 @@ // Referenced Intel(R) Multi-Buffer Crypto for IPsec // https://github.com/intel/intel-ipsec-mb/ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/zuc/eia256_asm_arm64.s b/zuc/eia256_asm_arm64.s index db80bcf..6f17690 100644 --- a/zuc/eia256_asm_arm64.s +++ b/zuc/eia256_asm_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/zuc/eia256_generic.go b/zuc/eia256_generic.go index 26ecebf..5491ce2 100644 --- a/zuc/eia256_generic.go +++ b/zuc/eia256_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 && !arm64 || purego -// +build !amd64,!arm64 purego package zuc diff --git a/zuc/eia_asm.go b/zuc/eia_asm.go index e4ba3c4..33cef7e 100644 --- a/zuc/eia_asm.go +++ b/zuc/eia_asm.go @@ -1,5 +1,4 @@ //go:build (amd64 && !purego) || (arm64 && !purego) -// +build amd64,!purego arm64,!purego package zuc diff --git a/zuc/eia_asm_amd64.s b/zuc/eia_asm_amd64.s index 9e29b19..ccbbbf7 100644 --- a/zuc/eia_asm_amd64.s +++ b/zuc/eia_asm_amd64.s @@ -1,7 +1,6 @@ // Referenced Intel(R) Multi-Buffer Crypto for IPsec // https://github.com/intel/intel-ipsec-mb/ //go:build amd64 && !purego -// +build amd64,!purego #include "textflag.h" diff --git a/zuc/eia_asm_arm64.s b/zuc/eia_asm_arm64.s index baff5be..6680364 100644 --- a/zuc/eia_asm_arm64.s +++ b/zuc/eia_asm_arm64.s @@ -1,5 +1,4 @@ //go:build arm64 && !purego -// +build arm64,!purego #include "textflag.h" diff --git a/zuc/eia_generic.go b/zuc/eia_generic.go index 8d87458..af2e321 100644 --- a/zuc/eia_generic.go +++ b/zuc/eia_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 && !arm64 || purego -// +build !amd64,!arm64 purego package zuc