Solved

Java crypto - Illegal key size or default parameters

Posted on 2014-02-19
6
2,909 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
Comment Utility
I'm assuming I need to install JCE (Java Cryptography Extensions)
That's a possibility. Did you?
0
 
LVL 16

Expert Comment

by:krakatoa
Comment Utility
>where secretKey contains 256 bytes.

Bits?

Think 128 might be the limit.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

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

Expert Comment

by:CEHJ
Comment Utility
:)
0
 
LVL 16

Expert Comment

by:krakatoa
Comment Utility
So the limit was 128-bit, correct?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

771 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