Blob Blame History Raw
# HG changeset patch
# User andrew
# Date 1453863246 0
#      Wed Jan 27 02:54:06 2016 +0000
# Node ID 48c15869ecd568263249af4b9a4e98d4e57f9a8f
# Parent  afd392dfaed501ac674a7cc3e37353ce300969c7
PR1983: Support using the system installation of NSS with the SunEC provider
Summary: Apply code changes from PR1699 & PR1742 & forward-port Makefile changes to the new build.
Updated 2017/07/04 to accomodate 8175110

diff -r 984a4af2ed4e make/lib/SecurityLibraries.gmk
--- openjdk/jdk/make/lib/SecurityLibraries.gmk
+++ openjdk/jdk/make/lib/SecurityLibraries.gmk
@@ -218,8 +218,17 @@
 
 ifeq ($(ENABLE_INTREE_EC), yes)
 
-  BUILD_LIBSUNEC_FLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/security/ec \
+  BUILD_LIBSUNEC_FLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/security/ec
+
+  ifeq ($(USE_EXTERNAL_NSS), true)
+    BUILD_LIBSUNEC_IMPL_DIR :=
+    BUILD_LIBSUNEC_FLAGS += $(NSS_CFLAGS) -DSYSTEM_NSS -DNSS_ENABLE_ECC
+  else
+    BUILD_LIBSUNEC_IMPL_DIR := \
+      $(JDK_TOPDIR)/src/share/native/sun/security/ec/impl
+    BUILD_LIBSUNEC_FLAGS += \
       -I$(JDK_TOPDIR)/src/share/native/sun/security/ec/impl
+  endif
 
   #
   # On sol-sparc...all libraries are compiled with -xregs=no%appl
@@ -235,8 +244,8 @@
   $(eval $(call SetupNativeCompilation,BUILD_LIBSUNEC, \
       LIBRARY := sunec, \
       OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-      SRC := $(JDK_TOPDIR)/src/share/native/sun/security/ec \
-          $(JDK_TOPDIR)/src/share/native/sun/security/ec/impl, \
+      SRC := $(JDK_TOPDIR)/src/share/native/sun/security/ec/ECC_JNI.cpp \
+          $(BUILD_LIBSUNEC_IMPL_DIR), \
       LANG := C++, \
       OPTIMIZATION := LOW, \
       CFLAGS := $(filter-out $(ECC_JNI_SOLSPARC_FILTER), $(CFLAGS_JDKLIB)) \
@@ -248,8 +257,8 @@
       LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK), \
       LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN), \
       LDFLAGS_SUFFIX := $(LIBCXX), \
-      LDFLAGS_SUFFIX_linux := -lc, \
-      LDFLAGS_SUFFIX_solaris := -lc, \
+      LDFLAGS_SUFFIX_linux := -lc $(NSS_LIBS), \
+      LDFLAGS_SUFFIX_solaris := -lc $(NSS_LIBS), \
       VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
       RC_FLAGS := $(RC_FLAGS) \
           -D "JDK_FNAME=sunec.dll" \
diff -r 984a4af2ed4e src/share/native/sun/security/ec/ECC_JNI.cpp
--- openjdk/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp
+++ openjdk/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp
@@ -24,7 +24,7 @@
  */
 
 #include <jni.h>
-#include "impl/ecc_impl.h"
+#include "ecc_impl.h"
 
 #define ILLEGAL_STATE_EXCEPTION "java/lang/IllegalStateException"
 #define INVALID_ALGORITHM_PARAMETER_EXCEPTION \
@@ -89,7 +89,7 @@
  */
 JNIEXPORT jobjectArray
 JNICALL Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair
