Documentation
¶
Index ¶
Constants ¶
const ( RsaCryptoWrap string = "RSA/NONE/PKCS1Padding" KmsAliCryptoWrap string = "KMS/ALICLOUD" AesCtrAlgorithm string = "AES/CTR/NoPadding" )
encryption Algorithm
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CipherData ¶
type CipherData struct {
IV []byte
Key []byte
MatDesc string
WrapAlgorithm string
CEKAlgorithm string
EncryptedIV []byte
EncryptedKey []byte
}
CipherData is secret key information
func (*CipherData) Clone ¶
func (cd *CipherData) Clone() CipherData
func (*CipherData) GetIV ¶
func (cd *CipherData) GetIV() uint64
func (*CipherData) RandomKeyIv ¶
func (cd *CipherData) RandomKeyIv(keyLen int, ivLen int) error
func (*CipherData) SeekIV ¶
func (cd *CipherData) SeekIV(startPos uint64)
func (*CipherData) SetIV ¶
func (cd *CipherData) SetIV(iv uint64)
type ContentCipher ¶
type ContentCipher interface {
EncryptContent(io.Reader) (io.ReadCloser, error)
DecryptContent(io.Reader) (io.ReadCloser, error)
Clone(cd CipherData) (ContentCipher, error)
GetEncryptedLen(int64) int64
GetCipherData() *CipherData
GetAlignLen() int
}
ContentCipher is used to encrypt or decrypt object's data
type ContentCipherBuilder ¶
type ContentCipherBuilder interface {
ContentCipher() (ContentCipher, error)
ContentCipherEnv(Envelope) (ContentCipher, error)
GetMatDesc() string
}
ContentCipherBuilder is used to create ContentCipher for encryting object's data
func CreateAesCtrCipher ¶
func CreateAesCtrCipher(cipher MasterCipher) ContentCipherBuilder
CreateAesCtrCipher creates ContentCipherBuilder
type CryptoDecrypter ¶
type CryptoDecrypter struct {
Body io.Reader
Decrypter io.Reader
// contains filtered or unexported fields
}
CryptoDecrypter provides close method for Decrypter
func (*CryptoDecrypter) Close ¶
func (rc *CryptoDecrypter) Close() error
Close lets the CryptoDecrypter satisfy io.ReadCloser interface
type CryptoEncrypter ¶
type CryptoEncrypter struct {
Body io.Reader
Encrypter io.Reader
// contains filtered or unexported fields
}
CryptoEncrypter provides close method for Encrypter
func (*CryptoEncrypter) Close ¶
func (rc *CryptoEncrypter) Close() error
Close lets the CryptoEncrypter satisfy io.ReadCloser interface
type Envelope ¶
type Envelope struct {
IV string
CipherKey string
MatDesc string
WrapAlg string
CEKAlg string
UnencryptedMD5 string
UnencryptedContentLen string
}
Envelope is stored in oss object's meta
type MasterCipher ¶
type MasterCipher interface {
Encrypt([]byte) ([]byte, error)
Decrypt([]byte) ([]byte, error)
GetWrapAlgorithm() string
GetMatDesc() string
}
MasterCipher encrypt or decrpt CipherData support master key: rsa && ali kms
func CreateMasterRsa ¶
func CreateMasterRsa(matDesc map[string]string, publicKey string, privateKey string) (MasterCipher, error)
CreateMasterRsa Create master key interface implemented by rsa matDesc will be converted to json string
type MasterRsaCipher ¶
MasterRsaCipher rsa master key interface
func (MasterRsaCipher) Decrypt ¶
func (mrc MasterRsaCipher) Decrypt(cryptoData []byte) ([]byte, error)
Decrypt Decrypt data by rsa private key Mainly used to decrypt object's symmetric secret key and iv
func (MasterRsaCipher) Encrypt ¶
func (mrc MasterRsaCipher) Encrypt(plainData []byte) ([]byte, error)
Encrypt encrypt data by rsa public key Mainly used to encrypt object's symmetric secret key and iv
func (MasterRsaCipher) GetMatDesc ¶
func (mrc MasterRsaCipher) GetMatDesc() string
GetMatDesc get master key describe
func (MasterRsaCipher) GetWrapAlgorithm ¶
func (mrc MasterRsaCipher) GetWrapAlgorithm() string
GetWrapAlgorithm get master key wrap algorithm