ca

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// get Cipher type
	GetCipherFromName = pkcs8.GetCipherFromName
	// get hash type
	GetHashFromName = pkcs8.GetHashFromName
)
View Source
var (
	ErrKeyMustBePEMEncoded = errors.New("go-cryptobin/ca: invalid key: Key must be a PEM encoded OpenSSH key")

	ErrPrivateKeyError = errors.New("go-cryptobin/ca: key is not a valid private key")
	ErrPublicKeyError  = errors.New("go-cryptobin/ca: key is not a valid public key")
)

Functions

This section is empty.

Types

type CA

type CA struct {

	// 错误
	Errors []error
	// contains filtered or unexported fields
}

*

  • CA *
  • @create 2022-7-22
  • @author deatil

func FromCertificate

func FromCertificate(cert []byte) CA

From Certificate PEM

func FromCertificateRequest

func FromCertificateRequest(cert []byte) CA

From Certificate Request PEM

func FromPKCS12Cert

func FromPKCS12Cert(pfxData []byte, password string) CA

From PKCS12 Cert

func FromPrivateKey

func FromPrivateKey(key []byte) CA

From PrivateKey PEM

func FromPrivateKeyWithPassword

func FromPrivateKeyWithPassword(key []byte, password []byte) CA

From PrivateKey PEM With Password

func FromPublicKey

func FromPublicKey(key []byte) CA

From PublicKey PEM

func GenerateDSAKey

func GenerateDSAKey(ln string) CA

Generate DSA Key

func GenerateECDSAKey

func GenerateECDSAKey(curve string) CA

Generate ECDSA Key

func GenerateEdDSAKey

func GenerateEdDSAKey() CA

Generate EdDSA Key

func GenerateElGamalKey

func GenerateElGamalKey(bitsize, probability int) CA

Generate ElGamal Key

func GenerateGostKey

func GenerateGostKey(curve string) CA

Generate Gost Key

func GenerateKey

func GenerateKey(options ...Options) CA

Generate Key

func GenerateKeyWithSeed

func GenerateKeyWithSeed(reader io.Reader, options ...Options) CA

Generate Key with Reader

func GenerateRSAKey

func GenerateRSAKey(bits int) CA

Generate RSA Key

func GenerateSM2Key

func GenerateSM2Key() CA

Generate SM2 Key

func New

func New() CA

构造函数

func NewCA

func NewCA() CA

构造函数

func (CA) AppendError

func (this CA) AppendError(err ...error) CA

添加错误

func (CA) CreateCA

func (this CA) CreateCA() CA

Create CA PEM

func (CA) CreateCAWithIssuer

func (this CA) CreateCAWithIssuer(issuer *cryptobin_x509.Certificate, issuerKey crypto.PrivateKey) CA

Create CA PEM With Issuer

func (CA) CreateCSR

func (this CA) CreateCSR() CA

Create CSR PEM

func (CA) CreateCert

func (this CA) CreateCert(issuer *cryptobin_x509.Certificate, issuerKey crypto.PrivateKey) CA

Create Cert PEM

func (CA) CreatePKCS12Cert

func (this CA) CreatePKCS12Cert(caCerts []*x509.Certificate, password string) CA

Create PKCS12 Cert PEM caCerts 通常保留为空

func (CA) CreatePrivateKey

func (this CA) CreatePrivateKey() CA

Create PrivateKey PEM

func (CA) CreatePrivateKeyWithPassword

func (this CA) CreatePrivateKeyWithPassword(password []byte, opts ...any) CA

Create PrivateKey PEM With Password

func (CA) CreatePublicKey

func (this CA) CreatePublicKey() CA

Create PublicKey PEM

func (CA) Error

func (this CA) Error() error

获取错误

func (CA) FromCertificate

func (this CA) FromCertificate(cert []byte) CA

From Certificate PEM

func (CA) FromCertificateRequest

