Blame pr1983-rh1565658-support_using_the_system_installation_of_nss_with_the_sunec_provider_jdk8.patch

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