XuanYang-cn 37a447d166
feat: Add CMEK cipher plugin (#43722)
1. Enable Milvus to read cipher configs
2. Enable cipher plugin in binlog reader and writer
3. Add a testCipher for unittests
4. Support pooling for datanode
5. Add encryption in storagev2

See also: #40321 
Signed-off-by: yangxuan <xuan.yang@zilliz.com>

---------

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
2025-08-27 11:15:52 +08:00

40 lines
888 B
Go

package message
import (
"sync"
"github.com/milvus-io/milvus-proto/go-api/v2/hook"
)
// cipher is a global variable that is used to encrypt and decrypt messages.
// It should be initialized at initialization stage.
var (
cipher hook.Cipher
initOnce sync.Once
)
// RegisterCipher registers a cipher to be used for encrypting and decrypting messages.
// It should be called only once when the program starts and initialization stage.
func RegisterCipher(c hook.Cipher) {
initOnce.Do(func() {
cipher = c
})
}
// mustGetCipher returns the registered cipher.
func mustGetCipher() hook.Cipher {
if cipher == nil {
panic("cipher not registered")
}
return cipher
}
// CipherConfig is the configuration for cipher that is used to encrypt and decrypt messages.
type CipherConfig struct {
// EzID is the encryption zone ID.
EzID int64
// Collection ID
CollectionID int64
}