func (this CA) FromCertificateRequest(cert []byte) CA

From Certificate Request PEM

func (CA) FromPKCS12Cert

func (this CA) FromPKCS12Cert(pfxData []byte, password string) CA

pkcs12

func (CA) FromPrivateKey

func (this CA) FromPrivateKey(key []byte) CA

From PrivateKey PEM

func (CA) FromPrivateKeyWithPassword

func (this CA) FromPrivateKeyWithPassword(key []byte, password []byte) CA

From PrivateKey PEM With Password

func (CA) FromPublicKey

func (this CA) FromPublicKey(key []byte) CA

From PublicKey PEM

func (CA) GenerateDSAKey

func (this CA) GenerateDSAKey(ln string) CA

Generate DSA key params: [ L1024N160 | L2048N224 | L2048N256 | L3072N256 ]

func (CA) GenerateECDSAKey

func (this CA) GenerateECDSAKey(curve string) CA

Generate ECDSA key params: [P521 | P384 | P256 | P224]

func (CA) GenerateEdDSAKey

func (this CA) GenerateEdDSAKey() CA

Generate EdDSA key

func (CA) GenerateElGamalKey

func (this CA) GenerateElGamalKey(bitsize, probability int) CA

Generate ElGamal key

func (CA) GenerateGostKey

func (this CA) GenerateGostKey(curve string) CA

Generate Gost key

func (CA) GenerateKey

func (this CA) GenerateKey() CA

Generate Key

func (CA) GenerateKeyWithSeed

func (this CA) GenerateKeyWithSeed(reader io.Reader) CA

Generate Key with Reader

func (CA) GenerateRSAKey

func (this CA) GenerateRSAKey(bits int) CA

Generate RSA key params: [512 | 1024 | 2048 | 4096]

func (CA) GenerateSM2Key

func (this CA) GenerateSM2Key() CA

Generate SM2 key

func (CA) GetBits

func (this CA) GetBits() int

get Options Bits

func (CA) GetBitsize

func (this CA) GetBitsize() int

get Options Bitsize

func (CA) GetCert

func (this CA) GetCert() *x509.Certificate

获取 cert

func (CA) GetCertRequest

func (this CA) GetCertRequest() *x509.CertificateRequest

获取 certRequest

func (CA) GetCurve

func (this CA) GetCurve() elliptic.Curve

get Options Curve

func (CA) GetErrors

func (this CA) GetErrors() []error

获取错误

func (CA) GetGostCurve

func (this CA) GetGostCurve() *gost.Curve

获取 Curve

func (CA) GetKeyData

func (this CA) GetKeyData() []byte

获取 keyData

func (CA) GetOptions

func (this CA) GetOptions() Options

get Options

func (CA) GetParameterSizes

func (this CA) GetParameterSizes() dsa.ParameterSizes

get DSA ParameterSizes

func (CA) GetPrivateKey

func (this CA) GetPrivateKey() crypto.PrivateKey

获取 PrivateKey

func (CA) GetPrivateKeyType

func (this CA) GetPrivateKeyType() PublicKeyType

get PrivateKey Type

func (CA) GetProbability

func (this CA) GetProbability() int

get Options Probability

func (CA) GetPublicKey

func (this CA) GetPublicKey() crypto.PublicKey

获取 publicKey

func (CA) GetPublicKeyType

func (this CA) GetPublicKeyType() PublicKeyType

get PublicKey Type

func (CA) MakeCA

func (this CA) MakeCA(
	subject pkix.Name,
	expire int,
	signAlgName string,
) CA

生成 CA 证书

func (CA) MakeCSR

func (this CA) MakeCSR(
	commonName string,
	organization []string,
	signAlgName string,
) CA

生成证书请求

func (CA) MakeCert

func (this CA) MakeCert(
	subject pkix.Name,
	expire int,
	dns []string,
	ip []net.IP,
	signAlgName string,
) CA

