Skip to content

Commit 458a4cc

Browse files
committed
8366342: Key generator and key pair generator tests skipping, but showing as passed
Reviewed-by: rschmelter Backport-of: 7690a45f77a2da47fa912fe7a2b2faa589f259f0
1 parent e5d39d8 commit 458a4cc

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

test/jdk/sun/security/pkcs11/KeyGenerator/DESParity.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 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
@@ -33,6 +33,8 @@
3333
* @run main/othervm -Djava.security.manager=allow DESParity sm
3434
*/
3535

36+
import jtreg.SkippedException;
37+
3638
import java.security.Provider;
3739
import java.util.Random;
3840
import javax.crypto.SecretKey;
@@ -46,8 +48,7 @@ public class DESParity extends PKCS11Test {
4648
@Override
4749
public void main(Provider p) throws Exception {
4850
if (p.getService("SecretKeyFactory", "DES") == null) {
49-
System.out.println("Not supported by provider, skipping");
50-
return;
51+
throw new SkippedException("Not supported by provider, skipping");
5152
}
5253
Random random = new Random();
5354
SecretKeyFactory kf;
@@ -58,7 +59,7 @@ public void main(Provider p) throws Exception {
5859
random.nextBytes(b);
5960
SecretKeySpec spec = new SecretKeySpec(b, "DES");
6061
SecretKey key = kf.generateSecret(spec);
61-
if (DESKeySpec.isParityAdjusted(key.getEncoded(), 0) == false) {
62+
if (!DESKeySpec.isParityAdjusted(key.getEncoded(), 0)) {
6263
throw new Exception("DES key not parity adjusted");
6364
}
6465
}
@@ -69,7 +70,7 @@ public void main(Provider p) throws Exception {
6970
random.nextBytes(b);
7071
SecretKeySpec spec = new SecretKeySpec(b, "DESede");
7172
SecretKey key = kf.generateSecret(spec);
72-
if (DESedeKeySpec.isParityAdjusted(key.getEncoded(), 0) == false) {
73+
if (!DESedeKeySpec.isParityAdjusted(key.getEncoded(), 0)) {
7374
throw new Exception("DESede key not parity adjusted");
7475
}
7576
}

test/jdk/sun/security/pkcs11/KeyGenerator/TestChaCha20.java

Lines changed: 4 additions & 3 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
@@ -29,6 +29,8 @@
2929
* @library /test/lib ..
3030
* @run main/othervm TestChaCha20
3131
*/
32+
import jtreg.SkippedException;
33+
3234
import java.security.Provider;
3335
import java.security.InvalidAlgorithmParameterException;
3436
import java.security.InvalidParameterException;
@@ -54,8 +56,7 @@ public void main(Provider p) throws Exception {
5456
try {
5557
kg = KeyGenerator.getInstance(ALGO, p);
5658
} catch (NoSuchAlgorithmException nsae) {
57-
System.out.println("Skip; no support for " + ALGO);
58-
return;
59+
throw new SkippedException("Skip; no support for " + ALGO, nsae);
5960
}
6061

6162
try {

test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 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

test/jdk/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 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
@@ -32,6 +32,8 @@
3232
* @run main/othervm -Djava.security.manager=allow TestDH2048 sm
3333
*/
3434

35+
import jtreg.SkippedException;
36+
3537
import java.security.InvalidParameterException;
3638
import java.security.KeyPair;
3739
import java.security.KeyPairGenerator;
@@ -51,8 +53,7 @@ private static void checkUnsupportedKeySize(KeyPairGenerator kpg, int ks)
5153
@Override
5254
public void main(Provider p) throws Exception {
5355
if (p.getService("KeyPairGenerator", "DH") == null) {
54-
System.out.println("KPG for DH not supported, skipping");
55-
return;
56+
throw new SkippedException("KPG for DH not supported, skipping");
5657
}
5758
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", p);
5859
kpg.initialize(512);

0 commit comments

Comments
 (0)