LockBox is an encrypted file container application that provides a virtual filesystem within a single password-protected file. It combines a custom encryption engine (OpenES) with a tree-based virtual filesystem (iNode) to securely store files and directories.
┌──────────────────────────────────────────────────────────────────────────────┐
│ APPLICATION LAYER │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────┐ │
│ │ Interactive │ │ CLI Parser │ │ Command Dispatcher │ │
│ │ UI/Main Menu │ │ (argc/argv) │ │ (ls, cd, cat, etc.) │ │
│ └────────┬────────┘ └────────┬────────┘ └─────────────┬───────────────┘ │
│ │ │ │ │
│ └────────────────────┴─────────────────────────┘ │
│ │ │
│ main.cpp (Main Entry) │
└──────────────────────────────────────┼───────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────────────────────┐
│ VIRTUAL FILESYSTEM LAYER (iNode/) │
│ ┌─────────────────┐ ┌─────────────────┐ ┌───────────────────────────────┐ │
│ │ iNode │ │ Block │ │ inode_raw │ │
│ │ (Tree Manager) │◄─┤ (Data Unit) │◄─┤ (Memory-Mapped I/O) │ │
│ │ │ │ │ │ │ │
│ │ • addFile() │ │ • File/Dir data │ │ • File mapping │ │
│ │ • addDir() │ │ • Encrypted │ │ • Page allocation │ │
│ │ • remove() │ │ names │ │ • Defragmentation │ │
│ │ • readFile() │ │ • Tree pointers │ │ • Raw I/O │ │
│ │ • listDir() │ │ • Timestamps │ │ • Block I/O │ │
│ └────────┬────────┘ └────────┬────────┘ └─────────────┬─────────────────┘ │
│ │ │ │ │
│ └────────────────────┴─────────────────────────┘ │
│ │ │
│ Tree Structure: ▼ │
│ ┌─────────┐ │
│ │ Root │──┐ │
│ │ Block 0 │ │ │
│ └────┬────┘ │ │
│ │child │ │
│ ┌────▼────┐ │ sibling │
│ │ Dir A │◄─┘ │
│ │ Block 1 │ │
│ └────┬────┘ │
│ │ │
│ ┌────▼────┐ │
│ │ File B │ │
│ │ Block 2 │ │
│ └─────────┘ │
└───────────────────────────────────────┬───────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ ENCRYPTION LAYER (OpenES/) │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ OES (Engine) │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌───────────────┐ │ │
│ │ │ enc_*() │ │ dec_*() │ │ hash() │ │ hmac() │ │ │
│ │ │ ECB/CBC/ │ │ ECB/CBC/ │ │ │ │ │ │ │
│ │ │ CTR/CKE/ │ │ CTR/CKE/ │ │ │ │ │ │ │
│ │ │ adv (SPHINX)│ │ adv (SPHINX)│ │ │ │ │ │ │
│ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └────────┬──────┘ │ │
│ │ └────────────────┴────────────────┴──────────────────┘ │ │
│ │ │ │ │
│ │ ┌─────────────────────────────────▼────────────────────────────────┐ │ │
│ │ │ SPHINX Cipher v3.1 │ │ │
│ │ │ • Wide-block cipher (1-16 blocks configurable) │ │ │
│ │ │ • Key Addition → Wide S-box → Algebraic S-box → Diffusion │ │ │
│ │ │ • PHT → Round Constants │ │ │
│ │ └──────────────────────────────────────────────────────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ Data Block Layer (layer/) │ │
│ │ │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │ │
│ │ │ MBLOCK │ │ m_block │ │ defines.h │ │ │
│ │ │ (Class) │ │ (Type) │ │ (Compile-time │ │ │
│ │ │ │ │ uint8-128 │ │ configuration) │ │ │
│ │ │ • Memory │ │ │ │ │ │ │
│ │ │ management│ │ • Rotations │ │ • Block sizes │ │ │
│ │ │ • Padding │ │ • Byte ops │ │ • Type definitions │ │ │
│ │ │ • XOR ops │ │ │ │ • Constants │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────────────┘ │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ Supporting Algorithms (algo/) │ │
│ │ │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ hashing │ │ key_mgmt │ │ PRNG │ │block_ciphers│ │ │
│ │ │ │ │ │ │ │ │ │ │ │
│ │ │ • SHA-256 │ │ • Key exp. │ │ • CSPRNG │ │ • AES │ │ │
│ │ │ • SHA-512 │ │ • PBKDF-like│ │ • SplitMix │ │ • ChaCha │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ PLATFORM ABSTRACTION LAYER │
│ ┌─────────────────────────────┐ ┌─────────────────────────────────────┐ │
│ │ filesystem.cpp/.h │ │ mman.cpp/.h │ │
│ │ │ │ │ │
│ │ Cross-platform file I/O: │ │ Memory-mapped file abstraction: │ │
│ │ • read/write files │ │ • Windows: CreateFileMapping │ │
│ │ • directory operations │ │ • POSIX: mmap/munmap │ │
│ │ • path manipulation │ │ • Page-aligned allocation │ │
│ └─────────────────────────────┘ └─────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
File: main.cpp
The entry point providing multiple interfaces:
ls, cd, cat, etc.)Key classes:
| Class | Line | Description |
|---|---|---|
ColorSupport |
26-77 | Terminal color management with cross-platform support |
ProgressTracker |
208-243 | Progress bar display with ETA calculation |
CommandHistory |
312-343 | Command history navigation (up/down arrows) |
LineEditor |
347-539 | Command-line editing with tab completion |
PreCalculatedBatch |
89-103 | Batch file processing metadata |
CLI Commands:
| Command | Arguments | Description |
|———|———–|————-|
| ls | [path] | List directory contents |
| cd | <path> | Change current directory |
| pwd | - | Print working directory |
| cat | <file> | Display file contents |
| rm | <path> | Remove file or directory |
| mkdir | <path> | Create directory |
| mv | <src> <dst> | Move/rename |
| cp | <src> <dst> | Copy file/directory |
| rename | <path> <name> | Rename file/directory |
| find | <pattern> | Search for files |
| tree | [path] | Display directory tree |
| extract | [src] <dst> | Export files to filesystem |
| add | <file> [path] | Add files from filesystem |
| info | <path> | Show file/directory details |
| limit | [n] | Set list display limit |
| clear | - | Clear screen |
| help | [cmd] | Show help |
| exit | - | Exit CLI mode |
Command-line arguments:
<src> <lockbox> <pass> Create lockbox from source
-e <lockbox> <dest> <pass> Extract lockbox to destination
-c <text> <password> Encrypt text
-d <hex> <password> Decrypt hex ciphertext
-cf <in> <out> <pass> Encrypt file (raw)
-df <in> <out> <pass> Decrypt file (raw)
-h Show help
Files: iNode/iNode.h, iNode/iNode.cpp
The main filesystem interface managing a tree of Block objects.
Key responsibilities:
Key methods:
| Method | Description |
|---|---|
addFile() |
Add or overwrite a file (supports empty files) |
addDirectory() |
Create directory chain |
remove() |
Remove file or recursive directory |
readFile() |
Read and decrypt file content |
updateFile() |
Update existing file content |
move() |
Move/rename files or directories |
copy() |
Copy files or directories recursively |
exists() |
Check if path exists |
listDirectory() |
List directory entries |
search() |
Search files by name pattern |
walk() |
Tree traversal with callback |
exportTo() |
Export to host filesystem |
beginBulkUpdate() |
Start batch operation mode |
endBulkUpdate() |
End batch mode, flush changes |
defragment() |
Compact storage, reclaim space |
getLog() |
Get encrypted activity log |
clearLog() |
Clear activity log |
Types:
| Type | Description |
|---|---|
| DirEntry | Directory entry with encrypted/decrypted names, type, and size |
| Stats | Container statistics (total size, used/free space, file/dir counts) |
| WalkCallback | Callback function for tree traversal |
Files: iNode/Block.h, iNode/Block.cpp
Represents a single file or directory in the virtual filesystem. Supports both inline and external name storage.
Structure:
Key methods:
| Method | Description |
|---|---|
setName() |
Set and encrypt name |
getPlainName() |
Get decrypted name |
getStoredName() |
Get encrypted name |
nameEquals() |
Compare with plaintext name |
setCreatedNow() |
Set creation timestamp |
setModifiedNow() |
Set modification timestamp |
setAccessedNow() |
Set access timestamp |
isNameInline() |
Check if name uses inline storage |
isValid() |
Validate block structure |
isLeaf() |
Check if node has no children |
hasChildren() |
Check if directory has entries |
linkAfter() |
Link after another block |
unlink() |
Remove from linked list |
clone() |
Create deep copy |
createFile() |
Factory for file blocks |
createDirectory() |
Factory for directory blocks |
createRoot() |
Factory for root block |
Static configuration methods:
setCipherEngine(): Set encryption engine for name encryptionsetNameResolver(): Set external name reader callbacksetNameWriter(): Set external name writer callbackFiles: iNode/inode_raw.h, iNode/inode_raw.cpp
Manages memory-mapped file I/O for the container with page-aligned allocation.
Features:
mman.cppKey members:
Key methods:
| Method | Description |
|---|---|
open() |
Open existing container |
create() |
Create new container |
allocate() |
Allocate space at end |
reallocate() |
Reallocate data block |
defragment() |
Compact storage file |
write() |
Write raw data |
read() |
Read raw data |
ptr() |
Get pointer to offset |
readBlock() |
Read Block structure |
writeBlock() |
Write Block structure |
appendBlock() |
Append Block to file |
sync() |
Flush to disk |
Defragmentation process:
Files: OpenES/OES.h, OpenES/OES.cpp
Main interface for all cryptographic operations with secure memory management.
Key components:
Supported modes:
| Mode | Method | Description |
|---|---|---|
| ECB | enc_ecb() |
Electronic Codebook (deterministic) |
| CBC | enc_cbc() |
Cipher Block Chaining |
| CTR | enc_ctr() |
Counter mode (streaming) |
| CKE | enc_cke() |
Custom CKE mode with stream chaining |
| ADV | enc_adv() |
SPHINX cipher (recommended, default) |
Key management:
| Method | Description |
|---|---|
set_key() |
Set password from string |
deriveWKey() |
Derive working key with salt |
extendWKey() |
PBKDF-like key expansion |
resetBlocks() |
Securely clear data blocks |
resetStreamState() |
Reset streaming state |
Data operations:
| Method | Description |
|---|---|
load_data_raw() |
Load plaintext data |
load_cipher_data_raw() |
Load ciphertext data |
load_cipher_block() |
Load existing MBLOCK |
get_data() |
Get plaintext (with padding removed) |
get_cipher_data() |
Get ciphertext |
get_cipher_data_raw() |
Get raw ciphertext bytes |
get_cipherBlock() |
Clone cipher block |
get_plainBlock() |
Clone plaintext block |
Files: OpenES/algo/sphinix.h, OpenES/algo/sphinix.cpp
Custom wide-block cipher designed for high security with configurable block sizes.
Features:
Security levels:
| Block Size | Max Key Size | Security Level |
|---|---|---|
| 8-bit | 64-bit | Basic |
| 16-bit | 128-bit | AES-128 equivalent |
| 32-bit | 256-bit | AES-256 equivalent |
| 64-bit | 512-bit | Post-quantum ready |
| 128-bit | 1024-bit | Quantum-safe |
Round structure:
Plaintext → [Key Addition] → [Wide S-box (Feistel)] → [Algebraic S-box]
→ [Diffusion Layer] → [PHT] → [Round Constants] → Ciphertext
Public interface (namespace SPHINX):
encrypt(): Basic encryption with plaintext and keydecrypt(): Basic decryption with ciphertext and keycreate_context(): Create reusable context for repeated operationsencrypt_with_context(): Encrypt using pre-computed contextdecrypt_with_context(): Decrypt using pre-computed contextFiles: OpenES/layer/m_block.h, OpenES/layer/m_block.cpp
Memory block class managing cryptographic data with secure memory handling.
Key components:
Operations:
The underlying type is configured at compile-time:
| Config | Type | Use Case |
|---|---|---|
| 8-bit | uint8_t |
Embedded systems |
| 16-bit | uint16_t |
Low memory |
| 32-bit | uint32_t |
General purpose |
| 64-bit | uint64_t |
High performance |
| 128-bit | __uint128_t |
Maximum security |
Key methods:
| Method | Description |
|---|---|
fromBytes() |
Create from bytes (with padding) |
fromBytes_raw() |
Create from bytes (no padding) |
toBytes() |
Export to bytes (strip padding) |
toBytes_raw() |
Export raw bytes |
clone() |
Deep copy |
secure_zero() |
Secure memory wipe |
xor_with() |
XOR with another block |
rotr() |
Rotate right |
rotl() |
Rotate left |
extend() |
Resize with fill value |
add_padding_outer() |
Add PKCS-like padding |
get_padding_size_outer() |
Calculate padding size |
dump() |
Debug output |
File: OpenES/layer/defines.h
Compile-time configuration:
| Constant | Default | Description |
|---|---|---|
OES_NUM_OF_BLOCKS |
16 | Number of parallel blocks (must be even) |
OES_LOGIC_BLOCK_SIZE |
128 | Bits per block (8-128, multiple of 8) |
OES_MEM_SIZE |
128 | Derived memory size |
Derived constants:
OES_BYTES_X_BLOCK: Bytes per block (MEM_SIZE / 8)Data types (configured based on block size):
Export format constants:
OES_TYPE_RAW_UINT8: Raw binaryOES_TYPE_MBLOCK: Internal formatOES_TYPE_UINT8: Byte arrayOES_TYPE_HEX: Hexadecimal stringOES_TYPE_CHAR: Character stringOES_EXPORT_BASE64: Base64 encodedFile: OpenES/layer/interface.h
High-level import/export functions:
toOESBlock(): Convert raw bytes to MBLOCKexportBlock(): Export MBLOCK to specified formatimportBlock(): Import from specified format to MBLOCKFiles: filesystem.h, filesystem.cpp
Cross-platform file operations supporting Windows and POSIX systems.
Directory entry structure:
File I/O operations:
Path operations:
File/Directory checks:
Directory operations:
Utilities:
Abstracts platform-specific memory-mapped file APIs:
CreateFileMapping / MapViewOfFilemmap / munmapProtection modes:
Map flags:
Map result contains:
Operations:
map(): Create memory mappingunmap(): Remove memory mappingsync(): Synchronize with disk┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Plaintext │────►│ MBLOCK │────►│ SPHINX │────►│ MBLOCK │
│ (bytes) │ │ (blocks) │ │ encrypt() │ │ (encrypted) │
└──────────────┘ └──────────────┘ └──────────────┘ └──────┬───────┘
│
▼
┌──────────────┐
│ Ciphertext │
│ (bytes) │
└──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ User File │────►│ Encryption │────►│ Block │────►│ inode_raw │
│ (host FS) │ │ (OES) │ │ (metadata + │ │ (mmapped) │
└──────────────┘ └──────────────┘ │ encrypted │ └──────────────┘
│ data) │ │
└──────────────┘ │
▼
┌──────────────┐
│ LockBox │
│ (.lb file) │
└──────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ LockBox File (.lb) │
├─────────────────────────────────────────────────────────────────────────────┤
│ Offset 0 │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ Block 0 (Root Directory) │ │
│ │ ┌─────────────┬─────────────┬─────────────┬──────────────────────────┐ │ │
│ │ │ Metadata │ Encrypted │ Parent │ Next/Prev/Child ptrs │ │ │
│ │ │ (headers) │ name │ offset │ (8 bytes each) │ │ │
│ │ └─────────────┴─────────────┴─────────────┴──────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │
│ Offset N │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ Block 1..N (Files/Directories) │ │
│ │ ┌─────────────┬─────────────┬────────────────────────────────────────┐ │ │
│ │ │ Metadata │ Encrypted │ Encrypted file data (if file) │ │ │
│ │ │ │ name │ or subdirectory blocks (if dir) │ │ │
│ │ └─────────────┴─────────────┴────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │
│ ... additional blocks ... │
│ │
│ After defragmentation: │
│ [Blocks Section][Padding][File Data Section][Padding][External Names] │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
User Password ──► MBLOCK.fromBytes() ──► oKey (original key)
│
▼
extendWKey()
│
▼
wKey (working key)
│
▼
SPHINX encrypt/decrypt
Key expansion process:
.lockbox_log file| Threat | Mitigation |
|---|---|
| Password guessing | Configurable key expansion (default: 16 iterations) |
| Known-plaintext | Wide-block SPHINX cipher with full diffusion |
| Side-channel | Constant-time operations, no table lookups |
| Quantum computing | Support for 1024-bit keys (128-bit blocks) |
| File carving | No magic numbers or predictable headers |
| Memory dumps | Secure zeroing of keys after use |
| Timing attacks | Page-aligned memory, constant-time comparison |
File: CMakeLists.txt
| Option | Default | Description |
|---|---|---|
BUILD_APP |
ON | Build the main application |
BUILD_TESTS |
OFF | Build the test suite |
-O3 -march=native -funroll-loopsCommon sources (library core):
Application sources:
Test sources:
Directory: test/
| File | Description |
|---|---|
oes_tests.cpp |
Encryption/decryption correctness tests |
prngtest.cpp |
Statistical randomness tests (NIST SP 800-22) |
prngtest.h |
PRNG test headers |
tester.h |
Test framework utilities |
Build tests:
cmake -DBUILD_TESTS=ON ..
make LockBoxTests
| Operation | Cost | Mitigation |
|---|---|---|
| Encryption | O(n) per block | Parallel SPHINX rounds |
| Disk sync | I/O bound | Bulk mode, deferred sync |
| Tree traversal | O(n) | Iterative, not recursive |
| Path lookup | O(depth) | Cached root block |
| Defragmentation | O(n log n) | Background operation |
Documentation generated from codebase analysis. Last updated: 2026-03-02