26 import java.security.NoSuchAlgorithmException;
27 import java.security.NoSuchProviderException;
28 import java.security.spec.AlgorithmParameterSpec;
29 import java.util.Random;
30 import javax.crypto.BadPaddingException;
31 import javax.crypto.Cipher;
32 import javax.crypto.IllegalBlockSizeException;
33 import javax.crypto.KeyGenerator;
34 import javax.crypto.NoSuchPaddingException;
35 import javax.crypto.SecretKey;
36 import javax.crypto.ShortBufferException;
37 import javax.crypto.spec.IvParameterSpec;
38
39 /**
40 * @test
41 * @bug 8043836
42 * @summary Test AES ciphers with different modes and padding schemes (ECB mode
43 * doesn't use IV).
44 * @author Liwen Wang
45 * @author Parag Salvi
46 */
47 public class TestAESCipher {
48
49 private static final String ALGORITHM = "AES";
50 private static final String PROVIDER = "SunJCE";
51 private static final String[] MODES = { "ECb", "CbC", "CTR", "PCBC", "OFB",
52 "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32",
53 "Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88",
54 "cfB96", "cfb104", "cfB112", "cfB120", "OFB8", "OFB16", "OFB24",
55 "OFB32", "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80",
56 "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", "GCM" };
57 private static final String[] PADDING = { "NoPadding", "PKCS5Padding" };
58 private static final int KEY_LENGTH = 128;
59
60 public static void main(String argv[]) throws Exception {
61 TestAESCipher test = new TestAESCipher();
62 for (String mode : MODES) {
63 int padKinds = 1;
64 if (mode.equalsIgnoreCase("ECB") || mode.equalsIgnoreCase("PCBC")
65 || mode.equalsIgnoreCase("CBC")) {
|
26 import java.security.NoSuchAlgorithmException;
27 import java.security.NoSuchProviderException;
28 import java.security.spec.AlgorithmParameterSpec;
29 import java.util.Random;
30 import javax.crypto.BadPaddingException;
31 import javax.crypto.Cipher;
32 import javax.crypto.IllegalBlockSizeException;
33 import javax.crypto.KeyGenerator;
34 import javax.crypto.NoSuchPaddingException;
35 import javax.crypto.SecretKey;
36 import javax.crypto.ShortBufferException;
37 import javax.crypto.spec.IvParameterSpec;
38
39 /**
40 * @test
41 * @bug 8043836
42 * @summary Test AES ciphers with different modes and padding schemes (ECB mode
43 * doesn't use IV).
44 * @author Liwen Wang
45 * @author Parag Salvi
46 * @key randomness
47 */
48 public class TestAESCipher {
49
50 private static final String ALGORITHM = "AES";
51 private static final String PROVIDER = "SunJCE";
52 private static final String[] MODES = { "ECb", "CbC", "CTR", "PCBC", "OFB",
53 "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32",
54 "Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88",
55 "cfB96", "cfb104", "cfB112", "cfB120", "OFB8", "OFB16", "OFB24",
56 "OFB32", "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80",
57 "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", "GCM" };
58 private static final String[] PADDING = { "NoPadding", "PKCS5Padding" };
59 private static final int KEY_LENGTH = 128;
60
61 public static void main(String argv[]) throws Exception {
62 TestAESCipher test = new TestAESCipher();
63 for (String mode : MODES) {
64 int padKinds = 1;
65 if (mode.equalsIgnoreCase("ECB") || mode.equalsIgnoreCase("PCBC")
66 || mode.equalsIgnoreCase("CBC")) {
|