Refactor vault functionality to dedicated package, fix import cycles with interface pattern, fix tests

This commit is contained in:
2025-05-29 12:48:36 -07:00
parent c33385be6c
commit ddb395901b
18 changed files with 1847 additions and 2128 deletions

View File

@@ -48,6 +48,11 @@ func encryptToRecipient(data []byte, recipient age.Recipient) ([]byte, error) {
return EncryptToRecipient(data, recipient)
}
// DecryptWithIdentity decrypts data with an identity using age (public version)
func DecryptWithIdentity(data []byte, identity age.Identity) ([]byte, error) {
return decryptWithIdentity(data, identity)
}
// decryptWithIdentity decrypts data with an identity using age
func decryptWithIdentity(data []byte, identity age.Identity) ([]byte, error) {
r, err := age.Decrypt(bytes.NewReader(data), identity)
@@ -63,6 +68,11 @@ func decryptWithIdentity(data []byte, identity age.Identity) ([]byte, error) {
return result, nil
}
// EncryptWithPassphrase encrypts data using a passphrase with age's scrypt-based encryption (public version)
func EncryptWithPassphrase(data []byte, passphrase string) ([]byte, error) {
return encryptWithPassphrase(data, passphrase)
}
// encryptWithPassphrase encrypts data using a passphrase with age's scrypt-based encryption
func encryptWithPassphrase(data []byte, passphrase string) ([]byte, error) {
recipient, err := age.NewScryptRecipient(passphrase)