Documentation
¶
Overview ¶
Package backupcrypt implements the versioned authenticated encrypted backup artifact format (OSS-236). Artifacts are AES-256-GCM in chunked streaming mode so memory stays bounded for large worlds: every 64 KiB chunk is authenticated before it is written, the key ID is bound into the authentication data, and a truncated or tampered artifact always fails closed. The format is self-describing: magic, version and key ID precede the ciphertext so a restore can pick the right key and legacy plaintext archives stay recognizable.
Index ¶
Constants ¶
const (
Version = 1
)
Variables ¶
var ( // ErrWrongKey reports a key that does not match the artifact's key ID or // fails authentication. No plaintext is produced. ErrWrongKey = errors.New("backup encryption key does not match the artifact") // ErrTampered reports an artifact that failed authentication or framing. ErrTampered = errors.New("encrypted backup artifact is corrupt or tampered") // ErrBadFormat reports a file that is not this artifact format. ErrBadFormat = errors.New("not an encrypted backup artifact") // ErrKeyMissing reports that encryption is expected but no key is // configured. The explicit disabled-encryption state is "no key". ErrKeyMissing = errors.New("backup is encrypted but no encryption key is configured") )
Functions ¶
func DecryptFile ¶
DecryptFile verifies and decrypts srcPath into dstPath under key. Every chunk is authenticated before it is written and the whole artifact must verify, so a wrong key or tampering produces no usable plaintext and never an unauthenticated write.
func EncryptFile ¶
EncryptFile writes srcPath to dstPath as a versioned authenticated artifact under key. Streaming and bounded: at most one chunk is held in memory at a time.
func EncryptedKeyID ¶
EncryptedKeyID returns the key ID recorded in an artifact header.
func IsEncrypted ¶
IsEncrypted reports whether the file starts with the artifact magic.
Types ¶
type Key ¶
type Key struct {
ID string
// contains filtered or unexported fields
}
Key is a backup encryption key with its non-secret rotation label.
func ParseKey ¶
ParseKey decodes key material (base64 or hex, 32 bytes) and attaches the key ID recorded with every artifact. The key material is never logged.
func ResolveKey ¶
ResolveKey returns the configured key, or nil when encryption is explicitly disabled (no key material configured).
func (*Key) Fingerprint ¶
Fingerprint returns a short one-way fingerprint of the key material for operational identification. It never reveals key bytes.