推荐肉丝r0ysue课程(包含安卓逆向与js逆向):https://img-blog.csdnimg.cn/7fa698312c304ab7bb0a03e2c866990f.png
jdk6→http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
jdk7→http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
jdk8→http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
将下载文件中的两个jar替换在%JAVA_HOME%\jre\lib\security
下的jar
个人尝试时,该文件夹下并没有相应的jar文件,仅有一个policy文件夹(并且已经解除限制)java version “1.8.0_241”
public static void main(String[] args) {
try {
KeyGenerator kg = KeyGenerator.getInstance("AES");
kg.init(256);
SecretKey secretKey=kg.generateKey();
System.out.println(secretKey.getFormat());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
运行成功则已经解除限制
把bcprov-ext*.jar
文件复制到 %JAVA_HOME%\jre\lib\ext
目录下面
修改配置文件\jre\lib\security\java.security
security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=sun.security.ec.SunEC
security.provider.4=com.sun.net.ssl.internal.ssl.Provider
security.provider.5=com.sun.crypto.provider.SunJCE
security.provider.6=sun.security.jgss.SunProvider
security.provider.7=com.sun.security.sasl.Provider
security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI
security.provider.9=sun.security.smartcardio.SunPCSC
security.provider.10=sun.security.mscapi.SunMSCAPI
...
security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider
导入不含ext的另一个jar
所使用的类中添加
static {
Security.addProvider(new BouncyCastleProvider());
}
public static void main(String[] args) {
Provider provider = Security.getProvider("BC");
System.out.println(provider);
for(Map.Entry<Object,Object> entry:provider.entrySet()){
System.out.println(entry.getKey()+" --> "+entry.getValue());
}
}
运行类似下,则配置成功
BC version 1.69
Cipher.ARIARFC3211WRAP --> org.bouncycastle.jcajce.provider.symmetric.ARIA$RFC3211Wrap
Alg.Alias.Cipher.1.3.6.1.4.1.22554.1.1.2.1.22 --> PBEWITHSHAAND192BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.SHA512withRSA/PSS --> PSS
Alg.Alias.Mac.HMAC/Skein-256-224 --> HMACSkein-256-224
Alg.Alias.MessageDigest.SHA256 --> SHA-256