Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions test/jdk/sun/security/pkcs11/KeyGenerator/DESParity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,6 +33,8 @@
* @run main/othervm -Djava.security.manager=allow DESParity sm
*/

import jtreg.SkippedException;

import java.security.Provider;
import java.util.Random;
import javax.crypto.SecretKey;
Expand All @@ -46,8 +48,7 @@ public class DESParity extends PKCS11Test {
@Override
public void main(Provider p) throws Exception {
if (p.getService("SecretKeyFactory", "DES") == null) {
System.out.println("Not supported by provider, skipping");
return;
throw new SkippedException("Not supported by provider, skipping");
}
Random random = new Random();
SecretKeyFactory kf;
Expand All @@ -58,7 +59,7 @@ public void main(Provider p) throws Exception {
random.nextBytes(b);
SecretKeySpec spec = new SecretKeySpec(b, "DES");
SecretKey key = kf.generateSecret(spec);
if (DESKeySpec.isParityAdjusted(key.getEncoded(), 0) == false) {
if (!DESKeySpec.isParityAdjusted(key.getEncoded(), 0)) {
throw new Exception("DES key not parity adjusted");
}
}
Expand All @@ -69,7 +70,7 @@ public void main(Provider p) throws Exception {
random.nextBytes(b);
SecretKeySpec spec = new SecretKeySpec(b, "DESede");
SecretKey key = kf.generateSecret(spec);
if (DESedeKeySpec.isParityAdjusted(key.getEncoded(), 0) == false) {
if (!DESedeKeySpec.isParityAdjusted(key.getEncoded(), 0)) {
throw new Exception("DESede key not parity adjusted");
}
}
Expand Down
7 changes: 4 additions & 3 deletions test/jdk/sun/security/pkcs11/KeyGenerator/TestChaCha20.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,6 +29,8 @@
* @library /test/lib ..
* @run main/othervm TestChaCha20
*/
import jtreg.SkippedException;

import java.security.Provider;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidParameterException;
Expand All @@ -54,8 +56,7 @@ public void main(Provider p) throws Exception {
try {
kg = KeyGenerator.getInstance(ALGO, p);
} catch (NoSuchAlgorithmException nsae) {
System.out.println("Skip; no support for " + ALGO);
return;
throw new SkippedException("Skip; no support for " + ALGO, nsae);
}

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
7 changes: 4 additions & 3 deletions test/jdk/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -32,6 +32,8 @@
* @run main/othervm -Djava.security.manager=allow TestDH2048 sm
*/

import jtreg.SkippedException;

import java.security.InvalidParameterException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
Expand All @@ -51,8 +53,7 @@ private static void checkUnsupportedKeySize(KeyPairGenerator kpg, int ks)
@Override
public void main(Provider p) throws Exception {
if (p.getService("KeyPairGenerator", "DH") == null) {
System.out.println("KPG for DH not supported, skipping");
return;
throw new SkippedException("KPG for DH not supported, skipping");
}
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", p);
kpg.initialize(512);
Expand Down