Skip to content

Commit bb865fb

Browse files
committed
Changed tests from multiple to one with tracking skipped exception
1 parent 11f7b1b commit bb865fb

File tree

3 files changed

+96
-358
lines changed

3 files changed

+96
-358
lines changed

test/jdk/sun/security/pkcs11/Cipher/TestCipherMode.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,30 +22,12 @@
2222
*/
2323

2424
/*
25-
* @test id=AES-ECB
25+
* @test
2626
* @bug 8265500
2727
* @summary
2828
* @library /test/lib ..
2929
* @modules jdk.crypto.cryptoki
30-
* @run main/othervm TestCipherMode AES/ECB/PKCS5Padding
31-
*/
32-
33-
/*
34-
* @test id=AES-GCM
35-
* @bug 8265500
36-
* @summary
37-
* @library /test/lib ..
38-
* @modules jdk.crypto.cryptoki
39-
* @run main/othervm TestCipherMode AES/GCM/NoPadding
40-
*/
41-
42-
/*
43-
* @test id=RSA-ECB
44-
* @bug 8265500
45-
* @summary
46-
* @library /test/lib ..
47-
* @modules jdk.crypto.cryptoki
48-
* @run main/othervm TestCipherMode RSA/ECB/PKCS1Padding
30+
* @run main/othervm TestCipherMode
4931
*/
5032

5133
import jtreg.SkippedException;
@@ -110,8 +92,25 @@ private static Key getKey(String t, CipherMode m, Provider p)
11092
}
11193

11294
public static void main(String[] args) throws Exception {
95+
final String[] transformations = {
96+
"AES/ECB/PKCS5Padding", "AES/GCM/NoPadding", "RSA/ECB/PKCS1Padding"
97+
};
98+
99+
boolean skipEncountered = false;
100+
for (final String t : transformations) {
101+
try {
102+
main(new TestCipherMode(t), args);
103+
} catch (SkippedException skippedException) {
104+
// printing to System.out, so it's easier to see which test it relates to
105+
skippedException.printStackTrace(System.out);
106+
skipEncountered = true;
107+
}
108+
}
109+
110+
if (skipEncountered) {
111+
throw new SkippedException("One or more transformations skipped");
112+
}
113113

114-
main(new TestCipherMode(args[0]), args);
115114
}
116115

117116
@Override

test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphers.java

Lines changed: 45 additions & 234 deletions
Original file line numberDiff line numberDiff line change
@@ -22,254 +22,24 @@
2222
*/
2323

2424
/*
25-
* @test id=ARCFOUR-ARCFOUR-400
25+
* @test
2626
* @bug 4898461 6604496 8330842
2727
* @summary basic test for symmetric ciphers with padding
2828
* @author Valerie Peng
2929
* @library /test/lib ..
3030
* @key randomness
3131
* @modules jdk.crypto.cryptoki
32-
* @run main/othervm TestSymmCiphers ARCFOUR ARCFOUR 400
32+
* @run main/othervm TestSymmCiphers
3333
*/
3434

