Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSP ¶
type CSP interface { // Hash returns the hash data against the specified algorithm Hash(algo string, origin []byte) ([]byte, error) // Enc returns the encrypted data against the specified algorithm Enc(algo, key, keyPwd string, plainText []byte, mode string) ([]byte, error) // Dec returns the decrypted data against the specified algorithm Dec(algo, key, keyPwd string, cipherText []byte, mode string) ([]byte, error) // HMac returns the hmac data against the specified algorithm HMac(algo, key string, plain []byte) ([]byte, error) // Sign returns the signature data against the specified algorithm Sign(algo, key, keyPwd string, plain []byte) ([]byte, error) // Verify returns the verification result against the specified algorithm Verify(algo, key string, plain, sig []byte) (bool, error) // GenSymKey return a fixed length random key against algo GenSymKey(algo string, keySize int) ([]byte, error) }
CSP - crypto service provider
var (
Csp CSP
)
func InitCrypto ¶
func InitCrypto(cfg *CryptoConfig) (CSP, error)
InitCrypto returns a new crypto instance. support soft and hsm
type CommonConfig ¶
type CommonConfig struct { ServerNo string `yaml:"server_no"` Port int `yaml:"port"` TLS TLSConfig `yaml:"tls"` }
CommonConfig - common config
type Config ¶
type Config struct { Common CommonConfig `yaml:"common"` Log LogConfig `yaml:"log"` Crypto CryptoConfig `yaml:"crypto"` DB DBConfig `yaml:"db"` Task TaskConfig `yaml:"task"` SignCrtBytes []byte SignKeyBytes []byte TlsCrtBytes []byte TlsKeyBytes []byte CaCrtBytes []byte }
Config - config
var Conf *Config
Conf -
type CryptoConfig ¶
CryptoConfig - crypto config
type TLSConfig ¶
type TLSConfig struct { Enable bool `yaml:"enable"` CrtPath string `yaml:"crt_path"` KeyPath string `yaml:"key_path"` CaPath string `yaml:"ca_path"` Mutual bool `yaml:"mutual"` }
TLSConfig - tls config for grpc server
type TaskConfig ¶
TaskConfig - task config
Click to show internal directories.
Click to hide internal directories.