Solved

Java crypto - Illegal key size or default parameters

Posted on 2014-02-19
6
2,943 Views
Last Modified: 2014-02-23
Hey guys,

I'm running into some trouble loading a key into a cipher to encrypt some strings.  Below is the line of code that's causing an issue.

Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);

where secretKey contains 256 bytes.

I'm getting a java.security.InvalidKeyException: Illegal key size or default parameters.

I've scoured the internet and have come to believe this is an environment issue - I'm assuming I need to install JCE (Java Cryptography Extensions), but am running out of luck getting anything to work (most of the better documentation are around 8 years old).

I'll start off by saying I have Eclipse Standard/SDK installed, Version Kepler Service Release 1.  Are there any set up gurus out there that could assist me in resolving this issue?
0
Comment
Question by:larrysy
  • 3
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 39870739
I'm assuming I need to install JCE (Java Cryptography Extensions)
That's a possibility. Did you?
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 39871016
>where secretKey contains 256 bytes.

Bits?

Think 128 might be the limit.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39871137
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:larrysy
ID: 39881029
Turns out I had pulled the wrong version of JCE.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39881034
:)
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 39881035
So the limit was 128-bit, correct?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

#SSL #TLS #Citrix #HTTPS #PKI #Compliance #Certificate #Encryption #StoreFront #Web Interface #Citrix XenApp
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now