Java Security: Illegal key size or default parameters?

来自:http://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters

I had asked a question about this earlier, but it didn‘t get answered right and led nowhere. So I‘ve clarified few details on the problem and I would really like to hear your ideas on how could I fix this or what should I try.

I‘ve Java 1.6.0.12 installed on my Linux server and the code bellow runs just perfectly.

String key = "av45k1pfb024xa3bl359vsb4esortvks74sksr5oy4s5serondry84jsrryuhsr5ys49y5seri5shrdliheuirdygliurguiy5ru";
try {
    Cipher c = Cipher.getInstance("ARCFOUR");

    SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "ARCFOUR");
    c.init(Cipher.DECRYPT_MODE, secretKeySpec);

    return new String(c.doFinal(Hex.decodeHex(data.toCharArray())), "UTF-8");

} catch (InvalidKeyException e) {
    throw new CryptoException(e);
}

Today I installed Java 1.6.0.26 on my server user and when I try to run my application, I get the following exception. My guess would be that it has something to do with the Java installation configuration because it works in the first one, but doesn‘t work in the later version..

Caused by: java.security.InvalidKeyException: Illegal key size or default parameters
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at my.package.Something.decode(RC4Decoder.java:25) ~[my.package.jar:na]
    ... 5 common frames omitted

Line 25 is: c.init(Cipher.DECRYPT_MODE, secretKeySpec);



Most likely you don‘t have the unlimited strength file installed now.

You may need to download this file:

Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6

Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7 Download

Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8 Download

Install the file in ${java.home}/jre/lib/security/.

时间: 2024-08-21 15:58:10

Java Security: Illegal key size or default parameters?的相关文章

Java学习-050-AES256 之 java.security.InvalidKeyException: Illegal key size or default parameters 解决方法

在进行 Java AES 加密测试时,出现如下错误信息: java.security.InvalidKeyException: Illegal key size or default parameters at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1026) at javax.crypto.Cipher.implInit(Cipher.java:801) at javax.crypto.Cipher.chooseProvider(Cip

java.security.InvalidKeyException: Illegal key size or default parameters

做CA认证 生成证书时候出错,后来发现是 秘钥长度太长了,怎么会有这个问题呢,看下面的: 参考网址 : http://open.eucalyptus.com/forum/illegal-key-size http://ksgimi.iteye.com/blog/1584716 异常: EjbcaException_Exception: exception encrypting data - java.security.InvalidKeyException: Illegal key size 分

错误:java.security.InvalidKeyException: Illegal key size or default parameters解决方法

Java几乎各种常用加密算法都能找到对应的实现.因为美国的出口限制,Sun通过权限文件(local_policy.jar.US_export_policy.jar)做了相应限制.因此存在一些问题: ●密钥长度上不能满足需求(如:java.security.InvalidKeyException: Illegal key size or default parameters): ●部分算法未能支持,如MD4.SHA-224等算法: ●API使用起来还不是很方便:一些常用的进制转换辅助工具未能提供,

Caused by: java.security.InvalidKeyException: Illegal key size or default parameters

How to remove the key size restriction in Java JDK? Are you developing your beautiful application using the Java Cryptography Extension, and using a key length of more than 128 bits you encounter the following error? Caused by: java.security.InvalidK

java中的AES 256算法遇到 Illegal key size or default parameters错的解决办法

 报错信息: Caused by: java.security.InvalidKeyException: Illegal key size or default parameters 问题原因: Java几乎各种常用加密算法都能找到对应的实现.因为美国的出口限制,Sun通过权限文件(local_policy.jar.US_export_policy.jar)做了相应限制.因此存在一些问题:●密钥长度上不能满足需求(如:java.security.InvalidKeyException: Ille

AES加密时抛出 Illegal key size or default parameters

使用AES加密时,当密钥大于128时,代码会抛出java.security.InvalidKeyException: Illegal key size or default parameters Illegal key size or default parameters是指密钥长度是受限制的,java运行时环境读到的是受限的policy文件.文件位于${java_home}/jre/lib/security 这种限制是因为美国对软件出口的控制. 解决办法: 去掉这种限制需要下载Java Cry

Illegal key size or default parameters 解决方案

1.背景 在做aes加密时,报错 Illegal key size or default parameters...有的jdk版本报错,有的不报错,原因在于: jdk 或jre\lib\security目录 下, 需要两个保密的jar文件   Oracle在其官方网站上提供了无政策限制权限文件(Unlimited Strength Jurisdiction Policy Files),我们只需要将其部署在JRE环境中,就可以解决限制问题. 下载地址:       http://www.oracl

AES加密时抛出java.security.InvalidKeyException: Illegal key size or default parametersIllegal key size or default parameters

使用AES加密时,当密钥大于128时,代码会抛出java.security.InvalidKeyException: Illegal key size or default parameters Illegal key size or default parameters是指密钥长度是受限制的,java运行时环境读到的是受限的policy文件.文件位于${java_home}/jre/lib/security 这种限制是因为美国对软件出口的控制. 解决办法: 去掉这种限制需要下载Java Cry

抛出java.security.InvalidKeyException: Illegal key size

使用FlexiEC的Provider来做ECIES加密时,发现IESParameterSpec在配置完参数后,代码会抛出java.security.InvalidKeyException: Illegal key size, 感觉应该是JCE的问题,于是查关于JCE的资料发现:Illegal key size or default parameters是指密钥长度是受限制的,java运行时环境读到的是受限的policy文件.文件位于${java_home}/jre/lib/security 这种