Documentation ¶
Index ¶
- Constants
- Variables
- func AesEcbPkcs5PaddingDecrypt(cipherContent, key []byte) (retBytes []byte, err error)
- func AesEcbPkcs5PaddingEncrypt(plainContent, key []byte) (retBytes []byte, err error)
- func BlockDecrypt(src []byte, b cipher.Block) (dst []byte, err error)
- func BlockEncrypt(src []byte, b cipher.Block) (dst []byte, err error)
- func GetDefaultKMSv1KeyId() string
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func RegisterConfigEncryptionKmsPlugins(encryptionHandler Handler, clientConfig constant.ClientConfig)
- type Handler
- type HandlerParam
- type KmsAes128Plugin
- func (k *KmsAes128Plugin) AlgorithmName() string
- func (k *KmsAes128Plugin) Decrypt(param *HandlerParam) error
- func (k *KmsAes128Plugin) DecryptSecretKey(param *HandlerParam) (string, error)
- func (k *KmsAes128Plugin) Encrypt(param *HandlerParam) error
- func (k *KmsAes128Plugin) EncryptSecretKey(param *HandlerParam) (string, error)
- func (k *KmsAes128Plugin) GenerateSecretKey(param *HandlerParam) (string, error)
- type KmsAes256Plugin
- func (k *KmsAes256Plugin) AlgorithmName() string
- func (k *KmsAes256Plugin) Decrypt(param *HandlerParam) error
- func (k *KmsAes256Plugin) DecryptSecretKey(param *HandlerParam) (string, error)
- func (k *KmsAes256Plugin) Encrypt(param *HandlerParam) error
- func (k *KmsAes256Plugin) EncryptSecretKey(param *HandlerParam) (string, error)
- func (k *KmsAes256Plugin) GenerateSecretKey(param *HandlerParam) (string, error)
- type KmsBasePlugin
- func (k *KmsBasePlugin) AlgorithmName() string
- func (k *KmsBasePlugin) Decrypt(param *HandlerParam) error
- func (k *KmsBasePlugin) DecryptSecretKey(param *HandlerParam) (string, error)
- func (k *KmsBasePlugin) Encrypt(param *HandlerParam) error
- func (k *KmsBasePlugin) EncryptSecretKey(param *HandlerParam) (string, error)
- func (k *KmsBasePlugin) GenerateSecretKey(param *HandlerParam) (string, error)
- type KmsClient
- func (kmsClient *KmsClient) Decrypt(cipherContent string) (string, error)
- func (kmsClient *KmsClient) Encrypt(content, keyId string) (string, error)
- func (kmsClient *KmsClient) GenerateDataKey(keyId, keySpec string) (string, string, error)
- func (kmsClient *KmsClient) GetKmsVersion() constant.KMSVersion
- type KmsHandler
- type Plugin
Constants ¶
View Source
const ( CipherPrefix = "cipher-" KmsAes128AlgorithmName = "cipher-kms-aes-128" KmsAes256AlgorithmName = "cipher-kms-aes-256" KmsAlgorithmName = "cipher" KmsHandlerName = "KmsHandler" )
Variables ¶
View Source
var ( DataIdParamCheckError = fmt.Errorf("dataId prefix should start with: %s", CipherPrefix) ContentParamCheckError = fmt.Errorf("content need to encrypt is nil") KeyIdParamCheckError = fmt.Errorf("keyId is nil, need to be set") )
View Source
var ( EmptyEncryptedDataKeyError = fmt.Errorf("empty encrypted data key error") EmptyPlainDataKeyError = fmt.Errorf("empty plain data key error") EmptyContentError = fmt.Errorf("encrypt empty content error") )
View Source
var ( EmptyRegionKmsV1ClientInitError = fmt.Errorf("init kmsV1 client failed with empty region") EmptyAkKmsV1ClientInitError = fmt.Errorf("init kmsV1 client failed with empty ak") EmptySkKmsV1ClientInitError = fmt.Errorf("init kmsV1 client failed with empty sk") EmptyEndpointKmsV3ClientInitError = fmt.Errorf("init kmsV3 client failed with empty endpoint") EmptyPasswordKmsV3ClientInitError = fmt.Errorf("init kmsV3 client failed with empty password") EmptyClientKeyContentKmsV3ClientInitError = fmt.Errorf("init kmsV3 client failed with empty client key content") EmptyCaVerifyKmsV3ClientInitError = fmt.Errorf("init kmsV3 client failed with empty ca verify") )
View Source
var (
PluginNotFoundError = fmt.Errorf("cannot find encryption plugin by dataId prefix")
)
Functions ¶
func GetDefaultKMSv1KeyId ¶
func GetDefaultKMSv1KeyId() string
func PKCS5Padding ¶
func PKCS5UnPadding ¶
func RegisterConfigEncryptionKmsPlugins ¶
func RegisterConfigEncryptionKmsPlugins(encryptionHandler Handler, clientConfig constant.ClientConfig)
Types ¶
type Handler ¶
type Handler interface { EncryptionHandler(*HandlerParam) error DecryptionHandler(*HandlerParam) error RegisterPlugin(Plugin) error GetHandlerName() string }
func NewKmsHandler ¶
func NewKmsHandler() Handler
type HandlerParam ¶
type KmsAes128Plugin ¶
type KmsAes128Plugin struct {
// contains filtered or unexported fields
}
func (*KmsAes128Plugin) AlgorithmName ¶
func (k *KmsAes128Plugin) AlgorithmName() string
func (*KmsAes128Plugin) Decrypt ¶
func (k *KmsAes128Plugin) Decrypt(param *HandlerParam) error
func (*KmsAes128Plugin) DecryptSecretKey ¶
func (k *KmsAes128Plugin) DecryptSecretKey(param *HandlerParam) (string, error)
func (*KmsAes128Plugin) Encrypt ¶
func (k *KmsAes128Plugin) Encrypt(param *HandlerParam) error
func (*KmsAes128Plugin) EncryptSecretKey ¶
func (k *KmsAes128Plugin) EncryptSecretKey(param *HandlerParam) (string, error)
func (*KmsAes128Plugin) GenerateSecretKey ¶
func (k *KmsAes128Plugin) GenerateSecretKey(param *HandlerParam) (string, error)
type KmsAes256Plugin ¶
type KmsAes256Plugin struct {
// contains filtered or unexported fields
}
func (*KmsAes256Plugin) AlgorithmName ¶
func (k *KmsAes256Plugin) AlgorithmName() string
func (*KmsAes256Plugin) Decrypt ¶
func (k *KmsAes256Plugin) Decrypt(param *HandlerParam) error
func (*KmsAes256Plugin) DecryptSecretKey ¶
func (k *KmsAes256Plugin) DecryptSecretKey(param *HandlerParam) (string, error)
func (*KmsAes256Plugin) Encrypt ¶
func (k *KmsAes256Plugin) Encrypt(param *HandlerParam) error
func (*KmsAes256Plugin) EncryptSecretKey ¶
func (k *KmsAes256Plugin) EncryptSecretKey(param *HandlerParam) (string, error)
func (*KmsAes256Plugin) GenerateSecretKey ¶
func (k *KmsAes256Plugin) GenerateSecretKey(param *HandlerParam) (string, error)
type KmsBasePlugin ¶
type KmsBasePlugin struct {
// contains filtered or unexported fields
}
func (*KmsBasePlugin) AlgorithmName ¶
func (k *KmsBasePlugin) AlgorithmName() string
func (*KmsBasePlugin) Decrypt ¶
func (k *KmsBasePlugin) Decrypt(param *HandlerParam) error
func (*KmsBasePlugin) DecryptSecretKey ¶
func (k *KmsBasePlugin) DecryptSecretKey(param *HandlerParam) (string, error)
func (*KmsBasePlugin) Encrypt ¶
func (k *KmsBasePlugin) Encrypt(param *HandlerParam) error
func (*KmsBasePlugin) EncryptSecretKey ¶
func (k *KmsBasePlugin) EncryptSecretKey(param *HandlerParam) (string, error)
func (*KmsBasePlugin) GenerateSecretKey ¶
func (k *KmsBasePlugin) GenerateSecretKey(param *HandlerParam) (string, error)
type KmsClient ¶
type KmsClient struct { *dkms_transfer.KmsTransferClient // contains filtered or unexported fields }
func (*KmsClient) GenerateDataKey ¶
func (*KmsClient) GetKmsVersion ¶
func (kmsClient *KmsClient) GetKmsVersion() constant.KMSVersion
type KmsHandler ¶
type KmsHandler struct {
// contains filtered or unexported fields
}
func (*KmsHandler) DecryptionHandler ¶
func (d *KmsHandler) DecryptionHandler(param *HandlerParam) error
func (*KmsHandler) EncryptionHandler ¶
func (d *KmsHandler) EncryptionHandler(param *HandlerParam) error
func (*KmsHandler) GetHandlerName ¶
func (d *KmsHandler) GetHandlerName() string
func (*KmsHandler) RegisterPlugin ¶
func (d *KmsHandler) RegisterPlugin(plugin Plugin) error
type Plugin ¶
type Plugin interface { Encrypt(*HandlerParam) error Decrypt(*HandlerParam) error AlgorithmName() string GenerateSecretKey(*HandlerParam) (string, error) EncryptSecretKey(*HandlerParam) (string, error) DecryptSecretKey(*HandlerParam) (string, error) }
Click to show internal directories.
Click to hide internal directories.