Skip to content

Instantly share code, notes, and snippets.

@zoff99
Last active January 18, 2025 17:35
Show Gist options
  • Save zoff99/11dd526834d12553b3845850891d331c to your computer and use it in GitHub Desktop.
Save zoff99/11dd526834d12553b3845850891d331c to your computer and use it in GitHub Desktop.
guardian_project_iocipher_update
title author categories tags
IOCipher 1.0 reboot
Zoff
Development
News
Android
JNI
iocipher
security

Exciting Updates to IOCipher 1.0

We are thrilled to announce that a community contributor has picked up maintaining a fork of IOCipher and updated to IOCipher 1.0, designed to enhance your development experience and empower you to create even more powerful applications. Here’s what’s new and why it matters to you:

1. Enhanced Features

We introduced a few new features. Now you can enjoy IOCipher also on Desktop Java for Linux and Windows (Windows does currently not support all features). And there is an example in python to access IOCipher VFS.

2. Dependency updates

We updated to the newest SQLCipher and OpenSSL.

3. Bug Fixes and Stability

Now your virutal files can be as large as you want, there is no longer a hard limit at 4 GB. We fixed some bugs that testing the JNI code with ASAN has found.

IOCipher: Encrypted Virtual Disk (for Android and Linux JVM)

IOCipher is a virtual encrypted disk for apps without requiring the device to be rooted. It uses a clone of the standard java.io API for working with files. Just password handling & opening the virtual disk are what stand between developers and fully encrypted file storage. It is based on libsqlfs and SQLCipher.

IOCipher is based on transactions in SQLite, which means that it does not require being mounted in the normal sense. There is no open state once a transaction is complete. Each read or write operation is a self-contained SQLite transaction, so if the file system is forcably quit, SQLite’s transactions prevent the whole file system from being corrupted. This is important in Android since an Activity or Service can be killed at any moment without warning.

Features

  • Comes with all batteries included
  • Secure transparent app-level virtual encrypted disk
  • Multi-threaded access
  • No root required
  • Only three new methods to learn: VirtualFileSystem.get(), VirtualFileSystem.mount(dbFile, password), and VirtualFileSystem.unmount()
  • Supports Android API 21 and above
  • Supports Java version 8 and above on Desktop

Adding IOCipher to your App

Here are the things you need to do in your code to make it use IOCipher encrypted storage for all of your app's file storage:

  • add to your project build.gradle
allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
    }
}
  • add to your module build.gradle
implementation 'com.github.zoff99:pkgs_guardianprojectIOCipher:1.0.4'
  • get the VFS singleton using VirtualFileSystem.get()
  • on first run, create the container file with a password using VirtualFileSystem.createNewContainer(dbFile, password)
  • mount the container file with a password using VirtualFileSystem.mount(dbFile, password)
  • replace the relevant java.io import statements with info.guardianproject.iocipher
import info.guardianproject.iocipher.File;
import info.guardianproject.iocipher.FileOutputStream;
import info.guardianproject.iocipher.FileReader;
import info.guardianproject.iocipher.IOCipherFileChannel;
import info.guardianproject.iocipher.VirtualFileSystem;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

Source Code

optional:

Usage notes

  • only one active mount per-app is supported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment