Security & Cryptography

AES-256-GCM Cryptographic Architecture

In mobile security, simply changing a file extension or moving a picture to a dot-prefixed hidden directory (e.g. .hidden/photo.jpg) provides zero actual cryptographic defense. Any basic file explorer, root shell, or forensics utility can easily read that data. Calculator Hide Files employs AES-256-GCM (Advanced Encryption Standard in Galois/Counter Mode)—the same standard trusted by cybersecurity institutions, military infrastructure, and modern secure communications protocols.

1. Why AES-256-GCM?

Many legacy file vault applications on Android still utilize outdated symmetric modes like AES-ECB or unauthenticated AES-CBC. These legacy modes carry significant vulnerabilities:

  • ECB (Electronic Codebook): Identical plaintext blocks produce identical ciphertext blocks, leaving clear structural visual patterns in uncompressed bitmaps and structured documents.
  • CBC (Cipher Block Chaining): While better than ECB, CBC is vulnerable to padding oracle attacks and bit-flipping attacks if ciphertext integrity is not verified with an independent HMAC.
  • GCM (Galois/Counter Mode): An authenticated encryption with associated data (AEAD) mode. GCM provides both confidentiality (hiding the contents) and authenticity/integrity (guaranteeing that not even a single bit of the file has been altered or tampered with).

2. Key Specifications of the AES-256-GCM & CHFE Architecture

Cryptographic & Storage Parameters:

  • Cipher Algorithm: AES (Advanced Encryption Standard / Rijndael)
  • Key Size: 256 bits (32 bytes)
  • Mode of Operation: GCM (Galois/Counter Mode – AEAD)
  • Key Derivation Function: PBKDF2WithHmacSHA256 with 100,000 iterations
  • Authentication Tag Length: 128 bits (16 bytes)
  • Initialization Vector (IV): 96-bit (12 bytes) cryptographically random Nonce generated per file stream via SecureRandom
  • Salt: 16-byte unique cryptographic salt generated per file
  • Container Format: Self-contained CHFE binary file package (v0x01)

3. Self-Contained Binary Container (CHFE) & Disaster-Proof Recovery

Unlike standard vault apps that depend entirely on an internal SQLite database to remember original filenames and formats, version 2.1.0 packages each encrypted file into an independent, self-describing binary container:

+---------------------------------------------------------------------------------+
| Magic ("CHFE") | Ver (0x01) | Salt (16B) | IV (12B) | Encrypted Payload + Tag   |
+---------------------------------------------------------------------------------+
                                                       |
                                                       v
                                          +---------------------------------------+
                                          | Metadata Length (4B) | JSON Metadata  |
                                          | - Original Name & Extension           |
                                          | - MIME Type & File Size               |
                                          | - Timestamp                           |
                                          +---------------------------------------+
                                          | Plaintext File Data Content           |
                                          +---------------------------------------+

Benefits of the CHFE container format:

  • Disaster Recovery: If the app is uninstalled or app data is wiped, the files on disk remain safe. When you reinstall Calculator Hide Files and re-enter your master encryption key, the app reads the embedded metadata from the CHFE container and restores all previews and details automatically.
  • Zero-Database Dependency: Files are never orphaned even if the local database is lost or corrupted.
  • Atomic File Migration: When upgrading legacy files, writes occur to a .tmp file first and verify the GCM tag before atomic replacement.

3. How Authenticated Encryption Protects Your Files

When you select a video, photo, audio recording, or PDF to hide in Calculator Hide Files, the cryptographic engine executes the following steps:

  1. Nonce Generation: A fresh, cryptographically secure 96-bit Initialization Vector (IV) is generated using Android's hardware entropy pool. A unique IV is generated for every single file to guarantee that identical files never yield identical ciphertext.
  2. Stream Processing: The plaintext payload is streamed through an AES/GCM/NoPadding cipher instance in chunks, minimizing RAM consumption even when encrypting multi-gigabyte 4K video files.
  3. Authentication Tag Computation: While encrypting, the Galois field multiplier generates a 128-bit authentication tag over the ciphertext.
  4. Atomic Storage: The IV, ciphertext, and tag are written atomically to the app's protected internal storage space.

4. Decryption & Integrity Verification

During decryption (when you preview or restore a hidden file):

The cipher calculates the authentication tag over the encrypted data and verifies it against the embedded 128-bit tag before completing decryption. If any malicious process, file corruption, or forensic tool has modified or flipped even a single bit of the file, the GCM cipher throws an AEADBadTagException and halts. This ensures corrupted or manipulated files are never silently presented to the user.

5. Zero-Permission Offline Guarantees

Cryptographic encryption is useless if an application transmits decryption keys or data over the network. In Calculator Hide Files:

  • No Internet Permission: The android.permission.INTERNET declaration was explicitly purged in version 2.0.1. The Android OS operating system level sandbox actively blocks the app from opening any TCP/UDP socket, HTTP request, or remote connection.
  • No Cloud Infrastructure: There are no AWS servers, Firebase analytics, Google cloud backups, or remote database tables. All keys and files remain strictly inside your physical phone.
  • No Analytics SDKs: No third-party behavioral trackers or telemetry daemons are integrated into the codebase.

6. Code Transparency & Open Auditing

The complete implementation of the encryption classes, key generation, and UI logic is open for inspection on GitHub. You can review the Kotlin source code, verify how Cipher.getInstance("AES/GCM/NoPadding") is configured, and compile your own build using Android Studio.

// Example of the AES-256-GCM cipher initialization in Kotlin
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
val spec = GCMParameterSpec(128, ivBytes)
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, spec)

To inspect the repository code or ask questions, visit our GitHub repository.