author | mbalao |
Wed, 24 Apr 2019 16:25:41 -0300 | |
changeset 54611 | bebb82ef3434 |
parent 54584 | test/jdk/sun/security/pkcs11/tls/tls12/TestTLS12.java@2de1c3fa3e7d |
child 55072 | d0f73fccf5f3 |
permissions | -rw-r--r-- |
54213
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
1 |
/* |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Red Hat, Inc. |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
4 |
* |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
8 |
* |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
13 |
* accompanied this code). |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
14 |
* |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
18 |
* |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
21 |
* questions. |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
22 |
*/ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
23 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
24 |
/* |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
25 |
* @test |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
26 |
* @bug 8029661 |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
27 |
* @summary Test TLS 1.2 |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
28 |
* @modules java.base/sun.security.internal.spec |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
29 |
* java.base/sun.security.util |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
30 |
* java.base/com.sun.crypto.provider |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
31 |
* @library /test/lib ../.. |
54611
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
32 |
* @run main/othervm/timeout=120 -Djdk.tls.useExtendedMasterSecret=false FipsModeTLS12 |
54213
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
33 |
*/ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
34 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
35 |
import java.io.File; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
36 |
import java.io.FileInputStream; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
37 |
import java.io.InputStream; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
38 |
import java.nio.ByteBuffer; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
39 |
|
54584
2de1c3fa3e7d
8221271: sun/security/pkcs11/tls/tls12/TestTLS12.java test failed
mbalao
parents:
54213
diff
changeset
|
40 |
import java.security.PrivateKey; |
2de1c3fa3e7d
8221271: sun/security/pkcs11/tls/tls12/TestTLS12.java test failed
mbalao
parents:
54213
diff
changeset
|
41 |
import java.security.PublicKey; |
54213
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
42 |
import java.security.KeyStore; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
43 |
import java.security.NoSuchAlgorithmException; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
44 |
import java.security.Provider; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
45 |
import java.security.SecureRandom; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
46 |
import java.security.Security; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
47 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
48 |
import java.util.Arrays; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
49 |
import java.util.LinkedList; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
50 |
import java.util.List; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
51 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
52 |
import javax.crypto.Cipher; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
53 |
import javax.crypto.KeyGenerator; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
54 |
import javax.crypto.SecretKey; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
55 |
import javax.crypto.spec.SecretKeySpec; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
56 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
57 |
import javax.net.ssl.KeyManagerFactory; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
58 |
import javax.net.ssl.SSLContext; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
59 |
import javax.net.ssl.SSLEngine; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
60 |
import javax.net.ssl.SSLEngineResult; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
61 |
import javax.net.ssl.SSLEngineResult.HandshakeStatus; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
62 |
import javax.net.ssl.SSLParameters; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
63 |
import javax.net.ssl.SSLSession; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
64 |
import javax.net.ssl.TrustManagerFactory; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
65 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
66 |
import sun.security.internal.spec.TlsMasterSecretParameterSpec; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
67 |
import sun.security.internal.spec.TlsPrfParameterSpec; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
68 |
import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
69 |
|
54611
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
70 |
public final class FipsModeTLS12 extends SecmodTest { |
54213
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
71 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
72 |
private static final boolean enableDebug = true; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
73 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
74 |
private static Provider sunPKCS11NSSProvider; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
75 |
private static Provider sunJCEProvider; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
76 |
private static KeyStore ks; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
77 |
private static KeyStore ts; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
78 |
private static char[] passphrase = "JAHshj131@@".toCharArray(); |
54584
2de1c3fa3e7d
8221271: sun/security/pkcs11/tls/tls12/TestTLS12.java test failed
mbalao
parents:
54213
diff
changeset
|
79 |
private static PrivateKey privateKey; |
2de1c3fa3e7d
8221271: sun/security/pkcs11/tls/tls12/TestTLS12.java test failed
mbalao
parents:
54213
diff
changeset
|
80 |
private static PublicKey publicKey; |
54213
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
81 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
82 |
public static void main(String[] args) throws Exception { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
83 |
try { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
84 |
initialize(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
85 |
} catch (Exception e) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
86 |
System.out.println("Test skipped: failure during" + |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
87 |
" initialization"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
88 |
if (enableDebug) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
89 |
System.out.println(e); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
90 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
91 |
return; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
92 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
93 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
94 |
if (shouldRun()) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
95 |
// Test against JCE |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
96 |
testTlsAuthenticationCodeGeneration(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
97 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
98 |
// Self-integrity test (complete TLS 1.2 communication) |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
99 |
new testTLS12SunPKCS11Communication().run(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
100 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
101 |
System.out.println("Test PASS - OK"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
102 |
} else { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
103 |
System.out.println("Test skipped: TLS 1.2 mechanisms" + |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
104 |
" not supported by current SunPKCS11 back-end"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
105 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
106 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
107 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
108 |
private static boolean shouldRun() { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
109 |
if (sunPKCS11NSSProvider == null) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
110 |
return false; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
111 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
112 |
try { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
113 |
KeyGenerator.getInstance("SunTls12MasterSecret", |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
114 |
sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
115 |
KeyGenerator.getInstance( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
116 |
"SunTls12RsaPremasterSecret", sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
117 |
KeyGenerator.getInstance("SunTls12Prf", sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
118 |
} catch (NoSuchAlgorithmException e) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
119 |
return false; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
120 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
121 |
return true; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
122 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
123 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
124 |
private static void testTlsAuthenticationCodeGeneration() |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
125 |
throws Exception { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
126 |
// Generate RSA Pre-Master Secret in SunPKCS11 provider |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
127 |
SecretKey rsaPreMasterSecret = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
128 |
@SuppressWarnings("deprecation") |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
129 |
TlsRsaPremasterSecretParameterSpec rsaPreMasterSecretSpec = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
130 |
new TlsRsaPremasterSecretParameterSpec(0x0303, 0x0303); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
131 |
{ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
132 |
KeyGenerator rsaPreMasterSecretKG = KeyGenerator.getInstance( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
133 |
"SunTls12RsaPremasterSecret", sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
134 |
rsaPreMasterSecretKG.init(rsaPreMasterSecretSpec, null); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
135 |
rsaPreMasterSecret = rsaPreMasterSecretKG.generateKey(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
136 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
137 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
138 |
// Get RSA Pre-Master Secret in plain (from SunPKCS11 provider) |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
139 |
byte[] rsaPlainPreMasterSecret = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
140 |
{ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
141 |
Cipher rsaPreMasterSecretWrapperCipher = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
142 |
Cipher.getInstance("RSA/ECB/PKCS1Padding", |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
143 |
sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
144 |
rsaPreMasterSecretWrapperCipher.init(Cipher.WRAP_MODE, publicKey, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
145 |
new SecureRandom()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
146 |
byte[] rsaEncryptedPreMasterSecret = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
147 |
rsaPreMasterSecretWrapperCipher.wrap(rsaPreMasterSecret); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
148 |
Cipher rsaPreMasterSecretUnwrapperCipher = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
149 |
Cipher.getInstance("RSA/ECB/PKCS1Padding", sunJCEProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
150 |
rsaPreMasterSecretUnwrapperCipher.init(Cipher.UNWRAP_MODE, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
151 |
privateKey, rsaPreMasterSecretSpec); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
152 |
rsaPlainPreMasterSecret = rsaPreMasterSecretUnwrapperCipher.unwrap( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
153 |
rsaEncryptedPreMasterSecret, "TlsRsaPremasterSecret", |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
154 |
Cipher.SECRET_KEY).getEncoded(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
155 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
156 |
if (enableDebug) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
157 |
System.out.println("rsaPlainPreMasterSecret:"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
158 |
for (byte b : rsaPlainPreMasterSecret) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
159 |
System.out.printf("%02X, ", b); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
160 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
161 |
System.out.println(""); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
162 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
163 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
164 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
165 |
// Generate Master Secret |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
166 |
SecretKey sunPKCS11MasterSecret = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
167 |
SecretKey jceMasterSecret = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
168 |
{ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
169 |
KeyGenerator sunPKCS11MasterSecretGenerator = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
170 |
KeyGenerator.getInstance("SunTls12MasterSecret", |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
171 |
sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
172 |
KeyGenerator jceMasterSecretGenerator = KeyGenerator.getInstance( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
173 |
"SunTls12MasterSecret", sunJCEProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
174 |
@SuppressWarnings("deprecation") |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
175 |
TlsMasterSecretParameterSpec sunPKCS11MasterSecretSpec = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
176 |
new TlsMasterSecretParameterSpec(rsaPreMasterSecret, 3, 3, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
177 |
new byte[32], new byte[32], "SHA-256", 32, 64); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
178 |
@SuppressWarnings("deprecation") |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
179 |
TlsMasterSecretParameterSpec jceMasterSecretSpec = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
180 |
new TlsMasterSecretParameterSpec( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
181 |
new SecretKeySpec(rsaPlainPreMasterSecret, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
182 |
"Generic"), 3, 3, new byte[32], |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
183 |
new byte[32], "SHA-256", 32, 64); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
184 |
sunPKCS11MasterSecretGenerator.init(sunPKCS11MasterSecretSpec, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
185 |
null); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
186 |
jceMasterSecretGenerator.init(jceMasterSecretSpec, null); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
187 |
sunPKCS11MasterSecret = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
188 |
sunPKCS11MasterSecretGenerator.generateKey(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
189 |
jceMasterSecret = jceMasterSecretGenerator.generateKey(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
190 |
if (enableDebug) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
191 |
System.out.println("Master Secret (SunJCE):"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
192 |
if (jceMasterSecret != null) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
193 |
for (byte b : jceMasterSecret.getEncoded()) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
194 |
System.out.printf("%02X, ", b); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
195 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
196 |
System.out.println(""); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
197 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
198 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
199 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
200 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
201 |
// Generate authentication codes |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
202 |
byte[] sunPKCS11AuthenticationCode = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
203 |
byte[] jceAuthenticationCode = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
204 |
{ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
205 |
// Generate SunPKCS11 authentication code |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
206 |
{ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
207 |
@SuppressWarnings("deprecation") |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
208 |
TlsPrfParameterSpec sunPKCS11AuthenticationCodeSpec = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
209 |
new TlsPrfParameterSpec(sunPKCS11MasterSecret, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
210 |
"client finished", "a".getBytes(), 12, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
211 |
"SHA-256", 32, 64); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
212 |
KeyGenerator sunPKCS11AuthCodeGenerator = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
213 |
KeyGenerator.getInstance("SunTls12Prf", |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
214 |
sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
215 |
sunPKCS11AuthCodeGenerator.init( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
216 |
sunPKCS11AuthenticationCodeSpec); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
217 |
sunPKCS11AuthenticationCode = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
218 |
sunPKCS11AuthCodeGenerator.generateKey().getEncoded(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
219 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
220 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
221 |
// Generate SunJCE authentication code |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
222 |
{ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
223 |
@SuppressWarnings("deprecation") |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
224 |
TlsPrfParameterSpec jceAuthenticationCodeSpec = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
225 |
new TlsPrfParameterSpec(jceMasterSecret, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
226 |
"client finished", "a".getBytes(), 12, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
227 |
"SHA-256", 32, 64); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
228 |
KeyGenerator jceAuthCodeGenerator = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
229 |
KeyGenerator.getInstance("SunTls12Prf", |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
230 |
sunJCEProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
231 |
jceAuthCodeGenerator.init(jceAuthenticationCodeSpec); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
232 |
jceAuthenticationCode = |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
233 |
jceAuthCodeGenerator.generateKey().getEncoded(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
234 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
235 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
236 |
if (enableDebug) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
237 |
System.out.println("SunPKCS11 Authentication Code: "); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
238 |
for (byte b : sunPKCS11AuthenticationCode) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
239 |
System.out.printf("%02X, ", b); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
240 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
241 |
System.out.println(""); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
242 |
System.out.println("SunJCE Authentication Code: "); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
243 |
for (byte b : jceAuthenticationCode) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
244 |
System.out.printf("%02X, ", b); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
245 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
246 |
System.out.println(""); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
247 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
248 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
249 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
250 |
if (sunPKCS11AuthenticationCode == null || |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
251 |
jceAuthenticationCode == null || |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
252 |
sunPKCS11AuthenticationCode.length == 0 || |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
253 |
jceAuthenticationCode.length == 0 || |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
254 |
!Arrays.equals(sunPKCS11AuthenticationCode, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
255 |
jceAuthenticationCode)) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
256 |
throw new Exception("Authentication codes from JCE" + |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
257 |
" and SunPKCS11 differ."); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
258 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
259 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
260 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
261 |
private static class testTLS12SunPKCS11Communication { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
262 |
public static void run() throws Exception { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
263 |
SSLEngine[][] enginesToTest = getSSLEnginesToTest(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
264 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
265 |
for (SSLEngine[] engineToTest : enginesToTest) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
266 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
267 |
SSLEngine clientSSLEngine = engineToTest[0]; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
268 |
SSLEngine serverSSLEngine = engineToTest[1]; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
269 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
270 |
// SSLEngine code based on RedhandshakeFinished.java |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
271 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
272 |
boolean dataDone = false; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
273 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
274 |
ByteBuffer clientOut = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
275 |
ByteBuffer clientIn = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
276 |
ByteBuffer serverOut = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
277 |
ByteBuffer serverIn = null; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
278 |
ByteBuffer cTOs; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
279 |
ByteBuffer sTOc; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
280 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
281 |
SSLSession session = clientSSLEngine.getSession(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
282 |
int appBufferMax = session.getApplicationBufferSize(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
283 |
int netBufferMax = session.getPacketBufferSize(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
284 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
285 |
clientIn = ByteBuffer.allocate(appBufferMax + 50); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
286 |
serverIn = ByteBuffer.allocate(appBufferMax + 50); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
287 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
288 |
cTOs = ByteBuffer.allocateDirect(netBufferMax); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
289 |
sTOc = ByteBuffer.allocateDirect(netBufferMax); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
290 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
291 |
clientOut = ByteBuffer.wrap( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
292 |
"Hi Server, I'm Client".getBytes()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
293 |
serverOut = ByteBuffer.wrap( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
294 |
"Hello Client, I'm Server".getBytes()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
295 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
296 |
SSLEngineResult clientResult; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
297 |
SSLEngineResult serverResult; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
298 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
299 |
while (!dataDone) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
300 |
clientResult = clientSSLEngine.wrap(clientOut, cTOs); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
301 |
runDelegatedTasks(clientResult, clientSSLEngine); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
302 |
serverResult = serverSSLEngine.wrap(serverOut, sTOc); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
303 |
runDelegatedTasks(serverResult, serverSSLEngine); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
304 |
cTOs.flip(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
305 |
sTOc.flip(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
306 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
307 |
if (enableDebug) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
308 |
System.out.println("Client -> Network"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
309 |
printTlsNetworkPacket("", cTOs); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
310 |
System.out.println(""); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
311 |
System.out.println("Server -> Network"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
312 |
printTlsNetworkPacket("", sTOc); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
313 |
System.out.println(""); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
314 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
315 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
316 |
clientResult = clientSSLEngine.unwrap(sTOc, clientIn); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
317 |
runDelegatedTasks(clientResult, clientSSLEngine); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
318 |
serverResult = serverSSLEngine.unwrap(cTOs, serverIn); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
319 |
runDelegatedTasks(serverResult, serverSSLEngine); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
320 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
321 |
cTOs.compact(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
322 |
sTOc.compact(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
323 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
324 |
if (!dataDone && |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
325 |
(clientOut.limit() == serverIn.position()) && |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
326 |
(serverOut.limit() == clientIn.position())) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
327 |
checkTransfer(serverOut, clientIn); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
328 |
checkTransfer(clientOut, serverIn); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
329 |
dataDone = true; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
330 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
331 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
332 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
333 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
334 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
335 |
static void printTlsNetworkPacket(String prefix, ByteBuffer bb) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
336 |
ByteBuffer slice = bb.slice(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
337 |
byte[] buffer = new byte[slice.remaining()]; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
338 |
slice.get(buffer); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
339 |
for (int i = 0; i < buffer.length; i++) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
340 |
System.out.printf("%02X, ", (byte)(buffer[i] & (byte)0xFF)); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
341 |
if (i % 8 == 0 && i % 16 != 0) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
342 |
System.out.print(" "); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
343 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
344 |
if (i % 16 == 0) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
345 |
System.out.println(""); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
346 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
347 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
348 |
System.out.flush(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
349 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
350 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
351 |
private static void checkTransfer(ByteBuffer a, ByteBuffer b) |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
352 |
throws Exception { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
353 |
a.flip(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
354 |
b.flip(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
355 |
if (!a.equals(b)) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
356 |
throw new Exception("Data didn't transfer cleanly"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
357 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
358 |
a.position(a.limit()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
359 |
b.position(b.limit()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
360 |
a.limit(a.capacity()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
361 |
b.limit(b.capacity()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
362 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
363 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
364 |
private static void runDelegatedTasks(SSLEngineResult result, |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
365 |
SSLEngine engine) throws Exception { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
366 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
367 |
if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
368 |
Runnable runnable; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
369 |
while ((runnable = engine.getDelegatedTask()) != null) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
370 |
runnable.run(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
371 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
372 |
HandshakeStatus hsStatus = engine.getHandshakeStatus(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
373 |
if (hsStatus == HandshakeStatus.NEED_TASK) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
374 |
throw new Exception( |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
375 |
"handshake shouldn't need additional tasks"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
376 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
377 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
378 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
379 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
380 |
private static SSLEngine[][] getSSLEnginesToTest() throws Exception { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
381 |
SSLEngine[][] enginesToTest = new SSLEngine[2][2]; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
382 |
String[][] preferredSuites = new String[][]{ new String[] { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
383 |
"TLS_RSA_WITH_AES_128_CBC_SHA256" |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
384 |
}, new String[] { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
385 |
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
386 |
}}; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
387 |
for (int i = 0; i < enginesToTest.length; i++) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
388 |
enginesToTest[i][0] = createSSLEngine(true); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
389 |
enginesToTest[i][1] = createSSLEngine(false); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
390 |
enginesToTest[i][0].setEnabledCipherSuites(preferredSuites[i]); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
391 |
enginesToTest[i][1].setEnabledCipherSuites(preferredSuites[i]); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
392 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
393 |
return enginesToTest; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
394 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
395 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
396 |
static private SSLEngine createSSLEngine(boolean client) |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
397 |
throws Exception { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
398 |
SSLEngine ssle; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
399 |
KeyManagerFactory kmf = KeyManagerFactory.getInstance("PKIX", "SunJSSE"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
400 |
kmf.init(ks, passphrase); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
401 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
402 |
TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX", "SunJSSE"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
403 |
tmf.init(ts); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
404 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
405 |
SSLContext sslCtx = SSLContext.getInstance("TLSv1.2", "SunJSSE"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
406 |
sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
407 |
ssle = sslCtx.createSSLEngine("localhost", 443); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
408 |
ssle.setUseClientMode(client); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
409 |
SSLParameters sslParameters = ssle.getSSLParameters(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
410 |
ssle.setSSLParameters(sslParameters); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
411 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
412 |
return ssle; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
413 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
414 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
415 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
416 |
private static void initialize() throws Exception { |
54611
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
417 |
// |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
418 |
// For a successful FIPS-mode TLS connection, the following |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
419 |
// cryptographic providers will be installed: |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
420 |
// |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
421 |
// 1. SunPKCS11 (with an NSS FIPS mode backend) |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
422 |
// 2. SUN (to handle X.509 certificates) |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
423 |
// 3. SunJSSE (for a TLS engine) |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
424 |
// |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
425 |
// RSASSA-PSS algorithm is not currently supported in SunPKCS11 |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
426 |
// but in SUN provider. As a result, it can be negotiated by the |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
427 |
// TLS engine. The problem is that SunPKCS11 keys are sensitive |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
428 |
// in FIPS mode and cannot be used in a SUN algorithm (conversion |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
429 |
// fails as plain values cannot be extracted). |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
430 |
// |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
431 |
// To workaround this issue, we disable RSASSA-PSS algorithm for |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
432 |
// TLS connections. Once JDK-8222937 is fixed, this workaround can |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
433 |
// (and should) be removed. |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
434 |
// |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
435 |
// On a final note, the list of disabled TLS algorithms |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
436 |
// (jdk.tls.disabledAlgorithms) has to be updated at this point, |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
437 |
// before it is read in sun.security.ssl.SSLAlgorithmConstraints |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
438 |
// class initialization. |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
439 |
String disabledAlgorithms = |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
440 |
Security.getProperty("jdk.tls.disabledAlgorithms"); |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
441 |
if (disabledAlgorithms.length() > 0) { |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
442 |
disabledAlgorithms += ", "; |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
443 |
} |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
444 |
disabledAlgorithms += "RSASSA-PSS"; |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
445 |
Security.setProperty("jdk.tls.disabledAlgorithms", disabledAlgorithms); |
bebb82ef3434
8222805: sun/security/pkcs11/tls/tls12/TestTLS12.java fails with Unsupported signature algorithm: rsa_pss_rsae_sha256
mbalao
parents:
54584
diff
changeset
|
446 |
|
54213
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
447 |
if (initSecmod() == false) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
448 |
return; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
449 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
450 |
String configName = BASE + SEP + "nss.cfg"; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
451 |
sunPKCS11NSSProvider = getSunPKCS11(configName); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
452 |
System.out.println("SunPKCS11 provider: " + sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
453 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
454 |
List<Provider> installedProviders = new LinkedList<>(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
455 |
for (Provider p : Security.getProviders()){ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
456 |
installedProviders.add(p); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
457 |
Security.removeProvider(p.getName()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
458 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
459 |
Security.addProvider(sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
460 |
for (Provider p : installedProviders){ |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
461 |
String providerName = p.getName(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
462 |
if (providerName.equals("SunJSSE") || |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
463 |
providerName.equals("SUN") || |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
464 |
providerName.equals("SunJCE")) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
465 |
Security.addProvider(p); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
466 |
if (providerName.equals("SunJCE")) { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
467 |
sunJCEProvider = p; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
468 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
469 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
470 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
471 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
472 |
ks = KeyStore.getInstance("PKCS11", sunPKCS11NSSProvider); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
473 |
ks.load(null, "test12".toCharArray()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
474 |
ts = ks; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
475 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
476 |
KeyStore ksPlain = readTestKeyStore(); |
54584
2de1c3fa3e7d
8221271: sun/security/pkcs11/tls/tls12/TestTLS12.java test failed
mbalao
parents:
54213
diff
changeset
|
477 |
privateKey = (PrivateKey)ksPlain.getKey("rh_rsa_sha256", |
54213
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
478 |
passphrase); |
54584
2de1c3fa3e7d
8221271: sun/security/pkcs11/tls/tls12/TestTLS12.java test failed
mbalao
parents:
54213
diff
changeset
|
479 |
publicKey = (PublicKey)ksPlain.getCertificate( |
54213
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
480 |
"rh_rsa_sha256").getPublicKey(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
481 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
482 |
|
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
483 |
private static KeyStore readTestKeyStore() throws Exception { |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
484 |
File file = new File(System.getProperty("test.src", "."), "keystore"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
485 |
InputStream in = new FileInputStream(file); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
486 |
KeyStore ks = KeyStore.getInstance("JKS"); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
487 |
ks.load(in, "passphrase".toCharArray()); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
488 |
in.close(); |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
489 |
return ks; |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
490 |
} |
d8d45286ffa9
8220753: Re-introduce the test case for TLS 1.2 algorithms in SunPKCS11 crypto provider
mbalao
parents:
diff
changeset
|
491 |
} |