35-
/*
36-
* @test id=RC4-RC4-401
37-
* @bug 4898461 6604496 8330842
38-
* @summary basic test for symmetric ciphers with padding
39-
* @author Valerie Peng
40-
* @library /test/lib ..
41-
* @key randomness
42-
* @modules jdk.crypto.cryptoki
43-
* @run main/othervm TestSymmCiphers RC4 RC4 401
44-
*/
45-
46-
/*
47-
* @test id=DES-CBC-NOPADDING-DES-400
48-
* @bug 4898461 6604496 8330842
49-
* @summary basic test for symmetric ciphers with padding
50-
* @author Valerie Peng
51-
* @library /test/lib ..
52-
* @key randomness
53-
* @modules jdk.crypto.cryptoki
54-
* @run main/othervm TestSymmCiphers DES/CBC/NoPadding DES 400
55-
*/
56-
57-
/*
58-
* @test id=DESEDE-CBC-NOPADDING-DESEDE-160
59-
* @bug 4898461 6604496 8330842
60-
* @summary basic test for symmetric ciphers with padding
61-
* @author Valerie Peng
62-
* @library /test/lib ..
63-
* @key randomness
64-
* @modules jdk.crypto.cryptoki
65-
* @run main/othervm TestSymmCiphers DESede/CBC/NoPadding DESede 160
66-
*/
67-
68-
/*
69-
* @test id=AES-CBC-NOPADDING-AES-4800
70-
* @bug 4898461 6604496 8330842
71-
* @summary basic test for symmetric ciphers with padding
72-
* @author Valerie Peng
73-
* @library /test/lib ..
74-
* @key randomness
75-
* @modules jdk.crypto.cryptoki
76-
* @run main/othervm TestSymmCiphers AES/CBC/NoPadding AES 4800
77-
*/
78-
79-
/*
80-
* @test id=BLOWFISH-CBC-NOPADDING-BLOWFISH-24
81-
* @bug 4898461 6604496 8330842
82-
* @summary basic test for symmetric ciphers with padding
83-
* @author Valerie Peng
84-
* @library /test/lib ..
85-
* @key randomness
86-
* @modules jdk.crypto.cryptoki
87-
* @run main/othervm TestSymmCiphers Blowfish/CBC/NoPadding Blowfish 24
88-
*/
89-
90-
/*
91-
* @test id=DES-CBC-PKCS5PADDING-DES-6401
92-
* @bug 4898461 6604496 8330842
93-
* @summary basic test for symmetric ciphers with padding
94-
* @author Valerie Peng
95-
* @library /test/lib ..
96-
* @key randomness
97-
* @modules jdk.crypto.cryptoki
98-
* @run main/othervm TestSymmCiphers DES/cbc/PKCS5Padding DES 6401
99-
*/
100-
101-
/*
102-
* @test id=DESEDE-CBC-PKCS5PADDING-DESEDE-402
103-
* @bug 4898461 6604496 8330842
104-
* @summary basic test for symmetric ciphers with padding
105-
* @author Valerie Peng
106-
* @library /test/lib ..
107-
* @key randomness
108-
* @modules jdk.crypto.cryptoki
109-
* @run main/othervm TestSymmCiphers DESede/CBC/PKCS5Padding DESede 402
110-
*/
111-
112-
/*
113-
* @test id=AES-CBC-PKCS5PADDING-AES-30
114-
* @bug 4898461 6604496 8330842
115-
* @summary basic test for symmetric ciphers with padding
116-
* @author Valerie Peng
117-
* @library /test/lib ..
118-
* @key randomness
119-
* @modules jdk.crypto.cryptoki
120-
* @run main/othervm TestSymmCiphers AES/CBC/PKCS5Padding AES 30
121-
*/
122-
123-
/*
124-
* @test id=BLOWFISH-CBC-PKCS5PADDING-BLOWFISH-19
125-
* @bug 4898461 6604496 8330842
126-
* @summary basic test for symmetric ciphers with padding
127-
* @author Valerie Peng
128-
* @library /test/lib ..
129-
* @key randomness
130-
* @modules jdk.crypto.cryptoki
131-
* @run main/othervm TestSymmCiphers Blowfish/CBC/PKCS5Padding Blowfish 19
132-
*/
133-
134-
/*
135-
* @test id=DES-ECB-NOPADDING-DES-400
136-
* @bug 4898461 6604496 8330842
137-
* @summary basic test for symmetric ciphers with padding
138-
* @author Valerie Peng
139-
* @library /test/lib ..
140-
* @key randomness
141-
* @modules jdk.crypto.cryptoki
142-
* @run main/othervm TestSymmCiphers DES/ECB/NoPadding DES 400
143-
*/
144-
145-
/*
146-
* @test id=DESEDE-ECB-NOPADDING-DESEDE-160
147-
* @bug 4898461 6604496 8330842
148-
* @summary basic test for symmetric ciphers with padding
149-
* @author Valerie Peng
150-
* @library /test/lib ..
151-
* @key randomness
152-
* @modules jdk.crypto.cryptoki
153-
* @run main/othervm TestSymmCiphers DESede/ECB/NoPadding DESede 160
154-
*/
155-
156-
/*
157-
* @test id=AES-ECB-NOPADDING-AES-4800
158-
* @bug 4898461 6604496 8330842
159-
* @summary basic test for symmetric ciphers with padding
160-
* @author Valerie Peng
161-
* @library /test/lib ..
162-
* @key randomness
163-
* @modules jdk.crypto.cryptoki
164-
* @run main/othervm TestSymmCiphers AES/ECB/NoPadding AES 4800
165-
*/
166-
167-
/*
168-
* @test id=DES-ECB-PKCS5PADDING-DES-32
169-
* @bug 4898461 6604496 8330842
170-
* @summary basic test for symmetric ciphers with padding
171-
* @author Valerie Peng
172-
* @library /test/lib ..
173-
* @key randomness
174-
* @modules jdk.crypto.cryptoki
175-
* @run main/othervm TestSymmCiphers DES/ECB/PKCS5Padding DES 32
176-
*/
177-
178-
/*
179-
* @test id=DES-ECB-PKCS5PADDING-DES-6400
180-
* @bug 4898461 6604496 8330842
181-
* @summary basic test for symmetric ciphers with padding
182-
* @author Valerie Peng
183-
* @library /test/lib ..
184-
* @key randomness
185-
* @modules jdk.crypto.cryptoki
186-
* @run main/othervm TestSymmCiphers DES/ECB/PKCS5Padding DES 6400
187-
*/
188-
189-
/*
190-
* @test id=DESEDE-ECB-PKCS5PADDING-DESEDE-400
191-
* @bug 4898461 6604496 8330842
192-
* @summary basic test for symmetric ciphers with padding
193-
* @author Valerie Peng
194-
* @library /test/lib ..
195-
* @key randomness
196-
* @modules jdk.crypto.cryptoki
197-
* @run main/othervm TestSymmCiphers DESede/ECB/PKCS5Padding DESede 400
198-
*/
199-
200-
/*
201-
* @test id=AES-ECB-PKCS5PADDING-AES-64
202-
* @bug 4898461 6604496 8330842
203-
* @summary basic test for symmetric ciphers with padding
204-
* @author Valerie Peng
205-
* @library /test/lib ..
206-
* @key randomness
207-
* @modules jdk.crypto.cryptoki
208-
* @run main/othervm TestSymmCiphers AES/ECB/PKCS5Padding AES 64
209-
*/
210-
211-
/*
212-
* @test id=DES-DES-6400
213-
* @bug 4898461 6604496 8330842
214-
* @summary basic test for symmetric ciphers with padding
215-
* @author Valerie Peng
216-
* @library /test/lib ..
217-
* @key randomness
218-
* @modules jdk.crypto.cryptoki
219-
* @run main/othervm TestSymmCiphers DES DES 6400
220-
*/
221-
222-
/*
223-
* @test id=DESEDE-DESEDE-408
224-
* @bug 4898461 6604496 8330842
225-
* @summary basic test for symmetric ciphers with padding
226-
* @author Valerie Peng
227-
* @library /test/lib ..
228-
* @key randomness
229-
* @modules jdk.crypto.cryptoki
230-
* @run main/othervm TestSymmCiphers DESede DESede 408
231-
*/
232-
233-
/*
234-
* @test id=AES-AES-128
235-
* @bug 4898461 6604496 8330842
236-
* @summary basic test for symmetric ciphers with padding
237-
* @author Valerie Peng
238-
* @library /test/lib ..
239-
* @key randomness
240-
* @modules jdk.crypto.cryptoki
241-
* @run main/othervm TestSymmCiphers AES AES 128
242-
*/
243-
244-
/*
245-
* @test id=AES-CTR-NOPADDING-AES-3200
246-
* @bug 4898461 6604496 8330842
247-
* @summary basic test for symmetric ciphers with padding
248-
* @author Valerie Peng
249-
* @library /test/lib ..
250-
* @key randomness
251-
* @modules jdk.crypto.cryptoki
252-
* @run main/othervm TestSymmCiphers AES/CTR/NoPadding AES 3200
253-
*/
254-
255-
/*
256-
* @test id=AES-CTS-NOPADDING-AES-3200
257-
* @bug 4898461 6604496 8330842
258-
* @summary basic test for symmetric ciphers with padding
259-
* @author Valerie Peng
260-
* @library /test/lib ..
261-
* @key randomness
262-
* @modules jdk.crypto.cryptoki
263-
* @run main/othervm TestSymmCiphers AES/CTS/NoPadding AES 3200
264-
*/
265-
26635
import jtreg.SkippedException;
26736