生成证书

func (CA) OnError

func (this CA) OnError(fn func([]error)) CA

引出错误信息

func (CA) ParseCertificateFromPEM

func (this CA) ParseCertificateFromPEM(cert []byte) (*cryptobin_x509.Certificate, error)

Parse Certificate From PEM

func (CA) ParseCertificateRequestFromPEM

func (this CA) ParseCertificateRequestFromPEM(cert []byte) (*cryptobin_x509.CertificateRequest, error)

Parse Certificate Request From PEM

func (CA) ParsePKCS8PrivateKeyFromPEM

func (this CA) ParsePKCS8PrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)

Parse PKCS8 PrivateKey From PEM

func (CA) ParsePKCS8PrivateKeyFromPEMWithPassword

func (this CA) ParsePKCS8PrivateKeyFromPEMWithPassword(key []byte, password []byte) (crypto.PrivateKey, error)

Parse PKCS8 PrivateKey From PEM With Password

func (CA) ParsePKCS8PublicKeyFromPEM

func (this CA) ParsePKCS8PublicKeyFromPEM(key []byte) (crypto.PublicKey, error)

Parse PKCS8 PublicKey From PEM

func (CA) SetCurve

func (this CA) SetCurve(curve string) CA

set Curve type params: [ P521 | P384 | P256 | P224 ]

func (CA) SetGenerateType

func (this CA) SetGenerateType(typ string) CA

set Generate public key type params: [ RSA | DSA | ECDSA | EdDSA | SM2 | Gost | ElGamal ]

func (CA) SetGostCurve

func (this CA) SetGostCurve(curve string) CA

设置曲线类型 set gost curve 可选参数 / params: IdGostR34102001TestParamSet IdGostR34102001CryptoProAParamSet IdGostR34102001CryptoProBParamSet IdGostR34102001CryptoProCParamSet IdGostR34102001CryptoProXchAParamSet IdGostR34102001CryptoProXchBParamSet Idtc26gost34102012256paramSetA Idtc26gost34102012256paramSetB Idtc26gost34102012256paramSetC Idtc26gost34102012256paramSetD Idtc26gost34102012512paramSetTest Idtc26gost34102012512paramSetA Idtc26gost34102012512paramSetB Idtc26gost34102012512paramSetC

func (CA) SetParameterSizes

func (this CA) SetParameterSizes(ln string) CA

With DSA ParameterSizes params: [ L1024N160 | L2048N224 | L2048N256 | L3072N256 ]

func (CA) SetPublicKeyType

func (this CA) SetPublicKeyType(keyType string) CA

set public key type params: [ RSA | DSA | ECDSA | EdDSA | SM2 | Gost | ElGamal ]

func (CA) ToKeyBytes

func (this CA) ToKeyBytes() []byte

私钥/公钥/cert

func (CA) ToKeyString

func (this CA) ToKeyString() string

私钥/公钥/cert

func (CA) UpdateCert

func (this CA) UpdateCert(fn func(*x509.Certificate)) CA

更新 Cert 数据

func (CA) UpdateCertRequest

func (this CA) UpdateCertRequest(fn func(*x509.CertificateRequest)) CA

更新证书请求数据

func (CA) Verify

func (this CA) Verify(rootPEM string, certPEM string, opts x509.VerifyOptions) (bool, error)

验证

func (CA) WithBits

func (this CA) WithBits(bits int) CA

RSA private key bit size

func (CA) WithBitsize

func (this CA) WithBitsize(bits int) CA

ElGamal private key bit size

func (CA) WithCert

func (this CA) WithCert(cert *x509.Certificate) CA

设置 cert

func (CA) WithCertRequest

func (this CA) WithCertRequest(cert *x509.CertificateRequest) CA

设置 certRequest

func (CA) WithCurve

func (this CA) WithCurve(curve elliptic.Curve) CA

With Curve type

func (CA) WithErrors

