0
Cipher cipher = Cipher.getInstance("AES");

and

Key key = new SecretKeySpec(keyValue, "AES");

What version of AES is this using, and how can i specify 128/256 bit?

edit: 'keyValue is a string.getBytes(), and im pretty sure that determines the 128/256 bits, so how long should my 'keyValue' be to make it 256 bit encryption?

edit2: more details:

final String key = "TrIlGnUmAkUkQkPe";
  final byte[] keyValue = key.getBytes();
Primm
  • 1,347
  • 4
  • 19
  • 32

1 Answers1

3

This document says its 128. You can navigate to it from Java doc in couple of links starting at Java Cryptography Architecture Reference Guide.

Alex Gitelman
  • 24,429
  • 7
  • 52
  • 49
  • Thanks, how can I make this use 256 bit? – Primm Jul 10 '12 at 18:21
  • @user1332495 here are 2 helpful links: [here](http://stackoverflow.com/questions/992019/java-256-bit-aes-password-based-encryption) and [this](http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html) – David Kroukamp Jul 10 '12 at 18:23
  • @user1332495 how stupid of me! You cant have 256 keys without installing [Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files](http://www.ngs.ac.uk/tools/jcepolicyfiles) – David Kroukamp Jul 10 '12 at 18:27
  • AH! Thanks so much! So once I install this, it should let me make my key 256 bits? and will the client of anyone who runs this have to have it installed? – Primm Jul 10 '12 at 18:29
  • @user1332495 yes then you are free to create keys of 192 and 256bits (which you couldnt do without it). Yes the client needs to have these updated policy files. (Please select appropriate policy files on the Oracle download page i.e Java 6 policy files for Java 6 etc) – David Kroukamp Jul 10 '12 at 18:30
  • I still get the: java.security.InvalidKeyException: Invalid AES key length: 256 bytes error – Primm Jul 10 '12 at 18:43
  • @user1332495 did you overwrite both JDK and JRE policy files? that should be done.. – David Kroukamp Jul 10 '12 at 19:34