Encryption Overview
Every piece of data and metadata in a repository is encrypted before it leaves your machine. The storage backend never sees unencrypted data.
Security Properties
rustic_core’s encryption provides:Confidentiality
All data encrypted with AES-256
Authenticity
Poly1305 MAC prevents tampering
Integrity
Corrupted data is detected
Forward Secrecy
Each blob uses unique nonce
Encryption Algorithm
rustic_core uses the AES256-CTR-Poly1305-AES construction:AES-256-CTR Encryption
Data is encrypted using AES-256 in Counter (CTR) mode:
- AES-256: Strong symmetric encryption with 256-bit keys
- CTR mode: Stream cipher mode allowing random access
- Performance: Hardware-accelerated on modern CPUs
Poly1305-AES Authentication
Encrypted data is authenticated with Poly1305-AES MAC:
- Poly1305: Fast one-time authentication code
- AES component: Additional randomness for security
- Result: 16-byte authentication tag
The Master Key
At the heart of repository encryption is a 64-byte master key:Key Generation
The master key is randomly generated using a cryptographically secure RNG:Key Components
- Encryption Key (32 bytes)
- MAC Key 'k' (16 bytes)
- MAC Key 'r' (16 bytes)
The first 32 bytes are used as the AES-256 encryption key.
Password-Based Key Derivation
The master key is never stored directly. Instead, it’s encrypted with a key derived from your password using scrypt.Scrypt Parameters
scrypt is a memory-hard key derivation function designed to resist brute-force attacks:- N: 2^15 (32768) - Memory cost factor
- r: 8 - Block size
- p: 1 - Parallelization
Key Derivation Process
Multiple Passwords
A repository can have multiple key files, each with a different password:Encryption in Practice
Encrypting Data
When saving data to the repository:Decrypting Data
When reading from the repository:What Gets Encrypted?
rustic_core encrypts everything except key files themselves:- Encrypted
- Not Encrypted
✅ Always encrypted:
- Config file
- Snapshot metadata
- Tree blobs (directory structure)
- Data blobs (file contents)
- Index files
Content-Addressed Encryption
Encryption interacts with deduplication:- Plaintext chunking: Files are split into chunks based on content
- Deterministic IDs: Each chunk’s ID is the SHA-256 hash of plaintext
- Encrypted storage: Chunks are encrypted before storage
- Deduplication preserved: Identical chunks have same ID despite different ciphertexts
Security Considerations
Password Strength
Password Strength
Your password is the weakest link. Use a strong, unique password:
- Minimum: 16+ characters
- Recommended: Random passphrase or password manager
- Avoid: Dictionary words, personal information
Key Storage
Key Storage
The master key exists in memory during operations:Security measures:
- Keys are never written to disk unencrypted
- Use encrypted swap or disable swap for maximum security
- Clear sensitive data from memory when done
Metadata Leakage
Metadata Leakage
While all data is encrypted, some metadata is visible:Encrypted:
- File names and paths
- File contents
- Directory structure
- Repository structure (config, keys, snapshots exist)
- Pack file sizes
- Number of snapshots
- Approximate repository size
Working with Keys
Opening with Password
Opening with Master Key
For automation, you can use the master key directly:Key Management
See Also
Repository
Repository structure and lifecycle
Deduplication
How encryption interacts with deduplication
Snapshots
What snapshot metadata is encrypted
Backends
Where encrypted data is stored