8079898: Resolve disabled warnings for libj2ucrypto

Updated header/code to address the E_MACRO_REDEFINED warning

Reviewed-by: ascarpino, ihse
This commit is contained in:
Valerie Peng 2016-12-09 02:26:48 +00:00
parent 9f9d019e9f
commit 37dc5b02ab
4 changed files with 29 additions and 53 deletions

View File

@ -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 @@ ifeq ($(OPENJDK_TARGET_OS), solaris)
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), \

View File

@ -122,14 +122,14 @@ JNIEXPORT jstring JNICALL Java_com_oracle_security_ucrypto_UcryptoProvider_getMe
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 @@ CipherInit(crypto_ctx_t *context, int encrypt, ucrypto_mech_t mech,
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 @@ CipherInit(crypto_ctx_t *context, int encrypt, ucrypto_mech_t mech,
}
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 @@ CipherUpdate(crypto_ctx_t *context, int encrypt, unsigned char *bufIn, int inOfs
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 @@ CipherFinal(crypto_ctx_t *context, int encrypt, unsigned char *bufOut, int outOf
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 @@ jlong JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeInit(jint mech
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 @@ jint JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeUpdate
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 @@ jint JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeDigest
&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 @@ jlong JavaCritical_com_oracle_security_ucrypto_NativeKey_00024RSAPublic_nativeIn
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 @@ SignatureInit(crypto_ctx_t *context, jint mechVal, jboolean sign,
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 @@ jint JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__J
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 @@ jint JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__J
}
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 @@ JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeRSASignature_nativ
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 @@ jint JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeFinal
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 @@ jint JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeFinal
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 @@ jint JavaCritical_com_oracle_security_ucrypto_NativeRSACipher_nativeAtomic
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 @@ jint JavaCritical_com_oracle_security_ucrypto_NativeRSACipher_nativeAtomic
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);

View File

@ -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 @@ extern "C" {
#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
}

View File

@ -73,7 +73,7 @@ jlong JavaCritical_com_oracle_security_ucrypto_NativeDigestMD_nativeInit(jint me
}
break;
default:
if (DEBUG) printf("ERROR: Unsupported mech %i\n", mech);
if (J2UC_DEBUG) printf("ERROR: Unsupported mech %i\n", mech);
}
return (jlong) pContext;
}