Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java default Crypto/AES behavior

Does anyone know what the default Java crypto behavior is for:

SecretKeySpec localSecretKeySpec = new SecretKeySpec(arrayOfByte, "AES"); Cipher localCipher = Cipher.getInstance("AES"); 

Specifically I am looking to understand how those classes generate the IV, as well as what is the default encryption mode when just specifying "AES". Thanks.

like image 830
wuntee Avatar asked Jun 06 '11 21:06

wuntee


People also ask

What is the default mode of AES encryption?

For Oracle JDK 7 (tested), the default cipher for AES is AES/ECB/PKCS5Padding.

Which API of Java is used for cryptography?

The Java Cryptography Architecture (JCA) is a set of APIs to implement concepts of modern cryptography such as digital signatures, message digests, and certificates.

What is AES ECB PKCS5Padding?

The transformation AES/ECB/PKCS5Padding tells the getInstance method to instantiate the Cipher object as an AES cipher with ECB mode of operation and PKCS5 padding scheme. We can also instantiate the Cipher object by specifying only the algorithm in the transformation: Cipher cipher = Cipher. getInstance("AES");


1 Answers

For Oracle JDK 7 (tested), the default cipher for AES is AES/ECB/PKCS5Padding. The Java Security documentation doesn't mention about this though (http://docs.oracle.com/javase/6/docs/technotes/guides/security/StandardNames.html#algspec), have to do some JUnit testing to find out.

like image 85
bratan Avatar answered Sep 24 '22 00:09

bratan