returns the decrypted text, using the encryption key id provided. If the key id is empty, the text is returned as is.
(text []byte, encKeyID string)
| 3920 | |
| 3921 | // returns the decrypted text, using the encryption key id provided. If the key id is empty, the text is returned as is. |
| 3922 | func (c *connection) decrypt(text []byte, encKeyID string) ([]byte, error) { |
| 3923 | if encKeyID == "" { |
| 3924 | return text, nil |
| 3925 | } |
| 3926 | var encKey *database.EncryptionKey |
| 3927 | for _, key := range c.encKeyring { |
| 3928 | if key.ID == encKeyID { |
| 3929 | encKey = key |
| 3930 | break |
| 3931 | } |
| 3932 | } |
| 3933 | if encKey == nil { |
| 3934 | return nil, fmt.Errorf("encryption key id %s not found in keyring", encKeyID) |
| 3935 | } |
| 3936 | return decrypt(text, encKey.Secret) |
| 3937 | } |
| 3938 | |
| 3939 | func checkUpdateRow(target string, res sql.Result, err error) error { |
| 3940 | if err != nil { |
no test coverage detected