正如我在各种评论中已经提到的,您可以使用getMaxAllowedKeyLength()
测试来确定 jdk/jre 是否支持无限强度加密(在我的测试中,我使用了“AES”密码,但“RC5”也应该可以工作)。在测试这个功能时,你需要有正确的罐子(罐子的内容是重要的部分)。
在我的本地盒子中,加密强度有限的 jdk 有一个包含以下内容的 local_policy.jar 文件:
// Some countries have import limits on crypto strength. This policy file
// is worldwide importable.
grant {
permission javax.crypto.CryptoPermission "DES", 64;
permission javax.crypto.CryptoPermission "DESede", *;
permission javax.crypto.CryptoPermission "RC2", 128,
"javax.crypto.spec.RC2ParameterSpec", 128;
permission javax.crypto.CryptoPermission "RC4", 128;
permission javax.crypto.CryptoPermission "RC5", 128,
"javax.crypto.spec.RC5ParameterSpec", *, 12, *;
permission javax.crypto.CryptoPermission "RSA", *;
permission javax.crypto.CryptoPermission *, 128;
};
而实力无限的jdk则有以下内容:
// Country-specific policy file for countries with no limits on crypto strength.
grant {
// There is no restriction to any algorithms.
permission javax.crypto.CryptoAllPermission;
};
(请注意,US_export_policy.jar 在两种情况下都是相同的)。