Skip to content

Commit 0a0956b

Browse files
author
John Jiang
committed
8180837: SunPKCS11-NSS tests failing with CKR_ATTRIBUTE_READ_ONLY and CKR_MECHANISM_PARAM_INVALID
Reviewed-by: xuelei
1 parent c77f6fd commit 0a0956b

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,6 @@ com/sun/nio/sctp/SctpChannel/SocketOptionTests.java 8141694 linux-al
652652
# jdk_security
653653

654654
sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all
655-
sun/security/pkcs11/Secmod/AddTrustedCert.java 8180837 generic-all
656-
sun/security/pkcs11/tls/TestKeyMaterial.java 8180837 generic-all
657655
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic-all
658656

659657
sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all

test/jdk/sun/security/pkcs11/PKCS11Test.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.security.InvalidAlgorithmParameterException;
4040
import java.security.KeyPairGenerator;
4141
import java.security.NoSuchProviderException;
42+
import java.security.Policy;
4243
import java.security.Provider;
4344
import java.security.ProviderException;
4445
import java.security.Security;
@@ -879,6 +880,9 @@ private static String fetchNssLib(String osId) {
879880
case "MacOSX-x86_64-64":
880881
return fetchNssLib(MACOSX_X64.class);
881882

883+
case "Linux-amd64-64":
884+
return fetchNssLib(LINUX_X64.class);
885+
882886
default:
883887
return null;
884888
}
@@ -900,6 +904,7 @@ private static String fetchNssLib(Class<?> clazz) {
900904
+ "\nPlease make sure the artifact is available.");
901905
}
902906
}
907+
Policy.setPolicy(null); // Clear the policy created by JIB if any
903908
return path;
904909
}
905910

@@ -923,4 +928,11 @@ private static class WINDOWS_X86 { }
923928
revision = "3.46",
924929
extension = "zip")
925930
private static class MACOSX_X64 { }
931+
932+
@Artifact(
933+
organization = "jpg.tests.jdk.nsslib",
934+
name = "nsslib-linux_x64",
935+
revision = "3.46",
936+
extension = "zip")
937+
private static class LINUX_X64 { }
926938
}

test/jdk/sun/security/pkcs11/Secmod/AddTrustedCert.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, 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
@@ -67,6 +67,13 @@ public static void main(String[] args) throws Exception {
6767
String configName = BASE + SEP + "nss.cfg";
6868
Provider p = getSunPKCS11(configName);
6969

70+
if (improperNSSVersion(p)) {
71+
System.out.println(
72+
"Skip test due to improper NSS version in [3.28, 3.35). "
73+
+ "See JDK-8180837 for more detatils.");
74+
return;
75+
}
76+
7077
System.out.println(p);
7178
Security.addProvider(p);
7279

@@ -125,4 +132,13 @@ public static void main(String[] args) throws Exception {
125132
System.out.println("OK");
126133
}
127134

135+
private static boolean improperNSSVersion(Provider p) {
136+
double nssVersion = getNSSVersion();
137+
if (p.getName().equalsIgnoreCase("SunPKCS11-NSSKeyStore")
138+
&& nssVersion >= 3.28 && nssVersion < 3.35) {
139+
return true;
140+
}
141+
142+
return false;
143+
}
128144
}

test/jdk/sun/security/pkcs11/tls/TestKeyMaterial.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, 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
@@ -36,13 +36,16 @@
3636
import java.io.BufferedReader;
3737
import java.nio.file.Files;
3838
import java.nio.file.Paths;
39-
import java.security.Provider;
4039
import java.security.InvalidAlgorithmParameterException;
40+
import java.security.Provider;
41+
import java.security.ProviderException;
4142
import java.util.Arrays;
43+
4244
import javax.crypto.KeyGenerator;
4345
import javax.crypto.SecretKey;
4446
import javax.crypto.spec.IvParameterSpec;
4547
import javax.crypto.spec.SecretKeySpec;
48+
4649
import sun.security.internal.spec.TlsKeyMaterialParameterSpec;
4750
import sun.security.internal.spec.TlsKeyMaterialSpec;
4851

@@ -51,6 +54,7 @@ public class TestKeyMaterial extends PKCS11Test {
5154
private static final int PREFIX_LENGTH = "km-master: ".length();
5255

5356
public static void main(String[] args) throws Exception {
57+
System.out.println("NSS Version: " + getNSSVersion());
5458
main(new TestKeyMaterial(), args);
5559
}
5660

@@ -154,10 +158,26 @@ public void main(Provider provider) throws Exception {
154158
match(lineNumber, serverMacBytes, result.getServerMacKey(), "");
155159
} catch (InvalidAlgorithmParameterException iape) {
156160
// SSLv3 support is removed in S12
157-
if (major == 3 && minor == 0) {
158-
System.out.println("Skip testing SSLv3");
159-
continue;
161+
if (provider.getName().indexOf("Solaris") != -1) {
162+
if (major == 3 && minor == 0) {
163+
System.out.println("Skip testing SSLv3 on Solaris");
164+
continue;
165+
}
166+
}
167+
throw iape;
168+
} catch (ProviderException pe) {
169+
if (provider.getName().indexOf("NSS") != -1) {
170+
Throwable t = pe.getCause();
171+
if (expandedKeyLength != 0
172+
&& t.getMessage().indexOf(
173+
"CKR_MECHANISM_PARAM_INVALID") != -1) {
174+
// NSS removed support for export-grade cipher suites in 3.28,
175+
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1252849
176+
System.out.println("Ignore known NSS failure on CKR_MECHANISM_PARAM_INVALID");
177+
continue;
178+
}
160179
}
180+
throw pe;
161181
}
162182
} else {
163183
throw new Exception("Unknown line: " + line);

0 commit comments

Comments
 (0)