46 */ |
46 */ |
47 public class Padding { |
47 public class Padding { |
48 |
48 |
49 private static final String ALGORITHM = "AES"; |
49 private static final String ALGORITHM = "AES"; |
50 private static final String PROVIDER = "SunJCE"; |
50 private static final String PROVIDER = "SunJCE"; |
51 private static final String[] MODES = { "ECb", "CbC", "PCBC", "OFB", |
51 private static final String[] MODES_PKCS5PAD = { |
|
52 "ECb", "CbC", "PCBC", "OFB", |
52 "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", |
53 "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", |
53 "Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88", |
54 "Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88", |
54 "cfB96", "cfb104", "cfB112", "cfB120", "OFB8", "OFB16", "OFB24", |
55 "cfB96", "cfb104", "cfB112", "cfB120", "OFB8", "OFB16", "OFB24", |
55 "OFB32", "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", |
56 "OFB32", "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", |
56 "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", "GCM" }; |
57 "OFB88", "OFB96", "OFB104", "OFB112", "OFB120" }; |
57 private static final String PADDING = "PKCS5Padding"; |
58 private static final String[] MODES_NOPAD = { "CTR", "CTS", "GCM" }; |
|
59 |
58 private static final int KEY_LENGTH = 128; |
60 private static final int KEY_LENGTH = 128; |
59 |
61 |
60 public static void main(String argv[]) throws Exception { |
62 public static void main(String argv[]) throws Exception { |
61 Padding test = new Padding(); |
63 Padding test = new Padding(); |
62 for (String mode : MODES) { |
64 for (String mode : MODES_PKCS5PAD) { |
63 test.runTest(ALGORITHM, mode, PADDING); |
65 test.runTest(ALGORITHM, mode, "PKCS5Padding"); |
|
66 } |
|
67 for (String mode : MODES_NOPAD) { |
|
68 test.runTest(ALGORITHM, mode, "NoPadding"); |
64 } |
69 } |
65 } |
70 } |
66 |
71 |
67 public void runTest(String algo, String mo, String pad) throws Exception { |
72 public void runTest(String algo, String mo, String pad) throws Exception { |
68 Cipher ci = null; |
73 Cipher ci = null; |