changeset 5457:0e2200a8762c jdk7u9-b03

7195931: UnsatisfiedLinkError on PKCS11.C_GetOperationState while using NSS from jre7u6+ 7197071: Makefiles for various security providers aren't including the default manifest. Reviewed-by: valeriep, mullan, katleman
author wetmore
date Tue, 11 Sep 2012 17:57:47 -0700
parents 57ae0cc82515
children cc3e08b3824f
files make/com/oracle/security/ucrypto/Makefile make/javax/crypto/Defs-jce.gmk make/sun/security/ec/Makefile make/sun/security/mscapi/Makefile make/sun/security/pkcs11/Makefile test/javax/crypto/sanity/CheckManifestForRelease.java test/javax/crypto/sanity/p11-solaris.txt
diffstat 7 files changed, 165 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/make/com/oracle/security/ucrypto/Makefile	Tue Sep 11 12:41:01 2012 -0700
+++ b/make/com/oracle/security/ucrypto/Makefile	Tue Sep 11 17:57:47 2012 -0700
@@ -198,9 +198,9 @@
   #
   # Build ucrypto.jar.
   #
-  $(UNSIGNED_DIR)/ucrypto.jar: build
+  $(UNSIGNED_DIR)/ucrypto.jar: build $(JCE_MANIFEST_FILE)
 	$(prep-target)
-	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
+	$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \
 	    $(BOOT_JAR_JFLAGS)
 	@$(java-vm-cleanup)
 
--- a/make/javax/crypto/Defs-jce.gmk	Tue Sep 11 12:41:01 2012 -0700
+++ b/make/javax/crypto/Defs-jce.gmk	Tue Sep 11 17:57:47 2012 -0700
@@ -31,7 +31,7 @@
 JCE_MANIFEST_FILE    = $(TEMPDIR)/manifest.mf
 $(JCE_MANIFEST_FILE): $(MAINMANIFEST)
 	$(prep-target)
-	$(SED) -e "s#@@RELEASE@@#$(RELEASE)#"           \
+	$(SED) -e "s#@@RELEASE@@#$(JDK_VERSION)#"       \
                -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \
                $(MAINMANIFEST) >> $@
 	$(ECHO) "Extension-Name: javax.crypto" >> $@
--- a/make/sun/security/ec/Makefile	Tue Sep 11 12:41:01 2012 -0700
+++ b/make/sun/security/ec/Makefile	Tue Sep 11 17:57:47 2012 -0700
@@ -245,9 +245,9 @@
 #
 # Build sunec.jar.
 #
-$(UNSIGNED_DIR)/sunec.jar: build
+$(UNSIGNED_DIR)/sunec.jar: build $(JCE_MANIFEST_FILE)
 	$(prep-target)
-	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
+	$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \
 	    $(BOOT_JAR_JFLAGS)
 	@$(java-vm-cleanup)
 
--- a/make/sun/security/mscapi/Makefile	Tue Sep 11 12:41:01 2012 -0700
+++ b/make/sun/security/mscapi/Makefile	Tue Sep 11 17:57:47 2012 -0700
@@ -210,9 +210,9 @@
 #
 # Build sunmscapi.jar.
 #
-$(UNSIGNED_DIR)/sunmscapi.jar: build
+$(UNSIGNED_DIR)/sunmscapi.jar: build $(JCE_MANIFEST_FILE)
 	$(prep-target)
-	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
+	$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \
 	    $(BOOT_JAR_JFLAGS)
 	@$(java-vm-cleanup)
 
--- a/make/sun/security/pkcs11/Makefile	Tue Sep 11 12:41:01 2012 -0700
+++ b/make/sun/security/pkcs11/Makefile	Tue Sep 11 17:57:47 2012 -0700
@@ -224,9 +224,9 @@
 #
 # Build sunpkcs11.jar.
 #
-$(UNSIGNED_DIR)/sunpkcs11.jar: build
+$(UNSIGNED_DIR)/sunpkcs11.jar: build $(JCE_MANIFEST_FILE)
 	$(prep-target)
