23
24 import java.security.InvalidKeyException;
25 import java.security.NoSuchAlgorithmException;
26 import java.security.NoSuchProviderException;
27 import java.security.spec.InvalidParameterSpecException;
28 import java.util.Random;
29 import javax.crypto.BadPaddingException;
30 import javax.crypto.Cipher;
31 import javax.crypto.IllegalBlockSizeException;
32 import javax.crypto.KeyGenerator;
33 import javax.crypto.NoSuchPaddingException;
34 import javax.crypto.SecretKey;
35 import javax.crypto.ShortBufferException;
36 import javax.crypto.spec.GCMParameterSpec;
37
38 /**
39 * @test
40 * @bug 8043836
41 * @summary Test AES encryption with no padding. Expect the original data length
42 * is the same as the encrypted data.
43 */
44 public class TestNonexpanding {
45
46 private static final String ALGORITHM = "AES";
47 private static final String PROVIDER = "SunJCE";
48 private static final String[] MODES = { "ECb", "CbC", "OFB", "OFB150",
49 "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", "Cfb40", "cfB48",
50 "cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96", "cfb104",
51 "cfB112", "cfB120", "GCM" };
52 private static final String PADDING = "NoPadding";
53 private static final int KEY_LENGTH = 128;
54
55 public static void main(String argv[]) throws Exception {
56 TestNonexpanding test = new TestNonexpanding();
57 for (String mode : MODES) {
58 test.runTest(ALGORITHM, mode, PADDING);
59 }
60 }
61
62 public void runTest(String algo, String mo, String pad) throws Exception {
|
23
24 import java.security.InvalidKeyException;
25 import java.security.NoSuchAlgorithmException;
26 import java.security.NoSuchProviderException;
27 import java.security.spec.InvalidParameterSpecException;
28 import java.util.Random;
29 import javax.crypto.BadPaddingException;
30 import javax.crypto.Cipher;
31 import javax.crypto.IllegalBlockSizeException;
32 import javax.crypto.KeyGenerator;
33 import javax.crypto.NoSuchPaddingException;
34 import javax.crypto.SecretKey;
35 import javax.crypto.ShortBufferException;
36 import javax.crypto.spec.GCMParameterSpec;
37
38 /**
39 * @test
40 * @bug 8043836
41 * @summary Test AES encryption with no padding. Expect the original data length
42 * is the same as the encrypted data.
43 * @key randomness
44 */
45 public class TestNonexpanding {
46
47 private static final String ALGORITHM = "AES";
48 private static final String PROVIDER = "SunJCE";
49 private static final String[] MODES = { "ECb", "CbC", "OFB", "OFB150",
50 "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", "Cfb40", "cfB48",
51 "cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96", "cfb104",
52 "cfB112", "cfB120", "GCM" };
53 private static final String PADDING = "NoPadding";
54 private static final int KEY_LENGTH = 128;
55
56 public static void main(String argv[]) throws Exception {
57 TestNonexpanding test = new TestNonexpanding();
58 for (String mode : MODES) {
59 test.runTest(ALGORITHM, mode, PADDING);
60 }
61 }
62
63 public void runTest(String algo, String mo, String pad) throws Exception {
|