Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Android NDK for encryption of data passed from normal android app

Is it possible and worth trying to develop some server application using android NDK which will encrypt data (or just use some built in Linux encryption library) passed to it from normal Java based application?

I tried using Cipher library, but it took almost a minute to encrypt 2MB file with AES. And blowfish is not available in Cipher until Android 2.3(?). And I doubt it will be much faster.

I was using blowfish for encryption on Symbian and it was much faster (under 5-10 seconds) so I think in android it is slower because of using Java virtual machine and I'd like to try native app for it.

Have someone done it before?

EDIT: Encrypting in NDK is so much faster. Do it there. There is a similar question with the same answer for AES: AES decryption on Android too slow to be usable. Will NDK be faster? Other ideas?

like image 430
shtolik Avatar asked Feb 16 '11 08:02

shtolik


People also ask

Is Android app data encrypted?

Virtually all Android devices on the market now come with encryption enabled by default. This is because Google required manufacturers to enable full-disk encryption starting with Android 6.0 Marshmallow, which debuted all the way back in 2015.

What encryption method does Android use?

Android full-disk encryption is based on dm-crypt , which is a kernel feature that works at the block device layer. Because of this, encryption works with Embedded MultiMediaCard (eMMC) and similar flash devices that present themselves to the kernel as block devices.

Can you encrypt files on Android?

Navigate to the folder or file you want to encrypt. Tap the folder or file icon to select it. Tap the Encrypt Dir button (Figure A). When prompted enter and verify an encryption password.


1 Answers

BouncyCastle in Android 2.2 is horribly slow with AES/CBC/PKCS5 while using stream decryption. CPU is going to 100% and throughput is 5kb/sec.

Using Chilkat is magnitudes faster and keeps CPU usage low (even in the Emulator). But Chilkat is not offering an InputStream to handle stream decryption and is buffering all the encrypted bytes internally (until a heap space error occurs). So you must manage stream decryption yourself (e.g. by initializing chilkat for every block...)

like image 164
sabalab Avatar answered Sep 20 '22 17:09

sabalab