Documentation ¶
Index ¶
- Variables
- func AddCipher(oid asn1.ObjectIdentifier, cipher func() Cipher)
- func AddKey(name string, key func() Key)
- func DecodeData(encodedData, password []byte) ([]byte, error)
- func DecryptedPrivateKeyInfo(data []byte) ([]byte, error)
- func EncodeData(data []byte, password string, cipher ...Cipher) ([]byte, error)
- func EncryptedPrivateKeyInfo(algorithm asn1.ObjectIdentifier, data []byte) ([]byte, error)
- func GetStructName(name any) string
- func MarshalPKCS8PrivateKey(privateKey crypto.PrivateKey) ([]byte, error)
- func ParsePKCS8PrivateKey(pkData []byte) (privateKey crypto.PrivateKey, err error)
- type Cipher
- type CipherBlockCBC
- func (this CipherBlockCBC) Decrypt(password, params, ciphertext []byte) ([]byte, error)
- func (this CipherBlockCBC) Encrypt(password, plaintext []byte) ([]byte, []byte, error)
- func (this CipherBlockCBC) KeySize() int
- func (this CipherBlockCBC) OID() asn1.ObjectIdentifier
- func (this CipherBlockCBC) WithSaltSize(saltSize int) CipherBlockCBC
- type JceksDecode
- func (this *JceksDecode) GetCert(alias string) (*x509.Certificate, error)
- func (this *JceksDecode) GetPrivateKeyAndCerts(alias string, password string) (key crypto.PrivateKey, certs []*x509.Certificate, err error)
- func (this *JceksDecode) GetSecretKey(alias string, password string) (key []byte, err error)
- func (this *JceksDecode) ListCerts() []string
- func (this *JceksDecode) ListPrivateKeys() []string
- func (this *JceksDecode) ListSecretKeys() []string
- func (this *JceksDecode) Parse(r io.Reader, password string) error
- func (this *JceksDecode) String() string
- type JceksEncode
- func (this *JceksEncode) AddPrivateKey(alias string, privateKey crypto.PrivateKey, password string, certs [][]byte, ...) error
- func (this *JceksEncode) AddSecretKey(alias string, secretKey []byte, password string, cipher ...Cipher) error
- func (this *JceksEncode) AddTrustedCert(alias string, cert []byte, cipher ...Cipher) error
- func (this *JceksEncode) Marshal(password string) ([]byte, error)
- type JksDecode
- func (this *JksDecode) GetCert(alias string) (*x509.Certificate, error)
- func (this *JksDecode) GetCertChain(alias string) ([]*x509.Certificate, error)
- func (this *JksDecode) GetCreateDate(alias string) (time.Time, error)
- func (this *JksDecode) GetEncodedKey(alias string) ([]byte, error)
- func (this *JksDecode) GetPrivateKey(alias string, password string) (crypto.PrivateKey, error)
- func (this *JksDecode) ListCerts() []string
- func (this *JksDecode) ListPrivateKeys() []string
- func (this *JksDecode) Parse(r io.Reader, password string) error
- func (this *JksDecode) String() string
- type JksEncode
- func (this *JksEncode) AddEncodedPrivateKey(alias string, encodedKey []byte, certChain [][]byte) error
- func (this *JksEncode) AddPrivateKey(alias string, privateKey crypto.PrivateKey, password string, ...) error
- func (this *JksEncode) AddTrustedCert(alias string, cert []byte) error
- func (this *JksEncode) Marshal(password string) ([]byte, error)
- type Key
- type KeyDSA
- type KeyEcdsa
- type KeyEdDSA
- type KeyRsa
- type KeySM2
Constants ¶
This section is empty.
Variables ¶
View Source
var CipherMD5And3DES = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var CipherSHA1And3DES = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var DefaultCipher = CipherMD5And3DES
默认配置
View Source
var LoadFromBytes = LoadJceksFromBytes
View Source
var LoadFromReader = LoadJceksFromReader
别名
View Source
var NewEncode = NewJceksEncode
Functions ¶
func EncodeData ¶
加密数据
func EncryptedPrivateKeyInfo ¶
func EncryptedPrivateKeyInfo(algorithm asn1.ObjectIdentifier, data []byte) ([]byte, error)
加密数据
func MarshalPKCS8PrivateKey ¶
func MarshalPKCS8PrivateKey(privateKey crypto.PrivateKey) ([]byte, error)
从注册的 key 列表编码证书
func ParsePKCS8PrivateKey ¶
func ParsePKCS8PrivateKey(pkData []byte) (privateKey crypto.PrivateKey, err error)
从注册的 key 列表解析证书
Types ¶
type Cipher ¶
type Cipher interface { // oid OID() asn1.ObjectIdentifier // 值大小 KeySize() int // 加密, 返回: [加密后数据, 参数, error] Encrypt(key, plaintext []byte) ([]byte, []byte, error) // 解密 Decrypt(key, params, ciphertext []byte) ([]byte, error) }
加密接口
type CipherBlockCBC ¶
type CipherBlockCBC struct {
// contains filtered or unexported fields
}
cbc 模式加密
func (CipherBlockCBC) Decrypt ¶
func (this CipherBlockCBC) Decrypt(password, params, ciphertext []byte) ([]byte, error)
解密
func (CipherBlockCBC) Encrypt ¶
func (this CipherBlockCBC) Encrypt(password, plaintext []byte) ([]byte, []byte, error)
加密
func (CipherBlockCBC) WithSaltSize ¶
func (this CipherBlockCBC) WithSaltSize(saltSize int) CipherBlockCBC
设置 saltSize
type JceksDecode ¶
type JceksDecode struct {
// contains filtered or unexported fields
}
Jceks 解析
func LoadJceksFromBytes ¶
func LoadJceksFromBytes(data []byte, password string) (*JceksDecode, error)
LoadFromBytes loads the key store from the bytes data.
func LoadJceksFromReader ¶
func LoadJceksFromReader(reader io.Reader, password string) (*JceksDecode, error)
LoadFromReader loads the key store from the specified file.
func (*JceksDecode) GetCert ¶
func (this *JceksDecode) GetCert(alias string) (*x509.Certificate, error)
GetCert
func (*JceksDecode) GetPrivateKeyAndCerts ¶
func (this *JceksDecode) GetPrivateKeyAndCerts(alias string, password string) ( key crypto.PrivateKey, certs []*x509.Certificate, err error, )
GetPrivateKeyAndCerts
func (*JceksDecode) GetSecretKey ¶
func (this *JceksDecode) GetSecretKey(alias string, password string) (key []byte, err error)
GetSecretKey
func (*JceksDecode) ListPrivateKeys ¶
func (this *JceksDecode) ListPrivateKeys() []string
ListPrivateKeys
func (*JceksDecode) ListSecretKeys ¶
func (this *JceksDecode) ListSecretKeys() []string
ListSecretKeys lists the names of the SecretKey stored in the key store.
func (*JceksDecode) String ¶
func (this *JceksDecode) String() string
type JceksEncode ¶
type JceksEncode struct {
// contains filtered or unexported fields
}
编码
func (*JceksEncode) AddPrivateKey ¶
func (this *JceksEncode) AddPrivateKey( alias string, privateKey crypto.PrivateKey, password string, certs [][]byte, cipher ...Cipher, ) error
添加私钥
func (*JceksEncode) AddSecretKey ¶
func (this *JceksEncode) AddSecretKey( alias string, secretKey []byte, password string, cipher ...Cipher, ) error
添加密钥
func (*JceksEncode) AddTrustedCert ¶
func (this *JceksEncode) AddTrustedCert( alias string, cert []byte, cipher ...Cipher, ) error
添加证书
type JksDecode ¶
type JksDecode struct {
// contains filtered or unexported fields
}
Jks 解析
func LoadJksFromBytes ¶
LoadFromBytes loads the key store from the bytes data.
func LoadJksFromReader ¶
LoadJksFromReader loads the key store from the specified file.
func (*JksDecode) GetCert ¶
func (this *JksDecode) GetCert(alias string) (*x509.Certificate, error)
GetCertificate
func (*JksDecode) GetCertChain ¶
func (this *JksDecode) GetCertChain(alias string) ([]*x509.Certificate, error)
GetCertificateChain
func (*JksDecode) GetCreateDate ¶
GetCreationDate
func (*JksDecode) GetEncodedKey ¶
GetEncodedKey
func (*JksDecode) GetPrivateKey ¶
GetKey
func (*JksDecode) ListPrivateKeys ¶
ListPrivateKeys
type JksEncode ¶
type JksEncode struct {
// contains filtered or unexported fields
}
编码
func (*JksEncode) AddEncodedPrivateKey ¶
func (this *JksEncode) AddEncodedPrivateKey( alias string, encodedKey []byte, certChain [][]byte, ) error
添加私钥
func (*JksEncode) AddPrivateKey ¶
func (this *JksEncode) AddPrivateKey( alias string, privateKey crypto.PrivateKey, password string, certChain [][]byte, ) error
添加私钥
func (*JksEncode) AddTrustedCert ¶
添加密钥
type Key ¶
type Key interface { // 包装 PKCS8 证书 MarshalPKCS8PrivateKey(privateKey crypto.PrivateKey) (pkData []byte, err error) // 解析 PKCS8 证书 ParsePKCS8PrivateKey(pkData []byte) (crypto.PrivateKey, error) }
Key 接口
type KeyDSA ¶
type KeyDSA struct{}
DSA
func (KeyDSA) MarshalPKCS8PrivateKey ¶
func (this KeyDSA) MarshalPKCS8PrivateKey(privateKey crypto.PrivateKey) ([]byte, error)
包装
func (KeyDSA) ParsePKCS8PrivateKey ¶
func (this KeyDSA) ParsePKCS8PrivateKey(pkData []byte) (crypto.PrivateKey, error)
解析
type KeyEcdsa ¶
type KeyEcdsa struct{}
Ecdsa
func (KeyEcdsa) MarshalPKCS8PrivateKey ¶
func (this KeyEcdsa) MarshalPKCS8PrivateKey(privateKey crypto.PrivateKey) ([]byte, error)
包装
func (KeyEcdsa) ParsePKCS8PrivateKey ¶
func (this KeyEcdsa) ParsePKCS8PrivateKey(pkData []byte) (crypto.PrivateKey, error)
解析
type KeyEdDSA ¶
type KeyEdDSA struct{}
EdDSA
func (KeyEdDSA) MarshalPKCS8PrivateKey ¶
func (this KeyEdDSA) MarshalPKCS8PrivateKey(privateKey crypto.PrivateKey) ([]byte, error)
包装
func (KeyEdDSA) ParsePKCS8PrivateKey ¶
func (this KeyEdDSA) ParsePKCS8PrivateKey(pkData []byte) (crypto.PrivateKey, error)
解析
type KeyRsa ¶
type KeyRsa struct{}
rsa
func (KeyRsa) MarshalPKCS8PrivateKey ¶
func (this KeyRsa) MarshalPKCS8PrivateKey(privateKey crypto.PrivateKey) ([]byte, error)
包装
func (KeyRsa) ParsePKCS8PrivateKey ¶
func (this KeyRsa) ParsePKCS8PrivateKey(pkData []byte) (crypto.PrivateKey, error)
解析
type KeySM2 ¶
type KeySM2 struct{}
SM2
func (KeySM2) MarshalPKCS8PrivateKey ¶
func (this KeySM2) MarshalPKCS8PrivateKey(privateKey crypto.PrivateKey) ([]byte, error)
包装
func (KeySM2) ParsePKCS8PrivateKey ¶
func (this KeySM2) ParsePKCS8PrivateKey(pkData []byte) (crypto.PrivateKey, error)
解析
Source Files ¶
- binary.go
- cipher.go
- cipher_blockcbc.go
- cipher_key.go
- cipher_setting.go
- consts.go
- jceks.go
- jceks_decode.go
- jceks_encode.go
- jceks_entry.go
- jceks_interface.go
- jceks_utils.go
- jks.go
- jks_decode.go
- jks_encode.go
- jks_encryptkey.go
- jks_utils.go
- key.go
- key_dsa.go
- key_ecdsa.go
- key_eddsa.go
- key_rsa.go
- key_setting.go
- key_sm2.go
Click to show internal directories.
Click to hide internal directories.