func (this CA) WithErrors(errs []error) CA

设置错误

func (CA) WithGostCurve

func (this CA) WithGostCurve(curve *gost.Curve) CA

设置曲线类型 set gost curve

func (CA) WithKeyData

func (this CA) WithKeyData(data []byte) CA

设置 keyData

func (CA) WithOptions

func (this CA) WithOptions(options Options) CA

With options

func (CA) WithParameterSizes

func (this CA) WithParameterSizes(sizes dsa.ParameterSizes) CA

With DSA ParameterSizes

func (CA) WithPrivateKey

func (this CA) WithPrivateKey(key crypto.PrivateKey) CA

设置 PrivateKey

func (CA) WithProbability

func (this CA) WithProbability(probability int) CA

ElGamal private key probability size

func (CA) WithPublicKey

func (this CA) WithPublicKey(key crypto.PublicKey) CA

设置 publicKey

func (CA) WithPublicKeyType

func (this CA) WithPublicKeyType(keyType PublicKeyType) CA

public key type

type Certificate

type Certificate = x509.Certificate

Certificate

type CertificateRequest

type CertificateRequest = x509.CertificateRequest

CertificateRequest

type ExtKeyUsage

type ExtKeyUsage = x509.ExtKeyUsage

ExtKeyUsage

type KeyUsage

type KeyUsage = x509.KeyUsage

KeyUsage

type Options

type Options struct {
	// public key type
	PublicKeyType PublicKeyType

	// generates DSA ParameterSizes
	ParameterSizes dsa.ParameterSizes

	// generates ECC curve
	Curve elliptic.Curve

	// generates Gost curve
	GostCurve *gost.Curve

	// generates RSA private key bit size
	Bits int

	// generates ElGamal private key bit size and probability
	Bitsize, Probability int
}

Options

type Opts

type Opts = pkcs8.Opts

options

type PBKDF2Opts

type PBKDF2Opts = pkcs8.PBKDF2Opts

PBKDF2 options

type PkixAlgorithmIdentifier

type PkixAlgorithmIdentifier = pkix.AlgorithmIdentifier

AlgorithmIdentifier

type PkixAttributeTypeAndValue

type PkixAttributeTypeAndValue = pkix.AttributeTypeAndValue

AttributeTypeAndValue 数据

type PkixAttributeTypeAndValueSET

type PkixAttributeTypeAndValueSET = pkix.AttributeTypeAndValueSET

AttributeTypeAndValueSET

type PkixCertificateList

type PkixCertificateList = pkix.CertificateList

CertificateList

type PkixExtension

type PkixExtension = pkix.Extension

Extension

type PkixName

type PkixName = pkix.Name

Subject data

type PkixRDNSequence

type PkixRDNSequence = pkix.RDNSequence

RDNSequence

type PkixRevokedCertificate

type PkixRevokedCertificate = pkix.RevokedCertificate

RevokedCertificate

type PkixTBSCertificateList

type PkixTBSCertificateList = pkix.TBSCertificateList

TBSCertificateList

type PublicKeyAlgorithm

type PublicKeyAlgorithm = x509.PublicKeyAlgorithm

PublicKeyAlgorithm

type PublicKeyType

type PublicKeyType uint

public key type

const (
	KeyTypeUnknown PublicKeyType = iota
	KeyTypeRSA
	KeyTypeDSA
	KeyTypeECDSA
	KeyTypeEdDSA
	KeyTypeSM2
	KeyTypeGost
	KeyTypeElGamal
)

func (PublicKeyType) String

func (typ PublicKeyType) String() string

type ScryptOpts

type ScryptOpts = pkcs8.ScryptOpts

Scrypt options

type SignatureAlgorithm

type SignatureAlgorithm = x509.SignatureAlgorithm

SignatureAlgorithm

type VerifyOptions

type VerifyOptions = x509.VerifyOptions

VerifyOptions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL