Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic encryption on Android

I have seen the example here. All well and good and I understand it, however it relies on the bounceycastle library for the provider. I don't want to bundle any additional third party libraries with my app if I can help it. I don't need fort knox style security, just some basic symmetric encryption for transmitting over the wire. How can I do basic encryption on Android with out third party libraries?

thanks

like image 909
MalcomTucker Avatar asked Aug 25 '10 11:08

MalcomTucker


People also ask

Do Android phones have encryption?

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 type of encryption 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.

How do I know if my Android phone is encrypted?

You can check the encryption status for Android devices by navigating to Settings > Security > Encryption. This tab shows whether the device is encrypted or not. In case the Android device is not encrypted, you can enable encryption from the same tab.

What are the basics of encryption?

There are two basic methods of encryption: symmetric and asymmetric. Symmetric encryption uses the same key for encryption and decryption. Asymmetric uses a different key for encryption and decryption. A key is an external piece of information, like a password, used to cipher or decipher the code.


2 Answers

Well BouncyCastle is included in Android, as you can see if you would try to include it you would get: D/dalvikvm( 9268): DexOpt: not verifying 'Lorg/bouncycastle/x509/extension/SubjectKeyIdentifierStructure;': multiple definitions and so on.

However, not all algorithms are implemented - you would get an NoSuchAlgorithmException. In Android 2.2 I found these to be implemented:

PBEWITHSHAAND128BITAES-CBC-BC PBEWITHSHAAND3-KEYTRIPLEDES-CBC 1.2.840.113549.1.1.7 PBEWITHSHA256AND256BITAES-CBC-BC PBEWITHSHAAND192BITAES-CBC-BC DESEDE DES 1.2.840.113549.3.7 PBEWITHSHAAND2-KEYTRIPLEDES-CBC 1.3.14.3.2.7 PBEWITHSHA256AND192BITAES-CBC-BC PBEWITHSHAAND256BITAES-CBC-BC PBEWITHSHAAND40BITRC2-CBC AES 2.16.840.1.101.3.4.1.42 PBEWITHSHA256AND128BITAES-CBC-BC 2.16.840.1.101.3.4.1.22 2.16.840.1.101.3.4.1.2

like image 154
Cpt.Ohlund Avatar answered Oct 14 '22 12:10

Cpt.Ohlund


I don't want to bundle any additional third party libraries with my app if I can help it.

You do not need third party libraries to use javax.crypto. There are online samples of using javax.crypto, such as this and this. If you need a Base64 encoder, there is one in Android 2.2, or there are open source implementations available for that as well.

like image 43
CommonsWare Avatar answered Oct 14 '22 12:10

CommonsWare