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