The value of AES encryption in Android?

Inherited Android code that uses the following cipher:

ks = new SecretKeySpec(key, "AES"); ciph = Cipher.getInstance("AES"); 

Since only "AES" is provided, I do not know what keys, modes, and add-ons are. I looked at the Bouncy Castle * documentation, but I cannot find where the AES instance is described. I would like to use a more explicit description of the instance (for example, "AES / ECB / PCKS5Padding"), if possible.

Does anyone know which keys, modes and additions this instance has?

Thanks!

* I read that Android uses Bouncy Castle as the default provider, but I did not find this official, so I could make a futile guess here.

+6
source share
2 answers

Java defaults to "AES/ECB/PKCS5Padding" by default, as indicated in the Oracle documentation.

If no mode or padding is specified, the vendor-specific default values ​​for the pad mode and pattern. For example, the SunJCE provider uses ECB as the default mode, and PKCS5Padding as the default padding scheme for DES, DES-EDE, and Blowfish ciphers. This means that in the case of the SunJCE provider:

 Cipher c1 = Cipher.getInstance("DES/ECB/PKCS5Padding"); and Cipher c1 = Cipher.getInstance("DES"); are equivalent statements. 

See creating an encryption object in the Oracle documentation.


I just checked using the debugger itself. At least for Android 4.0, it seems that Android uses the same encryption and padding mode by default (as expected). The result using the default provider for one ( 00 digit) byte is filled plain text with the value 000F0F0F0F0F0F0F0F0F0F0F0F0F0F0F in hexadecimal. This is clearly a complement to PKCS # 5, or rather, padding to PKCS # 7, which is the same addition as PKCS # 5 to 16-byte block ciphers.

+4
source

From what I know, in java it means AES in ECB mode without padding , And I think the same thing on android. I would advise you to run a simple test to encrypt something on android and decrypt it using AES/ECB/NoPadding using Java or Android. Plus, if you do not see anyone in this application, this is different, point in that direction.

+1
source

All Articles