Documentation ¶
Index ¶
- Variables
- func AddCipher(oid asn1.ObjectIdentifier, cipher Cipher)
- func AddKDF(oid asn1.ObjectIdentifier, params KDFParameters)
- func DecryptPEMBlock(block *pem.Block, password []byte) ([]byte, error)
- func DecryptPKCS8PrivateKey(data, password []byte) ([]byte, error)
- func EncryptPKCS8PrivateKey(rand io.Reader, blockType string, data []byte, password []byte, opts ...Opts) (*pem.Block, error)
- type Cipher
- type CipherBlock
- type KDFOpts
- type KDFParameters
- type Opts
- type PBKDF2Opts
- type ScryptOpts
Constants ¶
This section is empty.
Variables ¶
View Source
var AES128CBC = CipherBlock{ // contains filtered or unexported fields }
View Source
var AES192CBC = CipherBlock{ // contains filtered or unexported fields }
View Source
var AES256CBC = CipherBlock{ // contains filtered or unexported fields }
View Source
var DESCBC = CipherBlock{ // contains filtered or unexported fields }
View Source
var DESEDE3CBC = CipherBlock{ // contains filtered or unexported fields }
View Source
var DefaultOpts = Opts{ Cipher: AES256CBC, KDFOpts: PBKDF2Opts{ SaltSize: 16, IterationCount: 10000, HMACHash: crypto.SHA256, }, }
默认配置
Functions ¶
func AddKDF ¶ added in v1.0.1018
func AddKDF(oid asn1.ObjectIdentifier, params KDFParameters)
添加 kdf 方式
func DecryptPEMBlock ¶
解出 PEM 块
func DecryptPKCS8PrivateKey ¶
解出 PKCS8 密钥 加密方式: AES-128-CBC | AES-192-CBC | AES-256-CBC | DES | 3DES
Types ¶
type Cipher ¶ added in v1.0.1018
type Cipher interface { BlockSize() int KeySize() int Encrypt(key, iv, plaintext []byte) ([]byte, error) Decrypt(key, iv, ciphertext []byte) ([]byte, error) OID() asn1.ObjectIdentifier }
加密接口
type CipherBlock ¶ added in v1.0.1018
type CipherBlock struct {
// contains filtered or unexported fields
}
加密
func (CipherBlock) BlockSize ¶ added in v1.0.1018
func (this CipherBlock) BlockSize() int
func (CipherBlock) Decrypt ¶ added in v1.0.1018
func (this CipherBlock) Decrypt(key, iv, ciphertext []byte) ([]byte, error)
解密
func (CipherBlock) Encrypt ¶ added in v1.0.1018
func (this CipherBlock) Encrypt(key, iv, plaintext []byte) ([]byte, error)
加密
func (CipherBlock) KeySize ¶ added in v1.0.1018
func (this CipherBlock) KeySize() int
func (CipherBlock) OID ¶ added in v1.0.1018
func (this CipherBlock) OID() asn1.ObjectIdentifier
type KDFOpts ¶ added in v1.0.1018
type KDFOpts interface { DeriveKey(password, salt []byte, size int) (key []byte, params KDFParameters, err error) GetSaltSize() int OID() asn1.ObjectIdentifier }
KDF 设置接口
type KDFParameters ¶ added in v1.0.1018
数据接口
type PBKDF2Opts ¶ added in v1.0.1018
PBKDF2 配置
func (PBKDF2Opts) DeriveKey ¶ added in v1.0.1018
func (this PBKDF2Opts) DeriveKey(password, salt []byte, size int) (key []byte, params KDFParameters, err error)
func (PBKDF2Opts) GetSaltSize ¶ added in v1.0.1018
func (this PBKDF2Opts) GetSaltSize() int
func (PBKDF2Opts) OID ¶ added in v1.0.1018
func (this PBKDF2Opts) OID() asn1.ObjectIdentifier
type ScryptOpts ¶ added in v1.0.1018
type ScryptOpts struct { SaltSize int CostParameter int BlockSize int ParallelizationParameter int }
ScryptOpts 设置
func (ScryptOpts) DeriveKey ¶ added in v1.0.1018
func (this ScryptOpts) DeriveKey(password, salt []byte, size int) (key []byte, params KDFParameters, err error)
func (ScryptOpts) GetSaltSize ¶ added in v1.0.1018
func (this ScryptOpts) GetSaltSize() int
func (ScryptOpts) OID ¶ added in v1.0.1018
func (this ScryptOpts) OID() asn1.ObjectIdentifier
Click to show internal directories.
Click to hide internal directories.