-	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
+	$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \
 	    $(BOOT_JAR_JFLAGS)
 	@$(java-vm-cleanup)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/crypto/sanity/CheckManifestForRelease.java	Tue Sep 11 17:57:47 2012 -0700
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7195931 7197071
+ * @summary UnsatisfiedLinkError on PKCS11.C_GetOperationState while
+ *          using NSS from jre7u6+
+ */
+import java.net.*;
+import java.io.*;
+import java.security.*;
+
+/**
+ * When the Java specification version is incremented, all of the providers
+ * must be recompiled with the proper implementation version to match.
+ */
+public class CheckManifestForRelease {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        checkP11MessageDigestClone();
+        checkManifest();
+    }
+
+    /*
+     * Check the root cause, no manifest values.
+     */
+    static private void checkManifest() throws Exception {
+        System.out.println("=============");
+        String specVersion = System.getProperty("java.specification.version");
+        String extDirName = System.getProperty("java.home", ".") + "/"
+                + "lib/ext";
+
+        // Current list of JCE providers.  Add if more are created.
+        String[] files = new String[]{
+            "sunjce_provider.jar",
+            "sunec.jar",
+            "sunmscapi.jar",
+            "sunpkcs11.jar",
+            "ucrypto.jar"
+        };
+
+        System.out.println("Checking in " + extDirName);
+
+        for (String file : files) {
+            System.out.println("Checking: " + file);
+            String urlString = "jar:file:" + extDirName + "/" + file + "!/";
+            JarURLConnection urlc =
+                    (JarURLConnection) (new URL(urlString).openConnection());
+
+            String implVersion;
+            try {
+                /*
+                 * If the file doesn't exist (e.g. mscapi on solaris),
+                 * skip it. If there are other problems, fail out.
+                 */
+                implVersion = urlc.getManifest().getMainAttributes().getValue(
+                        "Implementation-Version");
+            } catch (FileNotFoundException e) {
+                System.out.println("    " + file + " not found, skipping...");
+                continue;
+            }
+
+            if (implVersion == null) {
+                throw new Exception(
+                        "Implementation-Version not found in Manifest");
+            }
+
+            if (!implVersion.startsWith(specVersion)) {
+                throw new Exception(
+                        "Implementation-Version does not match " +
+                        "Specification-Version");
+            }
+        }
+    }
+
+    /*
+     * Check the symptom, an UnsatisfiedLinkError
+     */
+    static private void checkP11MessageDigestClone() throws Exception {
+        System.out.println("=============");
+        System.out.println("Checking for UnsatisfiedLinkError");
+        String os = System.getProperty("os.name");
+        // Only run on Solaris
+        if (!os.equals("SunOS")) {
+            return;
+        }
+
+        /*
+         * We have to do some gyrations here, since the code to exercise
+         * this is in the P11 MessageDigests, and most of mechanisms are
+         * disabled by default.
+         */
+        String customP11File =
+                System.getProperty("TESTSRC", ".") + "/p11-solaris.txt";
+
+        try {
+            Provider provider =
+                new sun.security.pkcs11.SunPKCS11(customP11File);
+
+            MessageDigest md = MessageDigest.getInstance("SHA1", provider);
+            md.update((byte) 0x01);
+            System.out.println(md.getProvider());
+
+            md.clone();
+        } catch (Exception e) {
+            // These kinds of failure is ok.  We're testing the
+            // UnsatisfiedLinkError here.
+            return;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/crypto/sanity/p11-solaris.txt	Tue Sep 11 17:57:47 2012 -0700
@@ -0,0 +1,21 @@
+#
+# Configuration file to allow the SunPKCS11 provider to utilize
+# the Solaris Cryptographic Framework, if it is available
+#
+# This is a temporary file only for testing.  It does not contain the
+# normal disabled PKCS11 mechanisms that we will use for this test.
+#
+
+name = MyProvider
+
+description = SunPKCS11 accessing Solaris Cryptographic Framework
+
+library = /usr/lib/$ISA/libpkcs11.so
+
+handleStartupErrors = ignoreAll
+
+attributes = compatibility
+
+disabledMechanisms = {
+  CKM_MD2
+}