Documentation ¶
Overview ¶
Package kms provides a simple kms interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EncryptedData ¶
type EncryptedData struct { Version EncryptedDataVer KekID uint16 DekID []byte Ciphertext []byte }
EncryptedData encrypted data
func (EncryptedData) Marshal ¶
func (e EncryptedData) Marshal() (data []byte, err error)
Marshal marshal to bytes
func (EncryptedData) MarshalToString ¶ added in v4.6.0
func (e EncryptedData) MarshalToString() (string, error)
MarshalToString marshal to string
func (*EncryptedData) Unmarshal ¶
func (e *EncryptedData) Unmarshal(data []byte) error
Unmarshal unmarshal from bytes
func (*EncryptedData) UnmarshalFromString ¶ added in v4.6.0
func (e *EncryptedData) UnmarshalFromString(s string) error
UnmarshalFromString unmarshal from string
type EncryptedDataVer ¶
type EncryptedDataVer uint8
EncryptedDataVer version of encrypted data
const ( // EncryptedItemVer1 encrypted item in ver1 layout // // type EncryptedItem struct { // Version EncryptedItemVer // KekID uint16 // DekID []byte // Ciphertext []byte // } // // layout: // // - [0,1): version // - [1,3): dek id length // - [3,5): kek id // - [5,5+len(dek id)): dek id // - [5+len(dek id),5+len(dek id)+len(ciphertext)]: ciphertext EncryptedItemVer1 EncryptedDataVer = iota )
type Interface ¶
type Interface interface { // Status get current status Status() Status // AddKek add new kek AddKek(ctx context.Context, kekID uint16, kek []byte) error // Kek get current used kek Kek(ctx context.Context) (kekID uint16, kek []byte, err error) // Keks export all keks Keks(ctx context.Context) (keks map[uint16][]byte, err error) // DeriveKeyByID derive key by specific kek id and dek id DeriveKeyByID(ctx context.Context, kekID uint16, dekID []byte, length int) (dek []byte, err error) // DeriveKey derive random key by current kek DeriveKey(ctx context.Context, length int) (kekID uint16, dekID, dek []byte, err error) // Encrypt encrypt data Encrypt(ctx context.Context, plaintext, additionalData []byte) (ed *EncryptedData, err error) // Decrypt decrypt data Decrypt(ctx context.Context, ed *EncryptedData, additionalData []byte) (plaintext []byte, err error) }
Interface interface of kms
Click to show internal directories.
Click to hide internal directories.