-  (JNIEnv *env, jclass clazz, jint keySize, jbyteArray encodedParams, jbyteArray seed)
+  (JNIEnv *env, jclass UNUSED(clazz), jint UNUSED(keySize), jbyteArray encodedParams, jbyteArray seed)
 {
     ECPrivateKey *privKey = NULL; // contains both public and private values
     ECParams *ecparams = NULL;
@@ -190,7 +190,7 @@
  */
 JNIEXPORT jbyteArray
 JNICALL Java_sun_security_ec_ECDSASignature_signDigest
-  (JNIEnv *env, jclass clazz, jbyteArray digest, jbyteArray privateKey, jbyteArray encodedParams, jbyteArray seed, jint timing)
+  (JNIEnv *env, jclass UNUSED(clazz), jbyteArray digest, jbyteArray privateKey, jbyteArray encodedParams, jbyteArray seed, jint timing)
 {
     jbyte* pDigestBuffer = NULL;
     jint jDigestLength = env->GetArrayLength(digest);
@@ -299,7 +299,7 @@
  */
 JNIEXPORT jboolean
 JNICALL Java_sun_security_ec_ECDSASignature_verifySignedDigest
-  (JNIEnv *env, jclass clazz, jbyteArray signedDigest, jbyteArray digest, jbyteArray publicKey, jbyteArray encodedParams)
+  (JNIEnv *env, jclass UNUSED(clazz), jbyteArray signedDigest, jbyteArray digest, jbyteArray publicKey, jbyteArray encodedParams)
 {
     jboolean isValid = false;
 
@@ -384,7 +384,7 @@
  */
 JNIEXPORT jbyteArray
 JNICALL Java_sun_security_ec_ECDHKeyAgreement_deriveKey
-  (JNIEnv *env, jclass clazz, jbyteArray privateKey, jbyteArray publicKey, jbyteArray encodedParams)
+  (JNIEnv *env, jclass UNUSED(clazz), jbyteArray privateKey, jbyteArray publicKey, jbyteArray encodedParams)
 {
     jbyteArray jSecret = NULL;
     ECParams *ecparams = NULL;
diff -r 984a4af2ed4e src/share/native/sun/security/ec/ecc_impl.h
--- /dev/null
+++ openjdk/jdk/src/share/native/sun/security/ec/ecc_impl.h
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, 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.
+ */
+
+/* *********************************************************************
+ *
+ * The Original Code is the Netscape security libraries.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1994-2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Dr Vipul Gupta <vipul.gupta@sun.com> and
+ *   Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
+ *
+ * Last Modified Date from the Original Code: May 2017
+ *********************************************************************** */
+
+#ifndef _ECC_IMPL_H
+#define _ECC_IMPL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+
+#ifdef SYSTEM_NSS
+#include <secitem.h>
+#include <secerr.h>
+#include <keythi.h>
+#ifdef LEGACY_NSS
+#include <softoken.h>
+#else
+#include <blapi.h>
+#endif
+#else
+#include "ecl-exp.h"
+#endif
+
+/*
+ * Multi-platform definitions
+ */
+#ifdef __linux__
+#define B_FALSE FALSE
+#define B_TRUE TRUE
+typedef unsigned char uint8_t;
+typedef unsigned long ulong_t;
+typedef enum { B_FALSE, B_TRUE } boolean_t;
+#endif /* __linux__ */
+
+#ifdef _ALLBSD_SOURCE
+#include <stdint.h>
+#define B_FALSE FALSE
+#define B_TRUE TRUE
+typedef unsigned long ulong_t;
+typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
+#endif /* _ALLBSD_SOURCE */
+
+#ifdef AIX
+#define B_FALSE FALSE
+#define B_TRUE TRUE
+typedef unsigned char uint8_t;
+typedef unsigned long ulong_t;
+#endif /* AIX */
+
+#ifdef _WIN32
+typedef unsigned char uint8_t;
+typedef unsigned long ulong_t;
+typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
+#define strdup _strdup          /* Replace POSIX name with ISO C++ name */
+#endif /* _WIN32 */
+
+#ifndef _KERNEL
+#include <stdlib.h>
+#endif  /* _KERNEL */
+
+#define EC_MAX_DIGEST_LEN 1024  /* max digest that can be signed */
+#define EC_MAX_POINT_LEN 145    /* max len of DER encoded Q */
+#define EC_MAX_VALUE_LEN 72     /* max len of ANSI X9.62 private value d */
+#define EC_MAX_SIG_LEN 144      /* max signature len for supported curves */
+#define EC_MIN_KEY_LEN  112     /* min key length in bits */
+#define EC_MAX_KEY_LEN  571     /* max key length in bits */
+#define EC_MAX_OID_LEN 10       /* max length of OID buffer */
+
+/*
+ * Various structures and definitions from NSS are here.
+ */
+
+#ifndef SYSTEM_NSS
+#ifdef _KERNEL
+#define PORT_ArenaAlloc(a, n, f)        kmem_alloc((n), (f))
+#define PORT_ArenaZAlloc(a, n, f)       kmem_zalloc((n), (f))
+#define PORT_ArenaGrow(a, b, c, d)      NULL
+#define PORT_ZAlloc(n, f)               kmem_zalloc((n), (f))
+#define PORT_Alloc(n, f)                kmem_alloc((n), (f))
+#else
+#define PORT_ArenaAlloc(a, n, f)        malloc((n))
+#define PORT_ArenaZAlloc(a, n, f)       calloc(1, (n))
+#define PORT_ArenaGrow(a, b, c, d)      NULL
+#define PORT_ZAlloc(n, f)               calloc(1, (n))
+#define PORT_Alloc(n, f)                malloc((n))
+#endif
+
+#define PORT_NewArena(b)                (char *)12345
+#define PORT_ArenaMark(a)               NULL
+#define PORT_ArenaUnmark(a, b)
+#define PORT_ArenaRelease(a, m)
+#define PORT_FreeArena(a, b)
+#define PORT_Strlen(s)                  strlen((s))
+#define PORT_SetError(e)
+
+#define PRBool                          boolean_t
+#define PR_TRUE                         B_TRUE
+#define PR_FALSE                        B_FALSE
+
+#ifdef _KERNEL
+#define PORT_Assert                     ASSERT
+#define PORT_Memcpy(t, f, l)            bcopy((f), (t), (l))
+#else
+#define PORT_Assert                     assert
+#define PORT_Memcpy(t, f, l)            memcpy((t), (f), (l))
+#endif
+
+#endif
+
+#define CHECK_OK(func) if (func == NULL) goto cleanup
+#define CHECK_SEC_OK(func) if (SECSuccess != (rv = func)) goto cleanup
+
+#ifndef SYSTEM_NSS
+typedef enum {
+        siBuffer = 0,
+        siClearDataBuffer = 1,
+        siCipherDataBuffer = 2,
+        siDERCertBuffer = 3,
+        siEncodedCertBuffer = 4,
+        siDERNameBuffer = 5,
+        siEncodedNameBuffer = 6,
+        siAsciiNameString = 7,
+        siAsciiString = 8,
+        siDEROID = 9,
+        siUnsignedInteger = 10,
+        siUTCTime = 11,
+        siGeneralizedTime = 12
+} SECItemType;
+
+typedef struct SECItemStr SECItem;
+
+struct SECItemStr {
+        SECItemType type;
+        unsigned char *data;
+        unsigned int len;
+};
+
+typedef SECItem SECKEYECParams;
+
+typedef enum { ec_params_explicit,
+               ec_params_named
+} ECParamsType;
+
+typedef enum { ec_field_GFp = 1,
+               ec_field_GF2m
+} ECFieldType;
+
+struct ECFieldIDStr {
+    int         size;   /* field size in bits */
+    ECFieldType type;
+    union {
+        SECItem  prime; /* prime p for (GFp) */
+        SECItem  poly;  /* irreducible binary polynomial for (GF2m) */
+    } u;
+    int         k1;     /* first coefficient of pentanomial or
+                         * the only coefficient of trinomial
+                         */
+    int         k2;     /* two remaining coefficients of pentanomial */
+    int         k3;
+};
+typedef struct ECFieldIDStr ECFieldID;
+
+struct ECCurveStr {
+        SECItem a;      /* contains octet stream encoding of
+                         * field element (X9.62 section 4.3.3)
+                         */
+        SECItem b;
+        SECItem seed;
+};
+typedef struct ECCurveStr ECCurve;
+
+typedef void PRArenaPool;
+
+struct ECParamsStr {
+    PRArenaPool * arena;
+    ECParamsType  type;
+    ECFieldID     fieldID;
+    ECCurve       curve;
+    SECItem       base;
+    SECItem       order;
+    int           cofactor;
+    SECItem       DEREncoding;
+    ECCurveName   name;
+    SECItem       curveOID;
+};
+typedef struct ECParamsStr ECParams;
+
+struct ECPublicKeyStr {
+    ECParams ecParams;
+    SECItem publicValue;   /* elliptic curve point encoded as
+                            * octet stream.
+                            */
+};
+typedef struct ECPublicKeyStr ECPublicKey;
+
+struct ECPrivateKeyStr {
+    ECParams ecParams;
+    SECItem publicValue;   /* encoded ec point */
+    SECItem privateValue;  /* private big integer */
+    SECItem version;       /* As per SEC 1, Appendix C, Section C.4 */
+};
+typedef struct ECPrivateKeyStr ECPrivateKey;
+
+typedef enum _SECStatus {
+        SECBufferTooSmall = -3,
+        SECWouldBlock = -2,
+        SECFailure = -1,
+        SECSuccess = 0
+} SECStatus;
+#endif
+
+#ifdef _KERNEL
+#define RNG_GenerateGlobalRandomBytes(p,l) ecc_knzero_random_generator((p), (l))
+#else
+/*
+ This function is no longer required because the random bytes are now
+ supplied by the caller. Force a failure.
+*/
+#define RNG_GenerateGlobalRandomBytes(p,l) SECFailure
+#endif
+#define CHECK_MPI_OK(func) if (MP_OKAY > (err = func)) goto cleanup
+#define MP_TO_SEC_ERROR(err)
+
+#define SECITEM_TO_MPINT(it, mp)                                        \
+        CHECK_MPI_OK(mp_read_unsigned_octets((mp), (it).data, (it).len))
+
+extern int ecc_knzero_random_generator(uint8_t *, size_t);
+extern ulong_t soft_nzero_random_generator(uint8_t *, ulong_t);
+
+#ifdef SYSTEM_NSS
+#define EC_DecodeParams(a,b,c) EC_DecodeParams(a,b)
+#define EC_NewKey(a,b,c,d,e) EC_NewKeyFromSeed(a,b,c,d)
+#define ECDSA_SignDigest(a,b,c,d,e,f,g) ECDSA_SignDigestWithSeed(a,b,c,d,e)
+#define ECDSA_VerifyDigest(a,b,c,d) ECDSA_VerifyDigest(a,b,c)
+#define ECDH_Derive(a,b,c,d,e,f) ECDH_Derive(a,b,c,d,e)
+#else
+extern SECStatus EC_DecodeParams(const SECItem *, ECParams **, int);
+
+extern SECItem * SECITEM_AllocItem(PRArenaPool *, SECItem *, unsigned int, int);
+extern SECStatus SECITEM_CopyItem(PRArenaPool *, SECItem *, const SECItem *,
+    int);
+extern void SECITEM_FreeItem(SECItem *, boolean_t);
+
+/* This function has been modified to accept an array of random bytes */
+extern SECStatus EC_NewKey(ECParams *ecParams, ECPrivateKey **privKey,
+    const unsigned char* random, int randomlen, int);
+/* This function has been modified to accept an array of random bytes */
+extern SECStatus ECDSA_SignDigest(ECPrivateKey *, SECItem *, const SECItem *,
+    const unsigned char* random, int randomlen, int, int timing);
+extern SECStatus ECDSA_VerifyDigest(ECPublicKey *, const SECItem *,
+    const SECItem *, int);
+extern SECStatus ECDH_Derive(SECItem *, ECParams *, SECItem *, boolean_t,
+    SECItem *, int);
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif /* _ECC_IMPL_H */
diff -r 984a4af2ed4e src/share/native/sun/security/ec/impl/ecc_impl.h
--- openjdk/jdk/src/share/native/sun/security/ec/impl/ecc_impl.h
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, 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.
- */
-
-/* *********************************************************************
- *
- * The Original Code is the Netscape security libraries.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1994-2000
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Dr Vipul Gupta <vipul.gupta@sun.com> and
- *   Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
- *
- * Last Modified Date from the Original Code: May 2017
- *********************************************************************** */
-
-#ifndef _ECC_IMPL_H
-#define _ECC_IMPL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include "ecl-exp.h"
-
-/*
- * Multi-platform definitions
- */
-#ifdef __linux__
-#define B_FALSE FALSE
-#define B_TRUE TRUE
-typedef unsigned char uint8_t;
-typedef unsigned long ulong_t;
-typedef enum { B_FALSE, B_TRUE } boolean_t;
-#endif /* __linux__ */
-
-#ifdef _ALLBSD_SOURCE
-#include <stdint.h>
-#define B_FALSE FALSE
-#define B_TRUE TRUE
-typedef unsigned long ulong_t;
-typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
-#endif /* _ALLBSD_SOURCE */
-
-#ifdef AIX
-#define B_FALSE FALSE
-#define B_TRUE TRUE
-typedef unsigned char uint8_t;
-typedef unsigned long ulong_t;
-#endif /* AIX */
-
-#ifdef _WIN32
-typedef unsigned char uint8_t;
-typedef unsigned long ulong_t;
-typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
-#define strdup _strdup          /* Replace POSIX name with ISO C++ name */
-#endif /* _WIN32 */
-
-#ifndef _KERNEL
-#include <stdlib.h>
-#endif  /* _KERNEL */
-
-#define EC_MAX_DIGEST_LEN 1024  /* max digest that can be signed */
-#define EC_MAX_POINT_LEN 145    /* max len of DER encoded Q */
-#define EC_MAX_VALUE_LEN 72     /* max len of ANSI X9.62 private value d */
-#define EC_MAX_SIG_LEN 144      /* max signature len for supported curves */
-#define EC_MIN_KEY_LEN  112     /* min key length in bits */
-#define EC_MAX_KEY_LEN  571     /* max key length in bits */
-#define EC_MAX_OID_LEN 10       /* max length of OID buffer */
-
-/*
- * Various structures and definitions from NSS are here.
- */
-
-#ifdef _KERNEL
-#define PORT_ArenaAlloc(a, n, f)        kmem_alloc((n), (f))
-#define PORT_ArenaZAlloc(a, n, f)       kmem_zalloc((n), (f))
-#define PORT_ArenaGrow(a, b, c, d)      NULL
-#define PORT_ZAlloc(n, f)               kmem_zalloc((n), (f))
-#define PORT_Alloc(n, f)                kmem_alloc((n), (f))
-#else
-#define PORT_ArenaAlloc(a, n, f)        malloc((n))
-#define PORT_ArenaZAlloc(a, n, f)       calloc(1, (n))
-#define PORT_ArenaGrow(a, b, c, d)      NULL
-#define PORT_ZAlloc(n, f)               calloc(1, (n))
-#define PORT_Alloc(n, f)                malloc((n))
-#endif
-
-#define PORT_NewArena(b)                (char *)12345
-#define PORT_ArenaMark(a)               NULL
-#define PORT_ArenaUnmark(a, b)
-#define PORT_ArenaRelease(a, m)
-#define PORT_FreeArena(a, b)
-#define PORT_Strlen(s)                  strlen((s))
-#define PORT_SetError(e)
-
-#define PRBool                          boolean_t
-#define PR_TRUE                         B_TRUE
-#define PR_FALSE                        B_FALSE
-
-#ifdef _KERNEL
-#define PORT_Assert                     ASSERT
-#define PORT_Memcpy(t, f, l)            bcopy((f), (t), (l))
-#else
-#define PORT_Assert                     assert
-#define PORT_Memcpy(t, f, l)            memcpy((t), (f), (l))
-#endif
-
-#define CHECK_OK(func) if (func == NULL) goto cleanup
-#define CHECK_SEC_OK(func) if (SECSuccess != (rv = func)) goto cleanup
-
-typedef enum {
-        siBuffer = 0,
-        siClearDataBuffer = 1,
-        siCipherDataBuffer = 2,
-        siDERCertBuffer = 3,
-        siEncodedCertBuffer = 4,
-        siDERNameBuffer = 5,
-        siEncodedNameBuffer = 6,
-        siAsciiNameString = 7,
-        siAsciiString = 8,
-        siDEROID = 9,
-        siUnsignedInteger = 10,
-        siUTCTime = 11,
-        siGeneralizedTime = 12
-} SECItemType;
-
-typedef struct SECItemStr SECItem;
-
-struct SECItemStr {
-        SECItemType type;
-        unsigned char *data;
-        unsigned int len;
-};
-
-typedef SECItem SECKEYECParams;
-
-typedef enum { ec_params_explicit,
-               ec_params_named
-} ECParamsType;
-
-typedef enum { ec_field_GFp = 1,
-               ec_field_GF2m
-} ECFieldType;
-
-struct ECFieldIDStr {
-    int         size;   /* field size in bits */
-    ECFieldType type;
-    union {
-        SECItem  prime; /* prime p for (GFp) */
-        SECItem  poly;  /* irreducible binary polynomial for (GF2m) */
-    } u;
-    int         k1;     /* first coefficient of pentanomial or
-                         * the only coefficient of trinomial
-                         */
-    int         k2;     /* two remaining coefficients of pentanomial */
-    int         k3;
-};
-typedef struct ECFieldIDStr ECFieldID;
-
-struct ECCurveStr {
-        SECItem a;      /* contains octet stream encoding of
-                         * field element (X9.62 section 4.3.3)
-                         */
-        SECItem b;
-        SECItem seed;
-};
-typedef struct ECCurveStr ECCurve;
-
-typedef void PRArenaPool;
-
-struct ECParamsStr {
-    PRArenaPool * arena;
-    ECParamsType  type;
-    ECFieldID     fieldID;
-    ECCurve       curve;
-    SECItem       base;
-    SECItem       order;
-    int           cofactor;
-    SECItem       DEREncoding;
-    ECCurveName   name;
-    SECItem       curveOID;
-};
-typedef struct ECParamsStr ECParams;
-
-struct ECPublicKeyStr {
-    ECParams ecParams;
-    SECItem publicValue;   /* elliptic curve point encoded as
-                            * octet stream.
-                            */
-};
-typedef struct ECPublicKeyStr ECPublicKey;
-
-struct ECPrivateKeyStr {
-    ECParams ecParams;
-    SECItem publicValue;   /* encoded ec point */
-    SECItem privateValue;  /* private big integer */
-    SECItem version;       /* As per SEC 1, Appendix C, Section C.4 */
-};
-typedef struct ECPrivateKeyStr ECPrivateKey;
-
-typedef enum _SECStatus {
-        SECBufferTooSmall = -3,
-        SECWouldBlock = -2,
-        SECFailure = -1,
-        SECSuccess = 0
-} SECStatus;
-
-#ifdef _KERNEL
-#define RNG_GenerateGlobalRandomBytes(p,l) ecc_knzero_random_generator((p), (l))
-#else
-/*
- This function is no longer required because the random bytes are now
- supplied by the caller. Force a failure.
-*/
-#define RNG_GenerateGlobalRandomBytes(p,l) SECFailure
-#endif
-#define CHECK_MPI_OK(func) if (MP_OKAY > (err = func)) goto cleanup
-#define MP_TO_SEC_ERROR(err)
-
-#define SECITEM_TO_MPINT(it, mp)                                        \
-        CHECK_MPI_OK(mp_read_unsigned_octets((mp), (it).data, (it).len))
-
-extern int ecc_knzero_random_generator(uint8_t *, size_t);
-extern ulong_t soft_nzero_random_generator(uint8_t *, ulong_t);
-
-extern SECStatus EC_DecodeParams(const SECItem *, ECParams **, int);
-extern SECItem * SECITEM_AllocItem(PRArenaPool *, SECItem *, unsigned int, int);
-extern SECStatus SECITEM_CopyItem(PRArenaPool *, SECItem *, const SECItem *,
-    int);
-extern void SECITEM_FreeItem(SECItem *, boolean_t);
-/* This function has been modified to accept an array of random bytes */
-extern SECStatus EC_NewKey(ECParams *ecParams, ECPrivateKey **privKey,
-    const unsigned char* random, int randomlen, int);
-/* This function has been modified to accept an array of random bytes */
-extern SECStatus ECDSA_SignDigest(ECPrivateKey *, SECItem *, const SECItem *,
-    const unsigned char* random, int randomlen, int, int timing);
-extern SECStatus ECDSA_VerifyDigest(ECPublicKey *, const SECItem *,
-    const SECItem *, int);
-extern SECStatus ECDH_Derive(SECItem *, ECParams *, SECItem *, boolean_t,
-    SECItem *, int);
-
-#ifdef  __cplusplus
-}
-#endif
-
-#endif /* _ECC_IMPL_H */
diff -r 984a4af2ed4e src/solaris/javavm/export/jni_md.h
--- openjdk/jdk/src/solaris/javavm/export/jni_md.h
+++ openjdk/jdk/src/solaris/javavm/export/jni_md.h
@@ -36,6 +36,11 @@
   #define JNIEXPORT
   #define JNIIMPORT
 #endif
+#if (defined(__GNUC__)) || __has_attribute(unused)
+  #define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
+#else
+  #define UNUSED(x) UNUSED_ ## x
+#endif
 
 #define JNICALL