mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 20:26:19 +08:00
smx509: use bytes.Clone
This commit is contained in:
parent
0bb54adc1e
commit
9ba88a32a4
@ -20,15 +20,17 @@ type Opts = pkcs.PBES2Opts
|
||||
type PBKDF2Opts = pkcs.PBKDF2Opts
|
||||
type ScryptOpts = pkcs.ScryptOpts
|
||||
|
||||
var DefaultOpts = pkcs.DefaultOpts
|
||||
var SM3 = pkcs.SM3
|
||||
var SHA1 = pkcs.SHA1
|
||||
var SHA224 = pkcs.SHA224
|
||||
var SHA256 = pkcs.SHA256
|
||||
var SHA384 = pkcs.SHA384
|
||||
var SHA512 = pkcs.SHA512
|
||||
var SHA512_224 = pkcs.SHA512_224
|
||||
var SHA512_256 = pkcs.SHA512_256
|
||||
var (
|
||||
DefaultOpts = pkcs.DefaultOpts
|
||||
SM3 = pkcs.SM3
|
||||
SHA1 = pkcs.SHA1
|
||||
SHA224 = pkcs.SHA224
|
||||
SHA256 = pkcs.SHA256
|
||||
SHA384 = pkcs.SHA384
|
||||
SHA512 = pkcs.SHA512
|
||||
SHA512_224 = pkcs.SHA512_224
|
||||
SHA512_256 = pkcs.SHA512_256
|
||||
)
|
||||
|
||||
// for encrypted private-key information
|
||||
type encryptedPrivateKeyInfo struct {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package smx509
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"syscall"
|
||||
@ -73,8 +74,7 @@ func extractSimpleChain(simpleChain **syscall.CertSimpleChain, count int) (chain
|
||||
// Copy the buf, since ParseCertificate does not create its own copy.
|
||||
cert := elements[i].CertContext
|
||||
encodedCert := (*[1 << 20]byte)(unsafe.Pointer(cert.EncodedCert))[:cert.Length:cert.Length]
|
||||
buf := make([]byte, cert.Length)
|
||||
copy(buf, encodedCert)
|
||||
buf := bytes.Clone(encodedCert)
|
||||
parsedCert, err := ParseCertificate(buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user