CrypticCore is a high-performance Java-based encryption engine designed for memory-efficient file transformation. It implements a decoupled architecture that separates the cryptographic logic from the data streaming process, enriched with production-grade, vendor-neutral telemetry.
The engine utilizes the bitwise Exclusive OR (XOR) operation. Given that XOR is an involution, the transformation is self-inverse, allowing for identical encryption and decryption logic.
The operation is defined as:
To handle data streams where the length of the plaintext exceeds the key length, a cyclic key schedule is implemented:
To prevent unintended sign extension during the implicit promotion from byte to 32-bit int, a
bitmask of
- O(1) Space Complexity: Processes data in discrete 8 KB buffers, allowing files of arbitrary size (tested up to 5 GB) to be processed with minimal RAM footprint.
- Throughput: Optimized for high-speed I/O, achieving over 400 MB/s on standard hardware.
- Real-time Telemetry: Integrated progress bar, vendor-neutral Micrometer instrumentation, and performance statistics (throughput, processing latency).
- Atomic Writes: Utilizes a
.tmpfile staging strategy. The final output is only created via an atomicmoveoperation upon successful completion, preventing data corruption during crashes or power failures. - Memory Sanitation: The encryption key is explicitly overwritten in the JVM heap using
Arrays.fill()immediately after use to mitigate memory dump exploits. - Header Validation: Strict magic number and version checking prevents the processing of incompatible or corrupted files.
The engine is built on SOLID principles to ensure extensibility and testability:
- Single Responsibility (SRP): I/O handling, header validation, metric recording, and cryptographic logic are
strictly separated into specialized components (
HeaderHandler,FileValidator,EncryptionEngine). - Dependency Inversion (DIP): The engine does not depend on a specific UI or monitoring platform. It communicates progress through a
ProgressObserverinterface and accepts a vendor-neutral MicrometerMeterRegistryvia constructor injection, rendering it compatible with Prometheus, Dynatrace, or Datadog. - Interface Segregation: Cryptographic strategies are injected via the
CipherAlgorithminterface, making the engine open for future algorithms (e.g., AES) without modifying the core streaming logic.
The engine is fully containerized to ensure environment parity and security.
- Multi-Stage Docker Build: Uses a builder stage (Maven) and a hardened runtime stage (JRE Alpine) to minimize image size (~160MB) and attack surface.
- Security Hardening: The container execution is restricted to a Non-Root User.
- Orchestration Stack: Includes a unified
docker-compose.ymlthat provisions the engine along with a containerized time-series database (Prometheus) and visualization node (Grafana) in a shared network topology.
Every encrypted file starts with a 4-byte metadata header.
| Offset | Length | Description | Value (Hex / ASCII) |
|---|---|---|---|
| 0x00 | 3 Bytes | Magic Number (CCE) | 0x43 0x43 0x45 |
| 0x03 | 1 Byte | Format Version | 0x01 |
java -jar target/CrypticCore-jar-with-dependencies.jar <mode> <input> <output> <key>docker compose run --rm engine <mode> /app/data/input.txt /app/data/output.enc <key>Parameters:
- mode:
ENCRYPTIONorDECRYPTION(Case-insensitive). - input: Path to the source file.
- output: Final destination path for the transformed file.
- key: Secret key for transformation.
The project follows a rigorous testing strategy to ensure data integrity and system stability:
The project utilizes GitHub Actions for continuous integration. Every push and pull request is automatically validated against:
- Compilation & Test Suite: Ensures 100% build stability on Java 21.
- Checkstyle (Google Java Style): Strict enforcement of the Google Java Style Guide.
- Test Coverage (JaCoCo): A quality gate is set to ensure a minimum of 85% code coverage.
- Hybrid Structured Logging: Implements environment-aware logging. The engine automatically detects its environment and switches to Structured JSON Logging when running in Docker.
- Telemetric Exporters: Exposes real-time runtime counters and timing metrics formatted natively for Prometheus scraping via an embedded low-overhead HTTP daemon.
- Unit Testing: Verified the involution property and edge cases (byte boundaries).
- Integration Testing: End-to-end validation of the custom
.cceformat and header integrity. - Resilience: Validation of atomic write operations and prevention of data truncation.
- End-to-End Cycle: Successful encryption and decryption of real file streams.
- Atomic Integrity: Verification of the
.tmpstaging and atomic move strategy. - Error Resilience: * Detection of truncated files (Expected vs. Actual size check).
- Prevention of in-place corruption (Same-file validation).
- Robust header and version validation.
The engine is structured into specialized packages to ensure high maintainability and separation of concerns:
at.tuwien.crypticcore.core.domain: Functional interfaces and core contracts for algorithm strategies.at.tuwien.crypticcore.core.engine: The orchestration layer. Stateless execution of streaming cryptography.at.tuwien.crypticcore.infrastructure.io: Infrastructure layer handling format-specific headers (HeaderHandler), fail-fast validation (FileValidator), and theProgressObserverpattern.at.tuwien.crypticcore.infrastructure.observability: Observability Layer (currently using Micrometer, Prometheus, Grafana).
Follow these steps to spin up the metrics pipeline, process a file, and visualize the data within Grafana.
Ensure your project root contains the following configuration structures:
prometheus.yml
global:
scrape_interval: 2s
scrape_configs:
- job_name: 'crypticcore-engine'
static_configs:
- targets: ['host.docker.internal:8080']docker-compose.yml
services:
engine:
build: .
image: cryptic-core-engine:latest
volumes:
- .:/app/data
extra_hosts:
- "host.docker.internal:host-gateway"
prometheus:
image: prom/prometheus:v2.53.0
container_name: cc-prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
extra_hosts:
- "host.docker.internal:host-gateway"
grafana:
image: grafana/grafana:11.0.0
container_name: cc-grafana
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=adminBoot the integrated monitoring infrastructure using Docker Compose:
docker compose down
docker compose up -dGenerate a large test file (e.g., 100 MB or 1 GB) to benchmark throughput and latency.
Linux/macOS:
dd if=/dev/urandom of=input.txt bs=10m count=100Windows(PowerShell):
$fs = New-Object System.IO.FileStream("large_input.txt", [System.IO.FileMode]::Create); $fs.SetLength(100MB); $fs.Close()Compile and run the binary application:
mvn clean package
java -jar target/CrypticCore-jar-with-dependencies.jar ENCRYPTION input.txt output.enc secretkeyNote: The application will log that the telemetry server is live on port 8080 and hold execution until manually terminated via Ctrl+C.
- Open Grafana at http://localhost:3001 (Credentials: admin / admin).
- Navigate to Connections → Data sources → Add data source, and select Prometheus.
- Set the connection URL to: http://prometheus:9090 and click Save & test.
- Create a new dashboard panel, set the data source to your Prometheus entry, and configure the visualization with these PromQL formulas:
Accumulated Volume Panel:
crypticcore_bytes_processed_total / 1024 / 1024(Unit configuration: Data → Megabytes (MB), style as a plateau or counter step graph)
Restart-Aware Throughput Spike Panel:
increase(crypticcore_bytes_processed_total[1m]) / 1024 / 1024