mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 04:36:19 +08:00
change interface{} to any, and remove "+build" build tag #77
This commit is contained in:
parent
79765c757f
commit
17a3dd8d4b
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package cipher
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package cipher
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build !amd64 && !arm64 || purego
|
||||
// +build !amd64,!arm64 purego
|
||||
|
||||
package cipher
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !purego
|
||||
// +build !purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -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
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !purego
|
||||
// +build !purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !purego
|
||||
// +build !purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !purego
|
||||
// +build !purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm2ec
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego && !plugin) || (arm64 && !purego)
|
||||
// +build amd64,!purego,!plugin arm64,!purego
|
||||
|
||||
package sm2ec
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
// Code generated by generate.go. DO NOT EDIT.
|
||||
|
||||
//go:build !amd64 && !arm64 || purego
|
||||
// +build !amd64,!arm64 purego
|
||||
|
||||
package sm2ec
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm2ec
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (!amd64 && !arm64) || purego
|
||||
// +build !amd64,!arm64 purego
|
||||
|
||||
package sm2ec
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
package subtle
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
package subtle
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
//go:build !amd64 && !arm64 || purego
|
||||
// +build !amd64,!arm64 purego
|
||||
|
||||
package subtle
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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]
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build !race
|
||||
// +build !race
|
||||
|
||||
package pkcs8_test
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
package sm3
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
package sm3
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build !amd64 && !arm64 || purego
|
||||
// +build !amd64,!arm64 purego
|
||||
|
||||
package sm3
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Generated by gen_sm3block_ni.go. DO NOT EDIT.
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build !amd64 && !arm64 || purego
|
||||
// +build !amd64,!arm64 purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// go run gen_arm64_ni.go
|
||||
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
package sm4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego && !plugin
|
||||
// +build amd64,!purego,!plugin
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego && !plugin) || (arm64 && !purego)
|
||||
// +build amd64,!purego,!plugin arm64,!purego
|
||||
|
||||
package bn256
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (!amd64 && !arm64) || purego || plugin
|
||||
// +build !amd64,!arm64 purego plugin
|
||||
|
||||
package bn256
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego && !plugin
|
||||
// +build amd64,!purego,!plugin
|
||||
|
||||
#include "textflag.h"
|
||||
#include "gfp_macros_amd64.s"
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package bn256
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (!amd64 && !arm64) || purego
|
||||
// +build !amd64,!arm64 purego
|
||||
|
||||
package bn256
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego && plugin
|
||||
// +build amd64,!purego,plugin
|
||||
|
||||
#include "textflag.h"
|
||||
#include "gfp_macros_amd64.s"
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build amd64 && !purego
|
||||
// +build amd64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build arm64 && !purego
|
||||
// +build arm64,!purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (amd64 && !purego) || (arm64 && !purego)
|
||||
// +build amd64,!purego arm64,!purego
|
||||
|
||||
package bn256
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build (!amd64 && !arm64) || purego
|
||||
// +build !amd64,!arm64 purego
|
||||
|
||||
package bn256
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build dragonfly || freebsd || netbsd || openbsd
|
||||
// +build dragonfly freebsd netbsd openbsd
|
||||
|
||||
package smx509
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package smx509
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build plan9
|
||||
// +build plan9
|
||||
|
||||
package smx509
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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},
|
||||
|
@ -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"
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user