8079898: Resolve disabled warnings for libj2ucrypto
authorvaleriep
Fri, 09 Dec 2016 02:26:48 +0000
changeset 42457 cd246ab491f9
parent 42456 c328a7d6688e
child 42458 932634f64708
8079898: Resolve disabled warnings for libj2ucrypto Summary: Updated header/code to address the E_MACRO_REDEFINED warning Reviewed-by: ascarpino, ihse
jdk/make/lib/Lib-jdk.crypto.ucrypto.gmk
jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c
jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.h
jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCryptoMD.c
--- a/jdk/make/lib/Lib-jdk.crypto.ucrypto.gmk	Thu Dec 08 21:21:39 2016 +0000
+++ b/jdk/make/lib/Lib-jdk.crypto.ucrypto.gmk	Fri Dec 09 02:26:48 2016 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2016, 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
@@ -38,7 +38,6 @@
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKLIB) \
           $(addprefix -I, $(LIBJ2UCRYPTO_SRC)), \
-      DISABLED_WARNINGS_solstudio := E_MACRO_REDEFINED, \
       MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libj2ucrypto/mapfile-vers, \
       LDFLAGS := $(LDFLAGS_JDKLIB), \
       LIBS := $(LIBDL), \
--- a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c	Thu Dec 08 21:21:39 2016 +0000
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c	Fri Dec 09 02:26:48 2016 +0000
@@ -122,14 +122,14 @@
   jResult = NULL;
   if (ftab->ucryptoVersion != NULL && ftab->ucryptoGetMechList != NULL) {
       length = (*ftab->ucryptoGetMechList)(NULL);
-      if (DEBUG) printf("mech list length: %d\n", length);
+      if (J2UC_DEBUG) printf("mech list length: %d\n", length);
       result = malloc(length);
       if (result == NULL) {
         throwOutOfMemoryError(env, NULL);
         return NULL;
       }
       length = (*ftab->ucryptoGetMechList)(result);
-      if (DEBUG) printf("mech list: %s\n", result);
+      if (J2UC_DEBUG) printf("mech list: %s\n", result);
       jResult = (*env)->NewStringUTF(env, result);
       free(result);
   } else {
@@ -201,7 +201,7 @@
   void *iv;
   size_t ivLen;
 
-  if (DEBUG) printf("CipherInit: mech %i, key %i(%i), iv %i(%i) tagLen %i, aad %i(%i)\n",
+  if (J2UC_DEBUG) printf("CipherInit: mech %i, key %i(%i), iv %i(%i) tagLen %i, aad %i(%i)\n",
                     mech, jKey, jKeyLen, jIv, jIvLen, tagLen, jAad, jAadLen);
   if (mech == CRYPTO_AES_CTR) {
     ivLen = sizeof(CK_AES_CTR_PARAMS);
@@ -228,10 +228,10 @@
   }
   if (encrypt) {
     rv = (*ftab->ucryptoEncryptInit)(context, mech, jKey, (size_t)jKeyLen, iv, ivLen);
-    if (rv != 0 && DEBUG) printError("ucryptoEncryptInit", mech, rv);
+    if (rv != 0 && J2UC_DEBUG) printError("ucryptoEncryptInit", mech, rv);
   } else {
     rv =(*ftab->ucryptoDecryptInit)(context, mech, jKey, (size_t)jKeyLen, iv, ivLen);
-    if (rv != 0 && DEBUG) printError("ucryptoDecryptInit", mech, rv);
+    if (rv != 0 && J2UC_DEBUG) printError("ucryptoDecryptInit", mech, rv);
   }
 
   if (iv != jIv) {
@@ -253,23 +253,23 @@
   size_t outLength;
 
   outLength = (size_t) *outLen;
-  if (DEBUG) {
+  if (J2UC_DEBUG) {
     printf("CipherUpdate: Inofs %i, InLen %i, OutOfs %i, OutLen %i\n", inOfs, inLen, outOfs, *outLen);
     printBytes("BufIn=", (unsigned char*)(bufIn+inOfs), inLen);
   }
   if (encrypt) {
     rv = (*ftab->ucryptoEncryptUpdate)(context, (unsigned char*)(bufIn+inOfs), (size_t)inLen, (unsigned char*)(bufOut+outOfs), &outLength);
     if (rv) {
-      if (DEBUG) printError("ucryptoEncryptUpdate", -1, rv);
+      if (J2UC_DEBUG) printError("ucryptoEncryptUpdate", -1, rv);
     } else {
       *outLen = (int)outLength;
     }
   } else {
     rv = (*ftab->ucryptoDecryptUpdate)(context, (unsigned char*)(bufIn+inOfs), (size_t)inLen, (unsigned char*)(bufOut+outOfs), &outLength);
     if (rv) {
-      if (DEBUG) printError("ucryptoDecryptUpdate", -1, rv);
+      if (J2UC_DEBUG) printError("ucryptoDecryptUpdate", -1, rv);
     } else {
-      if (DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
+      if (J2UC_DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
       *outLen = (int)outLength;
     }
   }
@@ -285,21 +285,21 @@
 
   outLength = (size_t)*outLen;
 
-  if (DEBUG) printf("CipherFinal: OutOfs %i, outLen %i\n", outOfs, *outLen);
+  if (J2UC_DEBUG) printf("CipherFinal: OutOfs %i, outLen %i\n", outOfs, *outLen);
   if (encrypt) {
     rv = (*ftab->ucryptoEncryptFinal)(context, (unsigned char*)(bufOut+outOfs), &outLength);
     if (rv) {
-      if (DEBUG) printError("ucryptoDecryptFinal", -1, rv);
+      if (J2UC_DEBUG) printError("ucryptoDecryptFinal", -1, rv);
     } else {
-      if (DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
+      if (J2UC_DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
       *outLen = (int)outLength;
     }
   } else {
     rv = (*ftab->ucryptoDecryptFinal)(context, (unsigned char*)(bufOut+outOfs), &outLength);
     if (rv) {
-      if (DEBUG) printError("ucryptoDecryptFinal", -1, rv);
+      if (J2UC_DEBUG) printError("ucryptoDecryptFinal", -1, rv);
     } else {
-      if (DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
+      if (J2UC_DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
       *outLen = (int)outLength;
     }
   }
@@ -318,7 +318,7 @@
     rv = (*ftab->ucryptoDigestInit)(context, (ucrypto_mech_t) mech, NULL, 0);
     if (rv) {
       freeContext(context);
-      if (DEBUG) printError("ucryptoDigestInit", mech, rv);
+      if (J2UC_DEBUG) printError("ucryptoDigestInit", mech, rv);
       return 0L;
     }
   }
@@ -336,7 +336,7 @@
 
   if (rv) {
     freeContext(context);
-    if (DEBUG) printError("ucryptoDigestUpdate", mech, rv);
+    if (J2UC_DEBUG) printError("ucryptoDigestUpdate", mech, rv);
   }
 
   return -rv; // use negative value to indicate error
@@ -353,7 +353,7 @@
                                    &digest_len);
   if (rv) {
     freeContext(context);
-    if (DEBUG) printError("ucryptoDigestFinal", mech, rv);
+    if (J2UC_DEBUG) printError("ucryptoDigestFinal", mech, rv);
   }
 
   return -rv; // use negative value to indicate error
@@ -959,7 +959,7 @@
     memcpy(pub, jPub, pubLen);
   }
 
-  if (DEBUG) {
+  if (J2UC_DEBUG) {
     printf("RSAPublicKey.nativeInit: keyValue=%ld, keyLen=2\n", pKey);
     printBytes("\tmod: ", (unsigned char*) mod, modLen);
     printBytes("\tpubExp: ", (unsigned char*) pub, pubLen);
@@ -1035,7 +1035,7 @@
     rv = (*ftab->ucryptoVerifyInit)(context, mech, pKey, keyLength,
                                     NULL, 0);
   }
-  if (DEBUG) {
+  if (J2UC_DEBUG) {
     printf("SignatureInit: context=%ld, mech=%d, sign=%d, keyValue=%ld, keyLength=%d\n",
            context, mech, sign, pKey, keyLength);
     printError("SignatureInit", mech, rv);
@@ -1100,7 +1100,7 @@
   int rv = 0;
 
   context = (crypto_ctx_t *) pCtxt;
-  if (DEBUG) {
+  if (J2UC_DEBUG) {
     printf("NativeRSASignature.nativeUpdate: context=%ld, sign=%d, jIn=%ld, jInOfs=%d, jInLen=%d\n",
            context, sign, jIn, jInOfs, jInLen);
   }
@@ -1111,7 +1111,7 @@
   }
   if (rv) {
     freeContext(context);
-    if (DEBUG) printError("NativeRSASignature.nativeUpdate", -1, rv);
+    if (J2UC_DEBUG) printError("NativeRSASignature.nativeUpdate", -1, rv);
     return -rv; // use negative value to indicate error!
   }
 
@@ -1128,7 +1128,7 @@
     return -1; // use negative value to indicate error!
   }
 
-  if (DEBUG) printBytes("Update w/ data: ", (unsigned char*)bufIn, (size_t) inLen);
+  if (J2UC_DEBUG) printBytes("Update w/ data: ", (unsigned char*)bufIn, (size_t) inLen);
 
   rv = JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__JZ_3BII
     (pCtxt, sign, inLen, bufIn, 0, inLen);
@@ -1169,7 +1169,7 @@
   size_t sigLength = (size_t) jSigLen;
 
   context = (crypto_ctx_t *) pCtxt;
-  if (DEBUG) {
+  if (J2UC_DEBUG) {
       printf("NativeRSASignature.nativeFinal: context=%ld, sign=%d, bufSig=%ld, sigOfs=%d, sigLen=%d\n",
              context, sign, bufSig, sigOfs, jSigLen);
       printBytes("Before: SigBytes ", (unsigned char*) (bufSig + sigOfs), jSigLen);
@@ -1182,7 +1182,7 @@
 
   freeContext(context);
   if (rv) {
-    if (DEBUG) {
+    if (J2UC_DEBUG) {
       printError("NativeRSASignature.nativeFinal", -1, rv);
       if (sigLength != jSigLen) {
         printf("NativeRSASignature.nativeFinal out sig len=%d\n", sigLength);
@@ -1247,7 +1247,7 @@
   size_t outLength = (size_t) jOutLen;
 
   pKey = (uchar_t *) keyValue;
-  if (DEBUG) {
+  if (J2UC_DEBUG) {
     printf("NativeRSACipher.nativeAtomic: mech=%d, encrypt=%d, pKey=%ld, keyLength=%d\n",
            mech, encrypt, pKey, keyLength);
     printBytes("Before: in  = ", (unsigned char*) bufIn, jInLen);
@@ -1263,7 +1263,7 @@
       NULL, 0, (uchar_t *)bufIn, (size_t)jInLen,
       (uchar_t *)(bufOut + jOutOfs), &outLength);
   }
-  if (DEBUG) {
+  if (J2UC_DEBUG) {
     printError("NativeRSACipher.nativeAtomic", mech, rv);
     if (outLength != jOutLen) {
       printf("NativeRSACipher.nativeAtomic out len=%d\n", outLength);
--- a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.h	Thu Dec 08 21:21:39 2016 +0000
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.h	Fri Dec 09 02:26:48 2016 +0000
@@ -31,29 +31,6 @@
 extern "C" {
 #endif
 
-// used by nativeCrypto.c
-#ifdef _LIBUCRYPTO_H // workaround for Solaris bug; see 8157627
-#define CK_AES_CTR_PARAMS    crypto_ctr_params_t
-#define ulCounterBits    ct_ctr_bits
-#define cb        ct_cb
-
-#define CK_AES_CCM_PARAMS    crypto_ccm_params_t
-#define ulMACSize    cc_mac_size
-#define ulNonceSize    cc_nonce_size
-#define ulAuthDataSize    cc_auth_data_size
-#define ulDataSize    cc_data_size
-#define nonce        cc_nonce
-#define authData    cc_auth_data
-
-#define CK_AES_GCM_PARAMS    crypto_gcm_params_t
-#define pIv        gc_iv
-#define ulIvLen        gc_iv_len
-#define ulIvBits    gc_iv_bits
-#define pAAD        gc_aad
-#define ulAADLen    gc_aad_len
-#define ulTagBits    gc_tag_bits
-#endif
-
 // used by nativeCryptoMD.c
 #undef com_oracle_security_ucrypto_NativeDigestMD_MECH_MD5
 #define com_oracle_security_ucrypto_NativeDigestMD_MECH_MD5 1L
@@ -68,7 +45,7 @@
 #undef com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA512
 #define com_oracle_security_ucrypto_NativeDigestMD_MECH_SHA512 6L
 
-#define DEBUG 0
+#define J2UC_DEBUG 0
 
 #ifdef __cplusplus
 }
--- a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCryptoMD.c	Thu Dec 08 21:21:39 2016 +0000
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCryptoMD.c	Fri Dec 09 02:26:48 2016 +0000
@@ -73,7 +73,7 @@
     }
     break;
   default:
-    if (DEBUG) printf("ERROR: Unsupported mech %i\n", mech);
+    if (J2UC_DEBUG) printf("ERROR: Unsupported mech %i\n", mech);
   }
   return (jlong) pContext;
 }