JCE无限强度安装,但不支持AES 256 [英] JCE Unlimited Strength installed but AES 256 is not supported

查看:356
本文介绍了JCE无限强度安装,但不支持AES 256的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将JCE无限强度安装到JAVA_HOME\lib\security

但是,我仍然得到128个 Cipher.getMaxAllowedKeyLength(AES)

I have installed JCE Unlimited strength to JAVA_HOME\lib\security
However, I'm still getting 128 for Cipher.getMaxAllowedKeyLength("AES").

我想知道我是否在错误的地方安装了JCE。 C

I'm wondering if I have installed the JCE at the wrong place.
I have Java installed in 2 places.


  1. C:\Program Files\Java\jre7

  2. C:\Development\Java\jdk1.6.0_21

任何人都可以告诉我安装JCE的正确位置无限力量
您的帮助非常感激。

Can anyone tell me where is the correct place to install JCE Unlimited strength? Your help is much appreciated.

我的代码:

my code:

 KeyGenerator generator = KeyGenerator.getInstance("AES");      
 generator.init(256);       SecretKey secretKey = generator.generateKey();      
 byte[] raw= secretKey.getEncoded();        
 SecretKeySpec sskey= new SecretKeySpec(raw, "AES");

        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");         
        if (mode == Cipher.ENCRYPT_MODE) { 
           Cipher.getMaxAllowedKeyLength("AES"));   
           cipher.init(Cipher.ENCRYPT_MODE, sskey);             
           CipherInputStream cis = new CipherInputStream(is, cipher); 
           doCopy(cis, os);         
        } else if (mode == Cipher.DECRYPT_MODE) { 
           cipher.init(Cipher.DECRYPT_MODE, sskey); 
           CipherOutputStream cos = new CipherOutputStream(os, cipher);             
           doCopy(is, cos);         
        }


推荐答案

您需要安装文件进入无论哪个JVM要运行你的代码。为了安全起见,我主张在两者中安装。

You need to install the files into whichever JVM is going to run your code. To be on the safe side, I'd advocate installing it in both.

我注意到有两种不同的版本:Java 7用于JRE,Java 6用于SDK 。请记住,Java 6和7具有不同的无限强度策略文件,因此您需要下载两个集合。

I notice you have two different versions: Java 7 for a JRE and Java 6 for an SDK. Bear in mind that Java 6 and 7 have different unlimited strength policy files, so you'll need to download both sets.


  • 对于JRE ,安装到 C:\Program Files\Java\jre7\lib\security

  • 对于JDK,安装到 C:\Development\Java\jdk1.6.0_21\jre\lib\security

  • For the JRE, install into C:\Program Files\Java\jre7\lib\security.
  • For the JDK, install into C:\Development\Java\jdk1.6.0_21\jre\lib\security.

这篇关于JCE无限强度安装,但不支持AES 256的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