Documentation
¶
Index ¶
- func NewLibModule() *application.ModuleBuilder
- func NewMainModule() *application.ModuleBuilder
- func NewTestModule() *application.ModuleBuilder
- type CipherMethod
- type Class
- type ComplexAlgorithm
- type Crypt
- type Decrypter
- type Driver
- type DriverManager
- type DriverRegistration
- type Encrypter
- type FlowMode
- type Key
- type KeyData
- type Options
- type Padding
- type PaddingMode
- type PrivateKey
- type PrivateKeyDriver
- type PrivateKeyGenerator
- type PrivateKeyLoader
- type PrivateKeyNative
- type PublicKey
- type PublicKeyDriver
- type PublicKeyLoader
- type SecretKey
- type SecretKeyDriver
- type SecretKeyGenerator
- type SecretKeyLoader
- type SecretKeyNative
- type Signature
- type Signer
- type Verifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CipherMethod ¶
type CipherMethod int
CipherMethod 表示密钥的操作方法
const ( CipherMethodNone CipherMethod = iota CipherMethodDecrypt CipherMethodEncrypt )
定义密钥的操作方法
func (CipherMethod) String ¶
func (m CipherMethod) String() string
type ComplexAlgorithm ¶
type ComplexAlgorithm string
ComplexAlgorithm 是一组由多个单词构成的字符串,表示一组由多种算法构成的密码学套件 它在形式上,可以是: 驼峰命名,如: "SHA256withRSA"; 下划线分隔的小写字符,如: "sha256_with_rsa"; 下划线分隔的大写字符,如: "SHA256_WITH_RSA"; 空格分隔的小写(或大写)字符,如: "SHA256 WITH RSA"; 等。。。 默认形式为:"sha256_with_rsa"
func NewComplexAlgorithm ¶
func NewComplexAlgorithm(words []string) ComplexAlgorithm
NewComplexAlgorithm 新建算法字符串
func (ComplexAlgorithm) Normalize ¶
func (a ComplexAlgorithm) Normalize() ComplexAlgorithm
Normalize 标准化算法字符串
func (ComplexAlgorithm) String ¶
func (a ComplexAlgorithm) String() string
func (ComplexAlgorithm) ToArray ¶
func (a ComplexAlgorithm) ToArray() []string
ToArray 把这个 ComplexAlgorithm 解析为数组
type Crypt ¶
type Crypt struct { Flow FlowMode // 数据块串流模式 Padding PaddingMode // 填充模式 Random io.Reader // 随机数生成器 IV []byte // 初始化向量 Hash crypto.Hash // 摘要算法 CipherText []byte // 密文 PlainText []byte // 明文 }
Crypt 承载加密数据
type Driver ¶
type Driver interface { Algorithm() string Class() Class ListRegistrations() []*DriverRegistration }
Driver 代表密钥的驱动
type DriverManager ¶
type DriverManager interface { Find(algorithm string, class Class) (Driver, error) FindSecretKeyDriver(algorithm string) (SecretKeyDriver, error) FindPublicKeyDriver(algorithm string) (PublicKeyDriver, error) FindPrivateKeyDriver(algorithm string) (PrivateKeyDriver, error) }
DriverManager 代表密钥驱动管理器
type DriverRegistration ¶
type DriverRegistration struct { Algorithm string Class Class Enabled bool Priority int Driver Driver }
DriverRegistration 包含驱动的注册信息
type FlowMode ¶
type FlowMode int
FlowMode 表示密钥的串联模式
type Key ¶
type Key interface { BaseDriver() Driver Class() Class Export(want *KeyData) (*KeyData, error) Fingerprint(h crypto.Hash) []byte }
Key ...
type KeyData ¶
type KeyData struct { Algorithm string // like 'rsa' Encoding string // like 'x509' Format string // like 'pem' ContentType string // like 'application/x-pem' Content []byte }
KeyData 包含密钥的序列化数据
type Options ¶
type Options struct { Size int // in bits Flow FlowMode Padding PaddingMode Hash crypto.Hash Random io.Reader IV []byte }
Options 是通用的选项
type Padding ¶
type Padding interface { Mode() PaddingMode AddPadding(src []byte, blockSize int) ([]byte, error) RemovePadding(src []byte, blockSize int) ([]byte, error) }
Padding 是填充算法的接口
type PaddingMode ¶
type PaddingMode int
PaddingMode 代表一种填充模式
const ( PaddingModeNone PaddingMode = iota // for secret-key NoPadding PaddingPKCS7 PaddingPKCS5 PaddingZeros PaddingISO10126 PaddingANSIX923 // for RSA PaddingOAEP PaddingPKCS1v15 PaddingSessionKey PaddingPSS )
定义一些常用的填充模式
func (PaddingMode) String ¶
func (p PaddingMode) String() string
type PrivateKey ¶
type PrivateKey interface { Key PublicKey() PublicKey Decrypter() Decrypter Signer() Signer Native() PrivateKeyNative Driver() PrivateKeyDriver }
PrivateKey ...
type PrivateKeyDriver ¶
type PrivateKeyDriver interface { Driver Loader() PrivateKeyLoader Generator() PrivateKeyGenerator }
PrivateKeyDriver 代表密钥对的驱动接口
type PrivateKeyGenerator ¶
type PrivateKeyGenerator interface {
Generate(opt *Options) (PrivateKey, error)
}
PrivateKeyGenerator ... 代表密钥对的 生成器 接口
type PrivateKeyLoader ¶
type PrivateKeyLoader interface {
Load(kd *KeyData) (PrivateKey, error)
}
PrivateKeyLoader ... 代表密钥对的 加载器 接口
type PrivateKeyNative ¶
PrivateKeyNative ...
type PublicKey ¶
type PublicKey interface { Key Driver() PublicKeyDriver Encrypter() Encrypter Verifier() Verifier }
PublicKey ...
type PublicKeyDriver ¶
type PublicKeyDriver interface { Driver Loader() PublicKeyLoader }
PublicKeyDriver 代表公钥的驱动接口
type PublicKeyLoader ¶
PublicKeyLoader ... 代表公钥的 加载器 接口
type SecretKey ¶
type SecretKey interface { Key Driver() SecretKeyDriver Decrypter() Decrypter Encrypter() Encrypter Native() SecretKeyNative }
SecretKey ...
type SecretKeyDriver ¶
type SecretKeyDriver interface { Driver Loader() SecretKeyLoader Generator() SecretKeyGenerator }
SecretKeyDriver 代表对称密钥的驱动接口
type SecretKeyGenerator ¶
SecretKeyGenerator ... 代表密钥的 生成器 接口
type SecretKeyLoader ¶
SecretKeyLoader ... 代表密钥的 加载器 接口
type SecretKeyNative ¶
SecretKeyNative ...