Crypto: Consolidate duplicate unlimited strength crypto check code

This commit is contained in:
zzz
2015-10-17 12:55:39 +00:00
parent 70921a2b09
commit 3411a7c884
3 changed files with 50 additions and 45 deletions

View File

@@ -5,6 +5,7 @@ import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import net.i2p.crypto.CryptoCheck;
import net.i2p.crypto.SigType;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
@@ -57,7 +58,7 @@ public class CryptoChecker {
log.logAlways(Log.WARN, s);
System.out.println(s);
}
if (!isUnlimited()) {
if (!CryptoCheck.isUnlimited()) {
s = "Please consider installing the Java Cryptography Unlimited Strength Jurisdiction Policy Files from ";
//if (SystemVersion.isJava8())
// s += JRE8;
@@ -79,28 +80,6 @@ public class CryptoChecker {
}
}
/**
* Copied from CryptixAESEngine
*/
private static boolean isUnlimited() {
try {
if (Cipher.getMaxAllowedKeyLength("AES") < 256)
return false;
} catch (NoSuchAlgorithmException e) {
return false;
} catch (NoSuchMethodError e) {
// JamVM, gij
try {
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
SecretKeySpec key = new SecretKeySpec(new byte[32], "AES");
cipher.init(Cipher.ENCRYPT_MODE, key);
} catch (GeneralSecurityException gse) {
return false;
}
}
return true;
}
public static void main(String[] args) {
warnUnavailableCrypto(null);
}