26837
import java.io.ByteArrayOutputStream;
26938
import java.nio.ByteBuffer;
27039
import java.security.AlgorithmParameters;
27140
import java.security.NoSuchAlgorithmException;
27241
import java.security.Provider;
42+
import java.util.List;
27343
import java.util.Random;
27444
import javax.crypto.Cipher;
27545
import javax.crypto.KeyGenerator;
@@ -445,6 +215,47 @@ private static void match(ByteBuffer bb, byte[] answer) throws Exception {
445215
}
446216

447217
public static void main(String[] args) throws Exception {
448-
main(new TestSymmCiphers(args[0], args[1], Integer.parseInt(args[2])), args);
218+
219+
final List<String[]> tests = List.of(
220+
new String[]{"ARCFOUR", "ARCFOUR", "400"},
221+
new String[]{"RC4", "RC4", "401"},
222+
new String[]{"DES/CBC/NoPadding", "DES", "400"},
223+
new String[]{"DESede/CBC/NoPadding", "DESede", "160"},
224+
new String[]{"AES/CBC/NoPadding", "AES", "4800"},
225+
new String[]{"Blowfish/CBC/NoPadding", "Blowfish", "24"},
226+
new String[]{"DES/cbc/PKCS5Padding", "DES", "6401"},
227+
new String[]{"DESede/CBC/PKCS5Padding", "DESede", "402"},
228+
new String[]{"AES/CBC/PKCS5Padding", "AES", "30"},
229+
new String[]{"Blowfish/CBC/PKCS5Padding", "Blowfish", "19"},
230+
new String[]{"DES/ECB/NoPadding", "DES", "400"},
231+
new String[]{"DESede/ECB/NoPadding", "DESede", "160"},
232+
new String[]{"AES/ECB/NoPadding", "AES", "4800"},
233+
new String[]{"DES/ECB/PKCS5Padding", "DES", "32"},
234+
new String[]{"DES/ECB/PKCS5Padding", "DES", "6400"},
235+
new String[]{"DESede/ECB/PKCS5Padding", "DESede", "400"},
236+
new String[]{"AES/ECB/PKCS5Padding", "AES", "64"},
237+
238+
new String[]{"DES", "DES", "6400"},
239+
new String[]{"DESede", "DESede", "408"},
240+
new String[]{"AES", "AES", "128"},
241+
242+
new String[]{"AES/CTR/NoPadding", "AES", "3200"},
243+
new String[]{"AES/CTS/NoPadding", "AES", "3200"}
244+
245+
);
246+
247+
boolean skipEncountered = false;
248+
for (final String[] t : tests) {
249+
try {
250+
main(new TestSymmCiphers(t[0], t[1], Integer.parseInt(t[2])), args);
251+
} catch (SkippedException skippedException) {
252+
skippedException.printStackTrace(System.err);
253+
skipEncountered = true;
254+
}
255+
}
256+
257+
if (skipEncountered) {
258+
throw new SkippedException("One or more tests skipped");
259+
}
449260
}
450261
}

0 commit comments

Comments
 (0)