Hive encryption system
Encrypted storage with simple and Shufflecake modes
Hive storage has two encryption modes: Simple Mode for standard encryption, and Shufflecake Mode for plausible deniability with hidden volumes.
Overview
The encryption layer sits between the exFAT filesystem and the underlying storage, providing transparent encryption for all data:
Application Layer (QFile, QDir)
│
ExFatFilesystem (hivecluster-N:/)
│
EncryptedBlockDevice (AES-256-XTS)
│
ShufflecakeVolume (optional multi-volume)
│
FileBlockDevice (hive.store)
Encryption Modes
Simple Mode: Standard Encryption
Single encrypted volume with one password. Best for most users who need straightforward security.
Characteristics:
- One file, one password, one encrypted exFAT filesystem
- No multi-volume complexity
- Standard full-disk encryption
- AES-256-XTS with sector-based encryption
Usage:
- Select file size (10 GiB minimum recommended)
- Enter password (20+ characters)
- System creates encrypted exFAT volume
Shufflecake Mode: Plausible Deniability
Multiple hidden volumes that are cryptographically indistinguishable from random data. Best for high-threat scenarios requiring deniability.
Characteristics:
- Up to 15 volumes per device
- Each volume has its own password
- Slices randomly distributed across device
- Backward key linking: higher volumes unlock lower volumes
- Pre-allocated fixed sizes (no corruption risk)
Pre-allocated Slice Model:
Total: 30 GiB = 7680 slices (4 MiB each)
Volume 0 (decoy): 10 GiB → random slices
Volume 1 (hidden): 10 GiB → different slices
Volume 2 (most hidden): 10 GiB → remaining slices
Deniability: Without the correct password, there's no way to prove additional volumes exist. Unallocated space is filled with random data, making hidden volumes indistinguishable from unused space.
Backward Linking:
- Enter decoy password → only volume 0 opens
- Enter hidden password → volumes 0 + 1 open
- Enter most-hidden password → volumes 0 + 1 + 2 open
Cryptographic Details
Key Derivation
Password-based key derivation uses Argon2id with parameters suitable for disk encryption:
- Memory: 256 MiB
- Iterations: 3
- Parallelism: 4
These parameters provide strong resistance against brute-force attacks while keeping unlock time reasonable (~500ms on modern hardware).
Sector Encryption
Data encryption uses AES-256-XTS (IEEE P1619):
- 256-bit data key + 256-bit tweak key
- Sector number used as tweak for random access
- Each sector independently encrypted
Security Properties
| Threat | Mitigation |
|---|---|
| Offline brute-force | Argon2id with high memory cost |
| Sector swapping attacks | AES-XTS uses sector number as tweak |
| Hidden volume detection | Unallocated space filled with random data |
| Memory forensics | SecureMemory zeros keys on destruction |
| Timing attacks | Constant-time password verification |
On-Disk Structure
Device Master Block (Sector 0)
Always present, unencrypted:
- Magic number:
OCTOFLK1 - Format version
- Device flags (simple mode vs shufflecake)
- Total slice count
- Global salt for key derivation
Volume Master Blocks (Sectors 1-15)
One per possible volume, encrypted:
- Magic number:
OCTOVMB1(visible only when decrypted) - Volume index (0-14)
- Allocated slice count
- Logical volume size
- Backward link keys (to unlock previous volume)
- Position map seed and offset
Without the correct password, VMBs are indistinguishable from random data.
Data Slices
After the header sectors, data is organized in 4 MiB slices. Each volume's slices are randomly distributed across the device.
Password Requirements
For adequate security:
- Minimum 20 characters recommended
- Mix of character classes (upper, lower, digits, special)
- Avoid common patterns (password, 123456, qwerty)
- Longer passphrases (30+ characters) can use fewer character classes
The system estimates password entropy and warns if insufficient.
Limitations
-
No integrity protection: XTS mode doesn't authenticate data. A sophisticated attacker could modify encrypted data, though the result would be garbage.
-
Fixed volume sizes: In Shufflecake mode, volume sizes are fixed at creation. Volumes cannot grow beyond their initial allocation.
-
Write pattern analysis: Frequent writes to hidden volumes may leak timing information to sophisticated observers.
API Usage
Simple Mode
#include "fs/ShufflecakeVolume.hpp"
FileBlockDevice512 device;
device.create("hive.store", 10 * 1024 * 1024 * 1024ULL);
ShufflecakeVolume<512> volume(&device);
volume.formatSimple("my-secure-password-here");
auto encDevice = volume.getVolumeDevice(0);
ExFatFilesystem512 fs(encDevice);
fs.format();
fs.mount();
// Use filesystem...
fs.unmount();
Shufflecake Mode
#include "fs/ShufflecakeVolume.hpp"
FileBlockDevice512 device;
device.create("hive.store", 30 * 1024 * 1024 * 1024ULL);
ShufflecakeVolume<512> volume(&device);
QVector<VolumeSpec> specs;
specs.append({10ULL * 1024 * 1024 * 1024, "decoy-password"});
specs.append({10ULL * 1024 * 1024 * 1024, "hidden-password"});
specs.append({10ULL * 1024 * 1024 * 1024, "secret-password"});
volume.formatShufflecake(specs);
// Each volume can have its own filesystem
for (int i = 0; i < 3; ++i) {
auto encDevice = volume.getVolumeDevice(i);
ExFatFilesystem512 fs(encDevice);
fs.format();
}
Opening Existing Volumes
ShufflecakeVolume<512> volume(&device);
auto result = volume.open("hidden-password");
if (result.success) {
// result.volumeIndex tells which volume matched
// result.unlockedCount tells how many volumes are accessible
for (quint8 idx : volume.openVolumes()) {
auto encDevice = volume.getVolumeDevice(idx);
ExFatFilesystem512 fs(encDevice);
fs.mount();
// Use filesystem...
}
}
Test Coverage
| Category | Tests | Status |
|---|---|---|
| AES-XTS encryption | 3 | Pass |
| Argon2id derivation | 2 | Pass |
| Key derivation | 2 | Pass |
| Secure memory | 4 | Pass |
| EncryptedBlockDevice | 4 | Pass |
| Position maps | 3 | Pass |
| Volume key chain | 2 | Pass |
| ShufflecakeVolume | 5 | Pass |
| End-to-end integration | 5 | Pass |
| Total | 30 | Pass |
Related Documentation
- ExFat Filesystem: See libfs-exfat-native spec
- Entropy Collection: See libentropy documentation
- Hive Management: See libhive documentation