6

I was wondering if people have been successful in creating/mounting encrypted OBB (Opaque Binary Blob) files in Android? This is a follow up to this question 1: What is OBB(Opaque Binary Blob) in Android develop site? , Following the direction in that post I executed the following (from ICS 4.01 baseline, Tried both on Ubuntu 10.10-32bit and Ubuntu 12.4-64bit):

sudo modprobe cryptoloop
sudo modprobe twofish
sudo modprobe vfat
./mkobb.sh -d /tmp/obb/ -kblahblah -o /tmp/out.obb -v
obbtool a -n com.test.blah -v 1 -s 997ff9b1516a6788 /tmp/out.obb # 997ff... is the salt from the mkobb step
obbtool i /temp/out.obb # verify the obb file
adb push /temp/out.obb /sdcard/

From here I copy the out.obb file to the /sdcard/ on my phone. And mount with the following code:

String obbFile = Environment.getExternalStorageDirectory() + "/out.obb";
mgr = (StorageManager) getSystemService(Context.STORAGE_SERVICE);  // mgr is a member varible of my main activity
Log.i("OBB", "trying to mount : " + obbFile + " does it exist? " + new File(obbFile).exists());

if (mgr.mountObb(obbFile, "blahblah", new OnObbStateChangeListener(){

    @Override
    public void onObbStateChange(String path, int state) {
        Log.i("OBB", String.format("onObbStateChange:Path [%s] State=%d", path, state));
        if (state == OnObbStateChangeListener.ERROR_COULD_NOT_MOUNT){
            Log.i("OBB", "THIS IS THE ERROR I GET");
        }
    }})) 
{
    Log.i("OBB", "Attempting to mount");
} else {
    Log.i("OBB", "Mount failed");   // this isn't happening
}

The end result of this is:

 E/MountService( 2004): Couldn't mount OBB file: -1
 I/OBB     (21219): onObbStateChange:Path [/mnt/sdcard/out.obb] State=21
 I/OBB     (21219): THIS IS THE ERROR I GET

Anyone see any problems with this? Seems like it should work!

Note: I do have android.permission.WRITE_EXTERNAL_STORAGE and also I get expected info from:

ObbInfo info = ObbScanner.getObbInfo("/sdcard/out.obb"); // this returns expected info, so the file is there and able to be read.

Edit: Link to Android-Developer group question here

Community
  • 1
  • 1
user931366
  • 674
  • 5
  • 9

1 Answers1

1

You should format the virtual device (device-mapper device) which was created with the obb file (out.obb) first, and then you could mount it.

To put it concretely, you should add some code as this in the VolumeManager::mountObb().

if (Fat::format(dmDevice, 0)) {
    SLOGE("OBB FAT format failed (%s)", strerror(errno));
    return -1;
}

Maybe this is a bug for android?

user1482130
  • 176
  • 2
  • 4
  • The obb should already be formatted with the mkobb.sh step, in that script it calls mkfs.vfat. Secondly, if you format the obb on every mount, you'd erase your data each time you mount it! Thanks for the reply though. – user931366 Aug 24 '12 at 18:25
  • First, the device which was formatted using the script(mkfs.vfat) actually is the device in Linux machine NOT the device in Android(e.g. your phone). Second, I'm sorry for the ambiguity, I meant you should format the virtual device only ONCE, then you could mount it as usual. – user1482130 Aug 27 '12 at 00:49