MCPcopy Index your code
hub / github.com/rilldata/rill / decrypt

Function decrypt

admin/database/postgres/postgres.go:4052–4074  ·  view source on GitHub ↗

decrypts the ciphertext using AES-GCM with the given key and returns the plaintext

(ciphertext, key []byte)

Source from the content-addressed store, hash-verified

4050
4051// decrypts the ciphertext using AES-GCM with the given key and returns the plaintext
4052func decrypt(ciphertext, key []byte) ([]byte, error) {
4053 block, err := aes.NewCipher(key)
4054 if err != nil {
4055 return nil, err
4056 }
4057
4058 aesGCM, err := cipher.NewGCM(block)
4059 if err != nil {
4060 return nil, err
4061 }
4062
4063 nonceSize := aesGCM.NonceSize()
4064 if len(ciphertext) < nonceSize {
4065 return nil, errors.New("ciphertext too short")
4066 }
4067
4068 nonce, ciphertext := ciphertext[:nonceSize], ciphertext[nonceSize:]
4069 d, err := aesGCM.Open(nil, nonce, ciphertext, nil)
4070 if err != nil {
4071 return nil, err
4072 }
4073 return d, nil
4074}
4075
4076// validateAttributes validates keys and values of an attributes map, handling nil input
4077func (c *connection) validateAttributes(attributes map[string]any) (map[string]any, error) {

Callers 1

decryptMethod · 0.85

Calls 1

OpenMethod · 0.65

Tested by

no test coverage detected