Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Java crypto - Illegal key size or default parameters

Posted on 2014-02-19
Medium Priority
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 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?
Question by:larrysy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 86

Accepted Solution

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

Expert Comment

ID: 39871016
>where secretKey contains 256 bytes.


Think 128 might be the limit.
LVL 86

Expert Comment

ID: 39871137
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

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

Expert Comment

ID: 39881034
LVL 16

Expert Comment

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

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Worried about if Apple can protect your documents, photos, and everything else that gets stored in iCloud? Read on to find out what Apple really uses to make things secure.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

721 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