Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
public static void testEnvironment()
throws
NoSuchAlgorithmException,
NoSuchPaddingException,
GeneralSecurityException
{
// 64bits testing data block
byte[] data = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
// 128bit key
SecretKey key128 = new SecretKeySpec(new byte[] { 0x00, 0x01, 0x02,
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
0x0d, 0x0e, 0x0f }, ALGORITHM);
// sipher initialization and try to crypt data block with specified key
Cipher cipher = Cipher.getInstance(ALGORITHM + "/" + BLOCK_MODE + "/" + PADDING);
cipher.init(Cipher.ENCRYPT_MODE, key128, CBC_SALT);
cipher.doFinal(data);
System.out.println("128-bit test: O.K.");
// 192bit key
// sipher initialization and try to crypt data block with specified key
SecretKey key192 = new SecretKeySpec(new byte[] { 0x00, 0x01, 0x02,
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
0x17 }, ALGORITHM);
// sipher initialization and try to crypt data block with specified key
cipher.init(Cipher.ENCRYPT_MODE, key192, CBC_SALT);
cipher.doFinal(data);
System.out.println("192-bit test: O.K.");
// 256key
SecretKey key256 = new SecretKeySpec(new byte[] { 0x00, 0x01, 0x02,
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
ALGORITHM);
// sipher initialization and try to crypt data block with specified key
cipher.init(Cipher.ENCRYPT_MODE, key256, CBC_SALT);
cipher.doFinal(data);
System.out.println("256-bit test: O.K.");
System.out.println("Testing of JCE restriction ended.");
cipher = null;
}
// Country-specific policy file for countries with no limits on crypto strength.
grant {
// There is no restriction to any algorithms.
permission javax.crypto.CryptoAllPermission;
};
// Manufacturing policy file.
grant {
// There is no restriction to any algorithms.
permission javax.crypto.CryptoAllPermission;
};
Starting job TestJCE at 20:42 08/02/2011.
connecting to socket on port 3700
connected
Exception in component tJava_1
java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at routines.DesifrovatHeslo.testProstredi(DesifrovatHeslo.java:270)
at fnkv_ip.testjce_0_1.TestJCE.tJava_1Process(TestJCE.java:235)
at fnkv_ip.testjce_0_1.TestJCE.runJobInTOS(TestJCE.java:447)
at fnkv_ip.testjce_0_1.TestJCE.main(TestJCE.java:318)
128-bit test: O.K. - this is ok, this always run with standard libraries
disconnected
Job TestJCE ended at 20:42 08/02/2011.
package routines;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.Set;
import javax.crypto.Cipher;
public class TestovatJCE {
public static void JCE(){
try {
Set<String> algorithms = Security.getAlgorithms("Cipher");
for(String algorithm: algorithms) {
int max;
max = Cipher.getMaxAllowedKeyLength(algorithm);
System.out.printf("%-22s: %dbit%n", algorithm, max);
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
}
Starting job TestJCE at 09:43 09/02/2011.
connecting to socket on port 3384
connected
BLOWFISH : 128bit
ARCFOUR : 128bit
PBEWITHMD5ANDDES : 128bit
RC2 : 128bit
RSA : 2147483647bit
PBEWITHMD5ANDTRIPLEDES: 128bit
PBEWITHSHA1ANDDESEDE : 128bit
DESEDE : 2147483647bit
AESWRAP : 128bit
AES : 128bit
DES : 64bit
DESEDEWRAP : 128bit
PBEWITHSHA1ANDRC2_40 : 128bit
disconnected
Job TestJCE ended at 09:43 09/02/2011.
Starting job TestJCE at 11:20 09/02/2011.
connecting to socket on port 3426
connected
BLOWFISH : 2147483647bit
ARCFOUR : 2147483647bit
PBEWITHMD5ANDDES : 2147483647bit
RC2 : 2147483647bit
RSA : 2147483647bit
PBEWITHMD5ANDTRIPLEDES: 2147483647bit
PBEWITHSHA1ANDDESEDE : 2147483647bit
DESEDE : 2147483647bit
AESWRAP : 2147483647bit
AES : 2147483647bit
DES : 2147483647bit
DESEDEWRAP : 2147483647bit
PBEWITHSHA1ANDRC2_40 : 2147483647bit
disconnected
Job TestJCE ended at 11:20 09/02/2011.
package org.archenroot.crypto.aes;
/*
* @(#)EncryptString.java
*
* Summary: Application for encrypt string variables.
* AES(Rijndael) with 256-bit key in CBC mode.
* This is just a demonstration piece of code.
*
* Copyright: (C) 2009-2011
*
* Licence: MIT
* Copyright (c) 2011 Ladislav Jech
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restrictio