提交 cfdd8d92 编写于 作者: W weijun

7055362: jdk_security2 test target cleanup

Reviewed-by: alanb
上级 8dfabd3c
...@@ -532,7 +532,7 @@ jdk_security1: $(call TestDirs, java/security) ...@@ -532,7 +532,7 @@ jdk_security1: $(call TestDirs, java/security)
# Using samevm has serious problems with these tests # Using samevm has serious problems with these tests
JDK_ALL_TARGETS += jdk_security2 JDK_ALL_TARGETS += jdk_security2
jdk_security2: $(call TestDirs, javax/crypto com/sun/crypto) jdk_security2: $(call TestDirs, javax/crypto com/sun/crypto)
$(call RunOthervmBatch) $(call RunSamevmBatch)
# Stable othervm testruns (minus items from PROBLEM_LIST) # Stable othervm testruns (minus items from PROBLEM_LIST)
# Using samevm has serious problems with these tests # Using samevm has serious problems with these tests
......
...@@ -587,15 +587,9 @@ sun/security/tools/jarsigner/oldsig.sh generic-all ...@@ -587,15 +587,9 @@ sun/security/tools/jarsigner/oldsig.sh generic-all
# Various failures on Linux Fedora 9 X64, othervm mode # Various failures on Linux Fedora 9 X64, othervm mode
sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all
# Linux i586 -server, buffer too short to hold shared secret?
com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java generic-all
# Solaris sparcv9: Failed to parse input emptysubject.jks: No such file or directory # Solaris sparcv9: Failed to parse input emptysubject.jks: No such file or directory
sun/security/tools/keytool/emptysubject.sh generic-all sun/security/tools/keytool/emptysubject.sh generic-all
# Timeout on solaris-sparcv9 or exception thrown
com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java solaris-all
# Fails on OpenSolaris, missing classes, slow on Solaris sparc # Fails on OpenSolaris, missing classes, slow on Solaris sparc
sun/security/ec/TestEC.java generic-all sun/security/ec/TestEC.java generic-all
......
/* /*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 0000000 * @bug 0000000 7055362
* @summary Sealtest * @summary Sealtest
* @author Jan Luehe * @author Jan Luehe
*/ */
...@@ -54,14 +54,16 @@ public class Sealtest { ...@@ -54,14 +54,16 @@ public class Sealtest {
SealedObject sealed = new SealedObject(kp.getPrivate(), c); SealedObject sealed = new SealedObject(kp.getPrivate(), c);
// serialize // serialize
FileOutputStream fos = new FileOutputStream("sealed"); try (FileOutputStream fos = new FileOutputStream("sealed");
ObjectOutputStream oos = new ObjectOutputStream(fos); ObjectOutputStream oos = new ObjectOutputStream(fos)) {
oos.writeObject(sealed); oos.writeObject(sealed);
}
// deserialize // deserialize
FileInputStream fis = new FileInputStream("sealed"); try (FileInputStream fis = new FileInputStream("sealed");
ObjectInputStream ois = new ObjectInputStream(fis); ObjectInputStream ois = new ObjectInputStream(fis)) {
sealed = (SealedObject)ois.readObject(); sealed = (SealedObject)ois.readObject();
}
System.out.println(sealed.getAlgorithm()); System.out.println(sealed.getAlgorithm());
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4894151 * @bug 4894151 7055362
* @summary known answer test for OAEP encryption * @summary known answer test for OAEP encryption
* @author Andreas Sterbenz * @author Andreas Sterbenz
*/ */
...@@ -62,60 +62,62 @@ public class TestOAEP_KAT { ...@@ -62,60 +62,62 @@ public class TestOAEP_KAT {
System.out.println("Testing provider " + provider.getName() + "..."); System.out.println("Testing provider " + provider.getName() + "...");
Cipher c = Cipher.getInstance("RSA/ECB/OAEPwithSHA1andMGF1Padding", provider); Cipher c = Cipher.getInstance("RSA/ECB/OAEPwithSHA1andMGF1Padding", provider);
KeyFactory kf = KeyFactory.getInstance("RSA", kfProvider); KeyFactory kf = KeyFactory.getInstance("RSA", kfProvider);
InputStream in = new FileInputStream(new File(BASE, "oaep-vect.txt")); try (InputStream in = new FileInputStream(new File(BASE, "oaep-vect.txt"));
BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF8")); BufferedReader reader =
while (true) { new BufferedReader(new InputStreamReader(in, "UTF8"))) {
String line = reader.readLine(); while (true) {
if (line == null) { String line = reader.readLine();
break; if (line == null) {
} break;
line = line.trim(); }
if (line.length() == 0) { line = line.trim();
continue; if (line.length() == 0) {
} continue;
if (line.equals("# RSA modulus n:")) {
n = parseNumber(reader);
} else if (line.equals("# RSA public exponent e:")) {
e = parseNumber(reader);
} else if (line.equals("# RSA private exponent d:")) {
d = parseNumber(reader);
} else if (line.equals("# Prime p:")) {
p = parseNumber(reader);
} else if (line.equals("# Prime q:")) {
q = parseNumber(reader);
} else if (line.equals("# p's CRT exponent dP:")) {
pe = parseNumber(reader);
} else if (line.equals("# q's CRT exponent dQ:")) {
qe = parseNumber(reader);
} else if (line.equals("# CRT coefficient qInv:")) {
coeff = parseNumber(reader);
} else if (line.equals("# Message to be encrypted:")) {
plainText = parseBytes(reader);
} else if (line.equals("# Seed:")) {
seed = parseBytes(reader);
} else if (line.equals("# Encryption:")) {
cipherText = parseBytes(reader);
// do encryption test first
KeySpec pubSpec = new RSAPublicKeySpec(n, e);
PublicKey pubKey = kf.generatePublic(pubSpec);
c.init(Cipher.ENCRYPT_MODE, pubKey, new MyRandom(seed));
cipherText2 = c.doFinal(plainText);
if (Arrays.equals(cipherText2, cipherText) == false) {
throw new Exception("Encryption mismatch");
} }
// followed by decryption test if (line.equals("# RSA modulus n:")) {
KeySpec privSpec = new RSAPrivateCrtKeySpec(n, e, d, p, q, pe, qe, coeff); n = parseNumber(reader);
PrivateKey privKey = kf.generatePrivate(privSpec); } else if (line.equals("# RSA public exponent e:")) {
c.init(Cipher.DECRYPT_MODE, privKey); e = parseNumber(reader);
byte[] dec = c.doFinal(cipherText); } else if (line.equals("# RSA private exponent d:")) {
if (Arrays.equals(plainText, dec) == false) { d = parseNumber(reader);
throw new Exception("Decryption mismatch"); } else if (line.equals("# Prime p:")) {
p = parseNumber(reader);
} else if (line.equals("# Prime q:")) {
q = parseNumber(reader);
} else if (line.equals("# p's CRT exponent dP:")) {
pe = parseNumber(reader);
} else if (line.equals("# q's CRT exponent dQ:")) {
qe = parseNumber(reader);
} else if (line.equals("# CRT coefficient qInv:")) {
coeff = parseNumber(reader);
} else if (line.equals("# Message to be encrypted:")) {
plainText = parseBytes(reader);
} else if (line.equals("# Seed:")) {
seed = parseBytes(reader);
} else if (line.equals("# Encryption:")) {
cipherText = parseBytes(reader);
// do encryption test first
KeySpec pubSpec = new RSAPublicKeySpec(n, e);
PublicKey pubKey = kf.generatePublic(pubSpec);
c.init(Cipher.ENCRYPT_MODE, pubKey, new MyRandom(seed));
cipherText2 = c.doFinal(plainText);
if (Arrays.equals(cipherText2, cipherText) == false) {
throw new Exception("Encryption mismatch");
}
// followed by decryption test
KeySpec privSpec = new RSAPrivateCrtKeySpec(n, e, d, p, q, pe, qe, coeff);
PrivateKey privKey = kf.generatePrivate(privSpec);
c.init(Cipher.DECRYPT_MODE, privKey);
byte[] dec = c.doFinal(cipherText);
if (Arrays.equals(plainText, dec) == false) {
throw new Exception("Decryption mismatch");
}
} else if (line.startsWith("# ------------------------------")) {
// ignore, do not print
} else {
// unknown line (comment), print
System.out.println(": " + line);
} }
} else if (line.startsWith("# ------------------------------")) {
// ignore, do not print
} else {
// unknown line (comment), print
System.out.println(": " + line);
} }
} }
long stop = System.currentTimeMillis(); long stop = System.currentTimeMillis();
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/** /**
* @test * @test
* @bug 4508341 * @bug 4508341 7055362
* @library ../../../java/security/testlibrary
* @summary Test the error conditions of * @summary Test the error conditions of
* EncryptedPrivateKeyInfo.getKeySpec(...) methods. * EncryptedPrivateKeyInfo.getKeySpec(...) methods.
* @author Valerie Peng * @author Valerie Peng
...@@ -97,7 +98,16 @@ public class GetKeySpecException { ...@@ -97,7 +98,16 @@ public class GetKeySpecException {
} }
} }
public static void main(String[] argv) throws Exception { public static void main(String[] args) throws Exception {
ProvidersSnapshot snapshot = ProvidersSnapshot.create();
try {
main0(args);
} finally {
snapshot.restore();
}
}
public static void main0(String[] args) throws Exception {
if ((GOOD_PARAMS == null) || (BAD_PARAMS == null)) { if ((GOOD_PARAMS == null) || (BAD_PARAMS == null)) {
throw new Exception("Static parameter generation failed"); throw new Exception("Static parameter generation failed");
} }
......
/* /*
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/* /*
* @test * @test
* @bug 6377058 * @bug 6377058 7055362
* @library ../../../java/security/testlibrary
* @summary SunJCE depends on sun.security.provider.SignatureImpl * @summary SunJCE depends on sun.security.provider.SignatureImpl
* behaviour, BC can't load into 1st slot. * behaviour, BC can't load into 1st slot.
* @author Brad R. Wetmore * @author Brad R. Wetmore
...@@ -35,7 +36,16 @@ import java.io.*; ...@@ -35,7 +36,16 @@ import java.io.*;
public class SunJCE_BC_LoadOrdering { public class SunJCE_BC_LoadOrdering {
public static void main(String args[]) throws Exception { public static void main(String[] args) throws Exception {
ProvidersSnapshot snapshot = ProvidersSnapshot.create();
try {
main0(args);
} finally {
snapshot.restore();
}
}
public static void main0(String[] args) throws Exception {
/* /*
* Generate a random key, and encrypt the data * Generate a random key, and encrypt the data
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册