encdb_sdk

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHECK_CODE_SIZE = 1
	DATA_TYEP_SIZE  = 1
	BITS_SIZE       = 1
	NONCE_SIZE      = 8
	HEADER_SIZE     = CHECK_CODE_SIZE + DATA_TYEP_SIZE + BITS_SIZE
)
View Source
const (
	RDS          ServerVersion = "RDS"            // rds mysql
	POLAR_LAGACY               = "POLARDB_LEGACY" // polardb. encdb version < 1.1.14
	POLAR_1_1_14               = "POLARDB_1.1.14" // polar, encdb version == 1.1.14
)
View Source
const (
	AES_128_CBC SymmAlgo = "AES_128_CBC"
	AES_128_CTR          = "AES_128_CTR"
	AES_128_ECB          = "AES_128_ECB"
	AES_128_GCM          = "AES_128_GCM"
	SM4_128_CBC          = "SM4_128_CBC"
	SM4_128_CTR          = "SM4_128_CTR"
	SM4_128_ECB          = "SM4_128_ECB"
	SM4_128_GCM          = "SM4_128_GCM"
	INVALID              = "INVALID"
)
View Source
const (
	REQUEST_ID_MEK_PROVISION   int = 48
	REQUEST_ID_SERVER_INFO_GET     = 0
	REQUEST_ID_IMPORT_RULE         = 160
)
View Source
const (
	AES_BLOCK_SIZE   = 16
	AES_128_KEY_SIZE = 16
	SM4_BLOCK_SIZE   = 16
	SM4_KEY_SIZE     = 16
	GCM_TAG_SIZE     = 16
	GCM_IV_SIZE      = 12
	CBC_IV_SIZE      = 16
	CTR_IV_SIZE      = 16
)
View Source
const ENCDB_SDK_VERSION = "1.2.15"

Variables

This section is empty.

Functions

func AsymmDecrypt

func AsymmDecrypt(privk_pem string, ciphertext []byte, algo AsymmAlgo) ([]byte, error)

func AsymmEncrypt

func AsymmEncrypt(puk_pem string, plaintext []byte, algo AsymmAlgo) ([]byte, error)

func EnvelopeOpen

func EnvelopeOpen(cc CipherSuite, prik string, envelope []byte) ([]byte, error)

func EnvelopeSeal

func EnvelopeSeal(cc CipherSuite, puk string, data []byte) ([]byte, error)

func HKDF

func HKDF(secret []byte, salt []byte, info []byte, target_size int, alg HashAlgo) []byte

func SymmetricDecrypt

func SymmetricDecrypt(key []byte, alg SymmAlgo, ciphertext []byte) ([]byte, error)

func SymmetricEncrypt

func SymmetricEncrypt(key []byte, alg SymmAlgo, plaintext []byte) []byte

func SymmetricKeyValid

func SymmetricKeyValid(key []byte, alg SymmAlgo) bool

Types

type AsymmAlgo

type AsymmAlgo string
const (
	SM2 AsymmAlgo = "SM2"
	RSA           = "RSA"
)

type CipherSuite

type CipherSuite struct {
	// contains filtered or unexported fields
}

func FromString

func FromString(s string) *CipherSuite

func (*CipherSuite) ToString

func (cs *CipherSuite) ToString() string

type Cryptor

type Cryptor struct {
	Algo            SymmAlgo
	MEK             []byte
	Nonce           []byte
	DEK             []byte
	Server_cs       CipherSuite
	Server_puk      string // pem format
	Server_puk_hash string
	Server_version  ServerVersion
}

func (*Cryptor) Decrypt

func (cryptor *Cryptor) Decrypt(ciphertext []byte) ([]byte, uint8, error)

type EncdbCipher

type EncdbCipher struct {
	// contains filtered or unexported fields
}

Help parse a cipher

func ParseCipher

func ParseCipher(ciphertext []byte) (*EncdbCipher, error)

func (*EncdbCipher) Decrypt

func (encdb_cipher *EncdbCipher) Decrypt(key []byte) ([]byte, error)

func (*EncdbCipher) GetEncAlgo

func (encdb_cipher *EncdbCipher) GetEncAlgo() (SymmAlgo, error)

func (*EncdbCipher) GetType

func (encdb_cipher *EncdbCipher) GetType() uint8

type EncdbSDK

type EncdbSDK struct {
	Cryptor  Cryptor
	Conn     *driver.Conn
	Is_polar bool
}

func (*EncdbSDK) GetServerInfo

func (sdk *EncdbSDK) GetServerInfo()

func (*EncdbSDK) ImportRule

func (sdk *EncdbSDK) ImportRule(rule string) error

func (*EncdbSDK) ProvisionMEK

func (sdk *EncdbSDK) ProvisionMEK() error

type HashAlgo

type HashAlgo string
const (
	SHA256 HashAlgo = "SHA256"
	SM3             = "SM3"
)

type ServerVersion added in v1.0.2

type ServerVersion string

type SymmAlgo

type SymmAlgo string

func FromInt

func FromInt(i uint8) (SymmAlgo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL