mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
7103549: Remove dependencies on libjava and libjvm from security libraries
Reviewed-by: vinnie, ohair, alanb, dholmes
This commit is contained in:
parent
de7b261476
commit
f5ff85a77a
23 changed files with 180 additions and 134 deletions
|
@ -78,7 +78,3 @@ endif # linux
|
||||||
#
|
#
|
||||||
include $(BUILDDIR)/common/Library.gmk
|
include $(BUILDDIR)/common/Library.gmk
|
||||||
|
|
||||||
#
|
|
||||||
# JVMDI implementation lives in the VM.
|
|
||||||
#
|
|
||||||
OTHER_LDLIBS = $(JVMLIB)
|
|
||||||
|
|
|
@ -220,14 +220,30 @@ JDK_LOCALES = ja zh_CN
|
||||||
JRE_NONEXIST_LOCALES = en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh
|
JRE_NONEXIST_LOCALES = en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh
|
||||||
|
|
||||||
#
|
#
|
||||||
# All libraries except libjava and libjvm itself link against libjvm and
|
# For now, most libraries except libjava and libjvm itself link against libjvm
|
||||||
# libjava, the latter for its exported common utilities. libjava only links
|
# and libjava, the latter for its exported common utilities. libjava only
|
||||||
# against libjvm. Programs' makefiles take their own responsibility for
|
# links against libjvm. Programs' makefiles take their own responsibility for
|
||||||
# adding other libs.
|
# adding other libs.
|
||||||
#
|
#
|
||||||
|
# The makefiles for these packages do not link against libjvm and libjava.
|
||||||
|
# This list will eventually go away and each Programs' makefiles
|
||||||
|
# will have to explicitly declare that they want to link to libjava/libjvm
|
||||||
|
#
|
||||||
|
NO_JAVALIB_PKGS = \
|
||||||
|
sun.security.mscapi \
|
||||||
|
sun.security.krb5 \
|
||||||
|
sun.security.pkcs11 \
|
||||||
|
sun.security.jgss \
|
||||||
|
sun.security.jgss.wrapper \
|
||||||
|
sun.security.ec \
|
||||||
|
sun.security.smartcardio \
|
||||||
|
com.sun.security.auth.module
|
||||||
|
|
||||||
ifdef PACKAGE
|
ifdef PACKAGE
|
||||||
# put JAVALIB first, but do not lose any platform specific values....
|
# put JAVALIB first, but do not lose any platform specific values....
|
||||||
LDLIBS_COMMON = $(JAVALIB)
|
ifeq (,$(findstring $(PACKAGE),$(NO_JAVALIB_PKGS)))
|
||||||
|
LDLIBS_COMMON = $(JAVALIB)
|
||||||
|
endif
|
||||||
endif # PACKAGE
|
endif # PACKAGE
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -165,7 +165,7 @@ $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
|
||||||
$(LINK) -dll -out:$(OBJDIR)/$(@F) \
|
$(LINK) -dll -out:$(OBJDIR)/$(@F) \
|
||||||
-map:$(OBJDIR)/$(LIBRARY).map \
|
-map:$(OBJDIR)/$(LIBRARY).map \
|
||||||
$(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
|
$(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
|
||||||
$(OTHER_LCF) $(JAVALIB) $(LDLIBS)
|
$(OTHER_LCF) $(LDLIBS)
|
||||||
$(CP) $(OBJDIR)/$(@F) $@
|
$(CP) $(OBJDIR)/$(@F) $@
|
||||||
@$(call binary_file_verification,$@)
|
@$(call binary_file_verification,$@)
|
||||||
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
|
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
|
||||||
|
|
|
@ -192,10 +192,8 @@ ifeq ($(NATIVE_ECC_AVAILABLE), true)
|
||||||
#
|
#
|
||||||
# Libraries to link
|
# Libraries to link
|
||||||
#
|
#
|
||||||
ifeq ($(PLATFORM), windows)
|
ifneq ($(PLATFORM), windows)
|
||||||
OTHER_LDLIBS += $(JVMLIB)
|
OTHER_LDLIBS = $(LIBCXX)
|
||||||
else
|
|
||||||
OTHER_LDLIBS = -ldl $(JVMLIB) $(LIBCXX)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(BUILDDIR)/common/Mapfile-vers.gmk
|
include $(BUILDDIR)/common/Mapfile-vers.gmk
|
||||||
|
|
|
@ -72,5 +72,6 @@ include $(BUILDDIR)/common/Library.gmk
|
||||||
# Libraries to link
|
# Libraries to link
|
||||||
#
|
#
|
||||||
ifneq ($(PLATFORM), windows)
|
ifneq ($(PLATFORM), windows)
|
||||||
OTHER_LDLIBS = -ldl $(JVMLIB)
|
OTHER_LDLIBS = -ldl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -69,15 +69,6 @@ else
|
||||||
include $(BUILDDIR)/common/Classes.gmk
|
include $(BUILDDIR)/common/Classes.gmk
|
||||||
endif # PLATFORM
|
endif # PLATFORM
|
||||||
|
|
||||||
#
|
|
||||||
# Libraries to link
|
|
||||||
#
|
|
||||||
ifeq ($(PLATFORM), windows)
|
|
||||||
OTHER_LDLIBS = $(JVMLIB)
|
|
||||||
else
|
|
||||||
OTHER_LDLIBS = -ldl $(JVMLIB)
|
|
||||||
endif
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
ifeq ($(PLATFORM),windows)
|
ifeq ($(PLATFORM),windows)
|
||||||
$(call make-launcher, kinit, sun.security.krb5.internal.tools.Kinit, , )
|
$(call make-launcher, kinit, sun.security.krb5.internal.tools.Kinit, , )
|
||||||
|
|
|
@ -159,7 +159,7 @@ include $(BUILDDIR)/common/Library.gmk
|
||||||
# Libraries to link
|
# Libraries to link
|
||||||
#
|
#
|
||||||
ifeq ($(PLATFORM), windows)
|
ifeq ($(PLATFORM), windows)
|
||||||
OTHER_LDLIBS += $(JVMLIB) Crypt32.Lib
|
OTHER_LDLIBS += Crypt32.Lib
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -159,10 +159,8 @@ include $(BUILDDIR)/common/Library.gmk
|
||||||
#
|
#
|
||||||
# Libraries to link
|
# Libraries to link
|
||||||
#
|
#
|
||||||
ifeq ($(PLATFORM), windows)
|
ifneq ($(PLATFORM), windows)
|
||||||
OTHER_LDLIBS = $(JVMLIB)
|
OTHER_LDLIBS = -ldl
|
||||||
else
|
|
||||||
OTHER_LDLIBS = -ldl $(JVMLIB)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Other config files
|
# Other config files
|
||||||
|
|
|
@ -73,8 +73,8 @@ include $(BUILDDIR)/common/Library.gmk
|
||||||
# Libraries to link
|
# Libraries to link
|
||||||
#
|
#
|
||||||
ifeq ($(PLATFORM), windows)
|
ifeq ($(PLATFORM), windows)
|
||||||
OTHER_LDLIBS = $(JVMLIB) winscard.lib
|
OTHER_LDLIBS = winscard.lib
|
||||||
else
|
else
|
||||||
OTHER_LDLIBS = -ldl $(JVMLIB)
|
OTHER_LDLIBS = -ldl
|
||||||
OTHER_CFLAGS = -D__sun_jdk
|
OTHER_CFLAGS = -D__sun_jdk
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -273,7 +273,7 @@ CK_VERSION_PTR jVersionToCKVersionPtr(JNIEnv *env, jobject jVersion)
|
||||||
/* allocate memory for CK_VERSION pointer */
|
/* allocate memory for CK_VERSION pointer */
|
||||||
ckpVersion = (CK_VERSION_PTR) malloc(sizeof(CK_VERSION));
|
ckpVersion = (CK_VERSION_PTR) malloc(sizeof(CK_VERSION));
|
||||||
if (ckpVersion == NULL) {
|
if (ckpVersion == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ckpVersion->major = jByteToCKByte(jMajor);
|
ckpVersion->major = jByteToCKByte(jMajor);
|
||||||
|
@ -326,7 +326,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
|
||||||
/* allocate memory for CK_DATE pointer */
|
/* allocate memory for CK_DATE pointer */
|
||||||
ckpDate = (CK_DATE *) malloc(sizeof(CK_DATE));
|
ckpDate = (CK_DATE *) malloc(sizeof(CK_DATE));
|
||||||
if (ckpDate == NULL) {
|
if (ckpDate == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
|
||||||
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
|
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
|
||||||
if (jTempChars == NULL) {
|
if (jTempChars == NULL) {
|
||||||
free(ckpDate);
|
free(ckpDate);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
(*env)->GetCharArrayRegion(env, jYear, 0, ckLength, jTempChars);
|
(*env)->GetCharArrayRegion(env, jYear, 0, ckLength, jTempChars);
|
||||||
|
@ -364,7 +364,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
|
||||||
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
|
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
|
||||||
if (jTempChars == NULL) {
|
if (jTempChars == NULL) {
|
||||||
free(ckpDate);
|
free(ckpDate);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
(*env)->GetCharArrayRegion(env, jMonth, 0, ckLength, jTempChars);
|
(*env)->GetCharArrayRegion(env, jMonth, 0, ckLength, jTempChars);
|
||||||
|
@ -388,7 +388,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
|
||||||
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
|
jTempChars = (jchar*) malloc((ckLength) * sizeof(jchar));
|
||||||
if (jTempChars == NULL) {
|
if (jTempChars == NULL) {
|
||||||
free(ckpDate);
|
free(ckpDate);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
(*env)->GetCharArrayRegion(env, jDay, 0, ckLength, jTempChars);
|
(*env)->GetCharArrayRegion(env, jDay, 0, ckLength, jTempChars);
|
||||||
|
@ -558,7 +558,7 @@ CK_TLS_PRF_PARAMS jTlsPrfParamsToCKTlsPrfParam(JNIEnv *env, jobject jParam)
|
||||||
if (ckParam.pulOutputLen == NULL) {
|
if (ckParam.pulOutputLen == NULL) {
|
||||||
free(ckParam.pSeed);
|
free(ckParam.pSeed);
|
||||||
free(ckParam.pLabel);
|
free(ckParam.pLabel);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return ckParam;
|
return ckParam;
|
||||||
}
|
}
|
||||||
jByteArrayToCKByteArray(env, jOutput, &(ckParam.pOutput), ckParam.pulOutputLen);
|
jByteArrayToCKByteArray(env, jOutput, &(ckParam.pOutput), ckParam.pulOutputLen);
|
||||||
|
@ -665,7 +665,7 @@ CK_SSL3_KEY_MAT_PARAMS jSsl3KeyMatParamToCKSsl3KeyMatParam(JNIEnv *env, jobject
|
||||||
if (ckParam.pReturnedKeyMaterial == NULL) {
|
if (ckParam.pReturnedKeyMaterial == NULL) {
|
||||||
free(ckParam.RandomInfo.pClientRandom);
|
free(ckParam.RandomInfo.pClientRandom);
|
||||||
free(ckParam.RandomInfo.pServerRandom);
|
free(ckParam.RandomInfo.pServerRandom);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return ckParam;
|
return ckParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,7 +1013,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR) malloc(sizeof(CK_SSL3_MASTER_KEY_DERIVE_PARAMS));
|
ckpParam = (CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR) malloc(sizeof(CK_SSL3_MASTER_KEY_DERIVE_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_SSL3_KEY_MAT_PARAMS_PTR) malloc(sizeof(CK_SSL3_KEY_MAT_PARAMS));
|
ckpParam = (CK_SSL3_KEY_MAT_PARAMS_PTR) malloc(sizeof(CK_SSL3_KEY_MAT_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1067,7 +1067,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_TLS_PRF_PARAMS_PTR) malloc(sizeof(CK_TLS_PRF_PARAMS));
|
ckpParam = (CK_TLS_PRF_PARAMS_PTR) malloc(sizeof(CK_TLS_PRF_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,7 +1094,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_AES_CTR_PARAMS_PTR) malloc(sizeof(CK_AES_CTR_PARAMS));
|
ckpParam = (CK_AES_CTR_PARAMS_PTR) malloc(sizeof(CK_AES_CTR_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,7 +1121,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_RSA_PKCS_OAEP_PARAMS_PTR) malloc(sizeof(CK_RSA_PKCS_OAEP_PARAMS));
|
ckpParam = (CK_RSA_PKCS_OAEP_PARAMS_PTR) malloc(sizeof(CK_RSA_PKCS_OAEP_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1148,7 +1148,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_PBE_PARAMS_PTR) malloc(sizeof(CK_PBE_PARAMS));
|
ckpParam = (CK_PBE_PARAMS_PTR) malloc(sizeof(CK_PBE_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1175,7 +1175,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_PKCS5_PBKD2_PARAMS_PTR) malloc(sizeof(CK_PKCS5_PBKD2_PARAMS));
|
ckpParam = (CK_PKCS5_PBKD2_PARAMS_PTR) malloc(sizeof(CK_PKCS5_PBKD2_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1202,7 +1202,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_RSA_PKCS_PSS_PARAMS_PTR) malloc(sizeof(CK_RSA_PKCS_PSS_PARAMS));
|
ckpParam = (CK_RSA_PKCS_PSS_PARAMS_PTR) malloc(sizeof(CK_RSA_PKCS_PSS_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1229,7 +1229,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_ECDH1_DERIVE_PARAMS_PTR) malloc(sizeof(CK_ECDH1_DERIVE_PARAMS));
|
ckpParam = (CK_ECDH1_DERIVE_PARAMS_PTR) malloc(sizeof(CK_ECDH1_DERIVE_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,7 +1256,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_ECDH2_DERIVE_PARAMS_PTR) malloc(sizeof(CK_ECDH2_DERIVE_PARAMS));
|
ckpParam = (CK_ECDH2_DERIVE_PARAMS_PTR) malloc(sizeof(CK_ECDH2_DERIVE_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1283,7 +1283,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_X9_42_DH1_DERIVE_PARAMS_PTR) malloc(sizeof(CK_X9_42_DH1_DERIVE_PARAMS));
|
ckpParam = (CK_X9_42_DH1_DERIVE_PARAMS_PTR) malloc(sizeof(CK_X9_42_DH1_DERIVE_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,7 +1310,7 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||||
|
|
||||||
ckpParam = (CK_X9_42_DH2_DERIVE_PARAMS_PTR) malloc(sizeof(CK_X9_42_DH2_DERIVE_PARAMS));
|
ckpParam = (CK_X9_42_DH2_DERIVE_PARAMS_PTR) malloc(sizeof(CK_X9_42_DH2_DERIVE_PARAMS));
|
||||||
if (ckpParam == NULL) {
|
if (ckpParam == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestSingle
|
||||||
/* always use single part op, even for large data */
|
/* always use single part op, even for large data */
|
||||||
bufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
|
bufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
|
||||||
if (bufP == NULL) {
|
if (bufP == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestUpdate
|
||||||
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
|
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
|
||||||
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
|
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
|
||||||
if (bufP == NULL) {
|
if (bufP == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestEn
|
||||||
ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE));
|
ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE));
|
||||||
if (ckpEncryptedPart == NULL) {
|
if (ckpEncryptedPart == NULL) {
|
||||||
free(ckpPart);
|
free(ckpPart);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptD
|
||||||
ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE));
|
ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE));
|
||||||
if (ckpPart == NULL) {
|
if (ckpPart == NULL) {
|
||||||
free(ckpEncryptedPart);
|
free(ckpEncryptedPart);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignEncr
|
||||||
ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE));
|
ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE));
|
||||||
if (ckpEncryptedPart == NULL) {
|
if (ckpEncryptedPart == NULL) {
|
||||||
free(ckpPart);
|
free(ckpPart);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptV
|
||||||
ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE));
|
ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE));
|
||||||
if (ckpPart == NULL) {
|
if (ckpPart == NULL) {
|
||||||
free(ckpEncryptedPart);
|
free(ckpEncryptedPart);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,10 @@ jfieldID mech_pParameterID;
|
||||||
jclass jByteArrayClass;
|
jclass jByteArrayClass;
|
||||||
jclass jLongClass;
|
jclass jLongClass;
|
||||||
|
|
||||||
|
JavaVM* jvm = NULL;
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||||
|
jvm = vm;
|
||||||
return JNI_VERSION_1_4;
|
return JNI_VERSION_1_4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +354,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetSlotList
|
||||||
|
|
||||||
ckpSlotList = (CK_SLOT_ID_PTR) malloc(ckTokenNumber * sizeof(CK_SLOT_ID));
|
ckpSlotList = (CK_SLOT_ID_PTR) malloc(ckTokenNumber * sizeof(CK_SLOT_ID));
|
||||||
if (ckpSlotList == NULL) {
|
if (ckpSlotList == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +655,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetMechanismList
|
||||||
ckpMechanismList = (CK_MECHANISM_TYPE_PTR)
|
ckpMechanismList = (CK_MECHANISM_TYPE_PTR)
|
||||||
malloc(ckMechanismNumber * sizeof(CK_MECHANISM_TYPE));
|
malloc(ckMechanismNumber * sizeof(CK_MECHANISM_TYPE));
|
||||||
if (ckpMechanismList == NULL) {
|
if (ckpMechanismList == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Generate
|
||||||
if (ckMechanism.pParameter != NULL_PTR) {
|
if (ckMechanism.pParameter != NULL_PTR) {
|
||||||
free(ckMechanism.pParameter);
|
free(ckMechanism.pParameter);
|
||||||
}
|
}
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ckpPublicKeyHandle = ckpKeyHandles; /* first element of array is Public Key */
|
ckpPublicKeyHandle = ckpKeyHandles; /* first element of array is Public Key */
|
||||||
|
@ -253,7 +253,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1WrapKey
|
||||||
if (ckMechanism.pParameter != NULL_PTR) {
|
if (ckMechanism.pParameter != NULL_PTR) {
|
||||||
free(ckMechanism.pParameter);
|
free(ckMechanism.pParameter);
|
||||||
}
|
}
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
|
||||||
/* convert the Java InitArgs object to a pointer to a CK_C_INITIALIZE_ARGS structure */
|
/* convert the Java InitArgs object to a pointer to a CK_C_INITIALIZE_ARGS structure */
|
||||||
ckpInitArgs = (CK_C_INITIALIZE_ARGS_PTR) malloc(sizeof(CK_C_INITIALIZE_ARGS));
|
ckpInitArgs = (CK_C_INITIALIZE_ARGS_PTR) malloc(sizeof(CK_C_INITIALIZE_ARGS));
|
||||||
if (ckpInitArgs == NULL) {
|
if (ckpInitArgs == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL_PTR;
|
return NULL_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
|
||||||
ckpGlobalInitArgs = (CK_C_INITIALIZE_ARGS_PTR) malloc(sizeof(CK_C_INITIALIZE_ARGS));
|
ckpGlobalInitArgs = (CK_C_INITIALIZE_ARGS_PTR) malloc(sizeof(CK_C_INITIALIZE_ARGS));
|
||||||
if (ckpGlobalInitArgs == NULL) {
|
if (ckpGlobalInitArgs == NULL) {
|
||||||
free(ckpInitArgs);
|
free(ckpInitArgs);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL_PTR;
|
return NULL_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,9 +178,8 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
|
||||||
*/
|
*/
|
||||||
CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex)
|
CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex)
|
||||||
{
|
{
|
||||||
JavaVM *jvm;
|
extern JavaVM *jvm;
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
jsize actualNumberVMs;
|
|
||||||
jint returnValue;
|
jint returnValue;
|
||||||
jthrowable pkcs11Exception;
|
jthrowable pkcs11Exception;
|
||||||
jclass pkcs11ExceptionClass;
|
jclass pkcs11ExceptionClass;
|
||||||
|
@ -196,8 +195,7 @@ CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex)
|
||||||
|
|
||||||
|
|
||||||
/* Get the currently running Java VM */
|
/* Get the currently running Java VM */
|
||||||
returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
|
if (jvm == NULL) { return rv ;} /* there is no VM running */
|
||||||
if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ;} /* there is no VM running */
|
|
||||||
|
|
||||||
/* Determine, if current thread is already attached */
|
/* Determine, if current thread is already attached */
|
||||||
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
||||||
|
@ -273,9 +271,8 @@ CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex)
|
||||||
*/
|
*/
|
||||||
CK_RV callJDestroyMutex(CK_VOID_PTR pMutex)
|
CK_RV callJDestroyMutex(CK_VOID_PTR pMutex)
|
||||||
{
|
{
|
||||||
JavaVM *jvm;
|
extern JavaVM *jvm;
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
jsize actualNumberVMs;
|
|
||||||
jint returnValue;
|
jint returnValue;
|
||||||
jthrowable pkcs11Exception;
|
jthrowable pkcs11Exception;
|
||||||
jclass pkcs11ExceptionClass;
|
jclass pkcs11ExceptionClass;
|
||||||
|
@ -291,8 +288,7 @@ CK_RV callJDestroyMutex(CK_VOID_PTR pMutex)
|
||||||
|
|
||||||
|
|
||||||
/* Get the currently running Java VM */
|
/* Get the currently running Java VM */
|
||||||
returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
|
if (jvm == NULL) { return rv ; } /* there is no VM running */
|
||||||
if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ; } /* there is no VM running */
|
|
||||||
|
|
||||||
/* Determine, if current thread is already attached */
|
/* Determine, if current thread is already attached */
|
||||||
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
||||||
|
@ -367,9 +363,8 @@ CK_RV callJDestroyMutex(CK_VOID_PTR pMutex)
|
||||||
*/
|
*/
|
||||||
CK_RV callJLockMutex(CK_VOID_PTR pMutex)
|
CK_RV callJLockMutex(CK_VOID_PTR pMutex)
|
||||||
{
|
{
|
||||||
JavaVM *jvm;
|
extern JavaVM *jvm;
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
jsize actualNumberVMs;
|
|
||||||
jint returnValue;
|
jint returnValue;
|
||||||
jthrowable pkcs11Exception;
|
jthrowable pkcs11Exception;
|
||||||
jclass pkcs11ExceptionClass;
|
jclass pkcs11ExceptionClass;
|
||||||
|
@ -385,8 +380,7 @@ CK_RV callJLockMutex(CK_VOID_PTR pMutex)
|
||||||
|
|
||||||
|
|
||||||
/* Get the currently running Java VM */
|
/* Get the currently running Java VM */
|
||||||
returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
|
if (jvm == NULL) { return rv ; } /* there is no VM running */
|
||||||
if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ; } /* there is no VM running */
|
|
||||||
|
|
||||||
/* Determine, if current thread is already attached */
|
/* Determine, if current thread is already attached */
|
||||||
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
||||||
|
@ -457,9 +451,8 @@ CK_RV callJLockMutex(CK_VOID_PTR pMutex)
|
||||||
*/
|
*/
|
||||||
CK_RV callJUnlockMutex(CK_VOID_PTR pMutex)
|
CK_RV callJUnlockMutex(CK_VOID_PTR pMutex)
|
||||||
{
|
{
|
||||||
JavaVM *jvm;
|
extern JavaVM *jvm;
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
jsize actualNumberVMs;
|
|
||||||
jint returnValue;
|
jint returnValue;
|
||||||
jthrowable pkcs11Exception;
|
jthrowable pkcs11Exception;
|
||||||
jclass pkcs11ExceptionClass;
|
jclass pkcs11ExceptionClass;
|
||||||
|
@ -475,8 +468,7 @@ CK_RV callJUnlockMutex(CK_VOID_PTR pMutex)
|
||||||
|
|
||||||
|
|
||||||
/* Get the currently running Java VM */
|
/* Get the currently running Java VM */
|
||||||
returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
|
if (jvm == NULL) { return rv ; } /* there is no VM running */
|
||||||
if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ; } /* there is no VM running */
|
|
||||||
|
|
||||||
/* Determine, if current thread is already attached */
|
/* Determine, if current thread is already attached */
|
||||||
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
||||||
|
|
|
@ -258,7 +258,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetAttributeVa
|
||||||
ckpAttributes[i].pValue = (void *) malloc(ckBufferLength);
|
ckpAttributes[i].pValue = (void *) malloc(ckBufferLength);
|
||||||
if (ckpAttributes[i].pValue == NULL) {
|
if (ckpAttributes[i].pValue == NULL) {
|
||||||
freeCKAttributeArray(ckpAttributes, i);
|
freeCKAttributeArray(ckpAttributes, i);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ckpAttributes[i].ulValueLen = ckBufferLength;
|
ckpAttributes[i].ulValueLen = ckBufferLength;
|
||||||
|
@ -390,7 +390,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1FindObje
|
||||||
ckMaxObjectLength = jLongToCKULong(jMaxObjectCount);
|
ckMaxObjectLength = jLongToCKULong(jMaxObjectCount);
|
||||||
ckpObjectHandleArray = (CK_OBJECT_HANDLE_PTR) malloc(sizeof(CK_OBJECT_HANDLE) * ckMaxObjectLength);
|
ckpObjectHandleArray = (CK_OBJECT_HANDLE_PTR) malloc(sizeof(CK_OBJECT_HANDLE) * ckMaxObjectLength);
|
||||||
if (ckpObjectHandleArray == NULL) {
|
if (ckpObjectHandleArray == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1OpenSession
|
||||||
if (jNotify != NULL) {
|
if (jNotify != NULL) {
|
||||||
notifyEncapsulation = (NotifyEncapsulation *) malloc(sizeof(NotifyEncapsulation));
|
notifyEncapsulation = (NotifyEncapsulation *) malloc(sizeof(NotifyEncapsulation));
|
||||||
if (notifyEncapsulation == NULL) {
|
if (notifyEncapsulation == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
notifyEncapsulation->jApplicationData = (jApplication != NULL)
|
notifyEncapsulation->jApplicationData = (jApplication != NULL)
|
||||||
|
@ -301,7 +301,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetOpera
|
||||||
|
|
||||||
ckpState = (CK_BYTE_PTR) malloc(ckStateLength);
|
ckpState = (CK_BYTE_PTR) malloc(ckStateLength);
|
||||||
if (ckpState == NULL) {
|
if (ckpState == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ void putNotifyEntry(JNIEnv *env, CK_SESSION_HANDLE hSession, NotifyEncapsulation
|
||||||
|
|
||||||
newNode = (NotifyListNode *) malloc(sizeof(NotifyListNode));
|
newNode = (NotifyListNode *) malloc(sizeof(NotifyListNode));
|
||||||
if (newNode == NULL) {
|
if (newNode == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newNode->hSession = hSession;
|
newNode->hSession = hSession;
|
||||||
|
@ -558,9 +558,8 @@ CK_RV notifyCallback(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
NotifyEncapsulation *notifyEncapsulation;
|
NotifyEncapsulation *notifyEncapsulation;
|
||||||
JavaVM *jvm;
|
extern JavaVM *jvm;
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
jsize actualNumberVMs;
|
|
||||||
jint returnValue;
|
jint returnValue;
|
||||||
jlong jSessionHandle;
|
jlong jSessionHandle;
|
||||||
jlong jEvent;
|
jlong jEvent;
|
||||||
|
@ -577,8 +576,7 @@ CK_RV notifyCallback(
|
||||||
notifyEncapsulation = (NotifyEncapsulation *) pApplication;
|
notifyEncapsulation = (NotifyEncapsulation *) pApplication;
|
||||||
|
|
||||||
/* Get the currently running Java VM */
|
/* Get the currently running Java VM */
|
||||||
returnValue = JNI_GetCreatedJavaVMs(&jvm, (jsize) 1, &actualNumberVMs);
|
if (jvm == NULL) { return rv ; } /* there is no VM running */
|
||||||
if ((returnValue != 0) || (actualNumberVMs <= 0)) { return rv ; } /* there is no VM running */
|
|
||||||
|
|
||||||
/* Determine, if current thread is already attached */
|
/* Determine, if current thread is already attached */
|
||||||
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
returnValue = (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_2);
|
||||||
|
|
|
@ -132,7 +132,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Sign
|
||||||
ckpSignature = (CK_BYTE_PTR) malloc(ckSignatureLength * sizeof(CK_BYTE));
|
ckpSignature = (CK_BYTE_PTR) malloc(ckSignatureLength * sizeof(CK_BYTE));
|
||||||
if (ckpSignature == NULL) {
|
if (ckpSignature == NULL) {
|
||||||
free(ckpData);
|
free(ckpData);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Sign
|
||||||
ckpSignature = (CK_BYTE_PTR) malloc(256 * sizeof(CK_BYTE));
|
ckpSignature = (CK_BYTE_PTR) malloc(256 * sizeof(CK_BYTE));
|
||||||
if (ckpSignature == NULL) {
|
if (ckpSignature == NULL) {
|
||||||
free(ckpData);
|
free(ckpData);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rv = (*ckpFunctions->C_Sign)(ckSessionHandle, ckpData, ckDataLength, ckpSignature, &ckSignatureLength);
|
rv = (*ckpFunctions->C_Sign)(ckSessionHandle, ckpData, ckDataLength, ckpSignature, &ckSignatureLength);
|
||||||
|
@ -156,7 +156,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Sign
|
||||||
ckpSignature = (CK_BYTE_PTR) malloc(ckSignatureLength * sizeof(CK_BYTE));
|
ckpSignature = (CK_BYTE_PTR) malloc(ckSignatureLength * sizeof(CK_BYTE));
|
||||||
if (ckpSignature == NULL) {
|
if (ckpSignature == NULL) {
|
||||||
free(ckpData);
|
free(ckpData);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rv = (*ckpFunctions->C_Sign)(ckSessionHandle, ckpData, ckDataLength, ckpSignature, &ckSignatureLength);
|
rv = (*ckpFunctions->C_Sign)(ckSessionHandle, ckpData, ckDataLength, ckpSignature, &ckSignatureLength);
|
||||||
|
@ -210,7 +210,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignUpdate
|
||||||
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
|
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
|
||||||
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
|
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
|
||||||
if (bufP == NULL) {
|
if (bufP == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignFina
|
||||||
if (rv == CKR_BUFFER_TOO_SMALL) {
|
if (rv == CKR_BUFFER_TOO_SMALL) {
|
||||||
bufP = (CK_BYTE_PTR) malloc(ckSignatureLength);
|
bufP = (CK_BYTE_PTR) malloc(ckSignatureLength);
|
||||||
if (bufP == NULL) {
|
if (bufP == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rv = (*ckpFunctions->C_SignFinal)(ckSessionHandle, bufP, &ckSignatureLength);
|
rv = (*ckpFunctions->C_SignFinal)(ckSessionHandle, bufP, &ckSignatureLength);
|
||||||
|
@ -355,7 +355,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignRecover
|
||||||
} else {
|
} else {
|
||||||
inBufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
|
inBufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
|
||||||
if (inBufP == NULL) {
|
if (inBufP == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignRecover
|
||||||
if (inBufP != INBUF) {
|
if (inBufP != INBUF) {
|
||||||
free(inBufP);
|
free(inBufP);
|
||||||
}
|
}
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rv = (*ckpFunctions->C_SignRecover)(ckSessionHandle, inBufP, jInLen, outBufP, &ckSignatureLength);
|
rv = (*ckpFunctions->C_SignRecover)(ckSessionHandle, inBufP, jInLen, outBufP, &ckSignatureLength);
|
||||||
|
@ -508,7 +508,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1VerifyUpdate
|
||||||
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
|
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
|
||||||
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
|
bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
|
||||||
if (bufP == NULL) {
|
if (bufP == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1VerifyRecover
|
||||||
} else {
|
} else {
|
||||||
inBufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
|
inBufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
|
||||||
if (inBufP == NULL) {
|
if (inBufP == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -656,7 +656,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1VerifyRecover
|
||||||
outBufP = (CK_BYTE_PTR) malloc(ckDataLength);
|
outBufP = (CK_BYTE_PTR) malloc(ckDataLength);
|
||||||
if (outBufP == NULL) {
|
if (outBufP == NULL) {
|
||||||
if (inBufP != INBUF) { free(inBufP); }
|
if (inBufP != INBUF) { free(inBufP); }
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rv = (*ckpFunctions->C_VerifyRecover)(ckSessionHandle, inBufP, jInLen, outBufP, &ckDataLength);
|
rv = (*ckpFunctions->C_VerifyRecover)(ckSessionHandle, inBufP, jInLen, outBufP, &ckDataLength);
|
||||||
|
|
|
@ -213,28 +213,52 @@ jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue)
|
||||||
return jErrorCode ;
|
return jErrorCode ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function simply throws an IOException
|
* Throws a Java Exception by name
|
||||||
*
|
|
||||||
* @param env Used to call JNI funktions and to get the Exception class.
|
|
||||||
* @param message The message string of the Exception object.
|
|
||||||
*/
|
*/
|
||||||
void throwIOException(JNIEnv *env, const char *message)
|
void throwByName(JNIEnv *env, const char *name, const char *msg)
|
||||||
{
|
{
|
||||||
JNU_ThrowByName(env, CLASS_IO_EXCEPTION, message);
|
jclass cls = (*env)->FindClass(env, name);
|
||||||
|
|
||||||
|
if (cls != 0) /* Otherwise an exception has already been thrown */
|
||||||
|
(*env)->ThrowNew(env, cls, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Throws java.lang.OutOfMemoryError
|
||||||
|
*/
|
||||||
|
void throwOutOfMemoryError(JNIEnv *env, const char *msg)
|
||||||
|
{
|
||||||
|
throwByName(env, "java/lang/OutOfMemoryError", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Throws java.lang.NullPointerException
|
||||||
|
*/
|
||||||
|
void throwNullPointerException(JNIEnv *env, const char *msg)
|
||||||
|
{
|
||||||
|
throwByName(env, "java/lang/NullPointerException", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Throws java.io.IOException
|
||||||
|
*/
|
||||||
|
void throwIOException(JNIEnv *env, const char *msg)
|
||||||
|
{
|
||||||
|
throwByName(env, "java/io/IOException", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function simply throws a PKCS#11RuntimeException with the given
|
* This function simply throws a PKCS#11RuntimeException with the given
|
||||||
* string as its message. If the message is NULL, the exception is created
|
* string as its message.
|
||||||
* using the default constructor.
|
|
||||||
*
|
*
|
||||||
* @param env Used to call JNI funktions and to get the Exception class.
|
* @param env Used to call JNI funktions and to get the Exception class.
|
||||||
* @param jmessage The message string of the Exception object.
|
* @param jmessage The message string of the Exception object.
|
||||||
*/
|
*/
|
||||||
void throwPKCS11RuntimeException(JNIEnv *env, const char *message)
|
void throwPKCS11RuntimeException(JNIEnv *env, const char *message)
|
||||||
{
|
{
|
||||||
JNU_ThrowByName(env, CLASS_PKCS11RUNTIMEEXCEPTION, message);
|
throwByName(env, CLASS_PKCS11RUNTIMEEXCEPTION, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -318,7 +342,7 @@ void jBooleanArrayToCKBBoolArray(JNIEnv *env, const jbooleanArray jArray, CK_BBO
|
||||||
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
||||||
jpTemp = (jboolean*) malloc((*ckpLength) * sizeof(jboolean));
|
jpTemp = (jboolean*) malloc((*ckpLength) * sizeof(jboolean));
|
||||||
if (jpTemp == NULL) {
|
if (jpTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*env)->GetBooleanArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
|
(*env)->GetBooleanArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
|
||||||
|
@ -330,7 +354,7 @@ void jBooleanArrayToCKBBoolArray(JNIEnv *env, const jbooleanArray jArray, CK_BBO
|
||||||
*ckpArray = (CK_BBOOL*) malloc ((*ckpLength) * sizeof(CK_BBOOL));
|
*ckpArray = (CK_BBOOL*) malloc ((*ckpLength) * sizeof(CK_BBOOL));
|
||||||
if (*ckpArray == NULL) {
|
if (*ckpArray == NULL) {
|
||||||
free(jpTemp);
|
free(jpTemp);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i=0; i<(*ckpLength); i++) {
|
for (i=0; i<(*ckpLength); i++) {
|
||||||
|
@ -360,7 +384,7 @@ void jByteArrayToCKByteArray(JNIEnv *env, const jbyteArray jArray, CK_BYTE_PTR *
|
||||||
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
||||||
jpTemp = (jbyte*) malloc((*ckpLength) * sizeof(jbyte));
|
jpTemp = (jbyte*) malloc((*ckpLength) * sizeof(jbyte));
|
||||||
if (jpTemp == NULL) {
|
if (jpTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*env)->GetByteArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
|
(*env)->GetByteArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
|
||||||
|
@ -376,7 +400,7 @@ void jByteArrayToCKByteArray(JNIEnv *env, const jbyteArray jArray, CK_BYTE_PTR *
|
||||||
*ckpArray = (CK_BYTE_PTR) malloc ((*ckpLength) * sizeof(CK_BYTE));
|
*ckpArray = (CK_BYTE_PTR) malloc ((*ckpLength) * sizeof(CK_BYTE));
|
||||||
if (*ckpArray == NULL) {
|
if (*ckpArray == NULL) {
|
||||||
free(jpTemp);
|
free(jpTemp);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i=0; i<(*ckpLength); i++) {
|
for (i=0; i<(*ckpLength); i++) {
|
||||||
|
@ -407,7 +431,7 @@ void jLongArrayToCKULongArray(JNIEnv *env, const jlongArray jArray, CK_ULONG_PTR
|
||||||
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
||||||
jTemp = (jlong*) malloc((*ckpLength) * sizeof(jlong));
|
jTemp = (jlong*) malloc((*ckpLength) * sizeof(jlong));
|
||||||
if (jTemp == NULL) {
|
if (jTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*env)->GetLongArrayRegion(env, jArray, 0, *ckpLength, jTemp);
|
(*env)->GetLongArrayRegion(env, jArray, 0, *ckpLength, jTemp);
|
||||||
|
@ -419,7 +443,7 @@ void jLongArrayToCKULongArray(JNIEnv *env, const jlongArray jArray, CK_ULONG_PTR
|
||||||
*ckpArray = (CK_ULONG_PTR) malloc (*ckpLength * sizeof(CK_ULONG));
|
*ckpArray = (CK_ULONG_PTR) malloc (*ckpLength * sizeof(CK_ULONG));
|
||||||
if (*ckpArray == NULL) {
|
if (*ckpArray == NULL) {
|
||||||
free(jTemp);
|
free(jTemp);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i=0; i<(*ckpLength); i++) {
|
for (i=0; i<(*ckpLength); i++) {
|
||||||
|
@ -449,7 +473,7 @@ void jCharArrayToCKCharArray(JNIEnv *env, const jcharArray jArray, CK_CHAR_PTR *
|
||||||
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
||||||
jpTemp = (jchar*) malloc((*ckpLength) * sizeof(jchar));
|
jpTemp = (jchar*) malloc((*ckpLength) * sizeof(jchar));
|
||||||
if (jpTemp == NULL) {
|
if (jpTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*env)->GetCharArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
|
(*env)->GetCharArrayRegion(env, jArray, 0, *ckpLength, jpTemp);
|
||||||
|
@ -461,7 +485,7 @@ void jCharArrayToCKCharArray(JNIEnv *env, const jcharArray jArray, CK_CHAR_PTR *
|
||||||
*ckpArray = (CK_CHAR_PTR) malloc (*ckpLength * sizeof(CK_CHAR));
|
*ckpArray = (CK_CHAR_PTR) malloc (*ckpLength * sizeof(CK_CHAR));
|
||||||
if (*ckpArray == NULL) {
|
if (*ckpArray == NULL) {
|
||||||
free(jpTemp);
|
free(jpTemp);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i=0; i<(*ckpLength); i++) {
|
for (i=0; i<(*ckpLength); i++) {
|
||||||
|
@ -491,7 +515,7 @@ void jCharArrayToCKUTF8CharArray(JNIEnv *env, const jcharArray jArray, CK_UTF8CH
|
||||||
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
*ckpLength = (*env)->GetArrayLength(env, jArray);
|
||||||
jTemp = (jchar*) malloc((*ckpLength) * sizeof(jchar));
|
jTemp = (jchar*) malloc((*ckpLength) * sizeof(jchar));
|
||||||
if (jTemp == NULL) {
|
if (jTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*env)->GetCharArrayRegion(env, jArray, 0, *ckpLength, jTemp);
|
(*env)->GetCharArrayRegion(env, jArray, 0, *ckpLength, jTemp);
|
||||||
|
@ -503,7 +527,7 @@ void jCharArrayToCKUTF8CharArray(JNIEnv *env, const jcharArray jArray, CK_UTF8CH
|
||||||
*ckpArray = (CK_UTF8CHAR_PTR) malloc (*ckpLength * sizeof(CK_UTF8CHAR));
|
*ckpArray = (CK_UTF8CHAR_PTR) malloc (*ckpLength * sizeof(CK_UTF8CHAR));
|
||||||
if (*ckpArray == NULL) {
|
if (*ckpArray == NULL) {
|
||||||
free(jTemp);
|
free(jTemp);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i=0; i<(*ckpLength); i++) {
|
for (i=0; i<(*ckpLength); i++) {
|
||||||
|
@ -538,7 +562,7 @@ void jStringToCKUTF8CharArray(JNIEnv *env, const jstring jArray, CK_UTF8CHAR_PTR
|
||||||
*ckpArray = (CK_UTF8CHAR_PTR) malloc((*ckpLength + 1) * sizeof(CK_UTF8CHAR));
|
*ckpArray = (CK_UTF8CHAR_PTR) malloc((*ckpLength + 1) * sizeof(CK_UTF8CHAR));
|
||||||
if (*ckpArray == NULL) {
|
if (*ckpArray == NULL) {
|
||||||
(*env)->ReleaseStringUTFChars(env, (jstring) jArray, pCharArray);
|
(*env)->ReleaseStringUTFChars(env, (jstring) jArray, pCharArray);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strcpy((char*)*ckpArray, pCharArray);
|
strcpy((char*)*ckpArray, pCharArray);
|
||||||
|
@ -571,7 +595,7 @@ void jAttributeArrayToCKAttributeArray(JNIEnv *env, jobjectArray jArray, CK_ATTR
|
||||||
*ckpLength = jLongToCKULong(jLength);
|
*ckpLength = jLongToCKULong(jLength);
|
||||||
*ckpArray = (CK_ATTRIBUTE_PTR) malloc(*ckpLength * sizeof(CK_ATTRIBUTE));
|
*ckpArray = (CK_ATTRIBUTE_PTR) malloc(*ckpLength * sizeof(CK_ATTRIBUTE));
|
||||||
if (*ckpArray == NULL) {
|
if (*ckpArray == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TRACE1(", converting %d attibutes", jLength);
|
TRACE1(", converting %d attibutes", jLength);
|
||||||
|
@ -613,7 +637,7 @@ jbyteArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_U
|
||||||
} else {
|
} else {
|
||||||
jpTemp = (jbyte*) malloc((ckLength) * sizeof(jbyte));
|
jpTemp = (jbyte*) malloc((ckLength) * sizeof(jbyte));
|
||||||
if (jpTemp == NULL) {
|
if (jpTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i=0; i<ckLength; i++) {
|
for (i=0; i<ckLength; i++) {
|
||||||
|
@ -647,7 +671,7 @@ jlongArray ckULongArrayToJLongArray(JNIEnv *env, const CK_ULONG_PTR ckpArray, CK
|
||||||
|
|
||||||
jpTemp = (jlong*) malloc((ckLength) * sizeof(jlong));
|
jpTemp = (jlong*) malloc((ckLength) * sizeof(jlong));
|
||||||
if (jpTemp == NULL) {
|
if (jpTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i=0; i<ckLength; i++) {
|
for (i=0; i<ckLength; i++) {
|
||||||
|
@ -678,7 +702,7 @@ jcharArray ckCharArrayToJCharArray(JNIEnv *env, const CK_CHAR_PTR ckpArray, CK_U
|
||||||
|
|
||||||
jpTemp = (jchar*) malloc(ckLength * sizeof(jchar));
|
jpTemp = (jchar*) malloc(ckLength * sizeof(jchar));
|
||||||
if (jpTemp == NULL) {
|
if (jpTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i=0; i<ckLength; i++) {
|
for (i=0; i<ckLength; i++) {
|
||||||
|
@ -709,7 +733,7 @@ jcharArray ckUTF8CharArrayToJCharArray(JNIEnv *env, const CK_UTF8CHAR_PTR ckpArr
|
||||||
|
|
||||||
jpTemp = (jchar*) malloc(ckLength * sizeof(jchar));
|
jpTemp = (jchar*) malloc(ckLength * sizeof(jchar));
|
||||||
if (jpTemp == NULL) {
|
if (jpTemp == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i=0; i<ckLength; i++) {
|
for (i=0; i<ckLength; i++) {
|
||||||
|
@ -812,7 +836,7 @@ CK_BBOOL* jBooleanObjectToCKBBoolPtr(JNIEnv *env, jobject jObject)
|
||||||
jValue = (*env)->CallBooleanMethod(env, jObject, jValueMethod);
|
jValue = (*env)->CallBooleanMethod(env, jObject, jValueMethod);
|
||||||
ckpValue = (CK_BBOOL *) malloc(sizeof(CK_BBOOL));
|
ckpValue = (CK_BBOOL *) malloc(sizeof(CK_BBOOL));
|
||||||
if (ckpValue == NULL) {
|
if (ckpValue == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*ckpValue = jBooleanToCKBBool(jValue);
|
*ckpValue = jBooleanToCKBBool(jValue);
|
||||||
|
@ -842,7 +866,7 @@ CK_BYTE_PTR jByteObjectToCKBytePtr(JNIEnv *env, jobject jObject)
|
||||||
jValue = (*env)->CallByteMethod(env, jObject, jValueMethod);
|
jValue = (*env)->CallByteMethod(env, jObject, jValueMethod);
|
||||||
ckpValue = (CK_BYTE_PTR) malloc(sizeof(CK_BYTE));
|
ckpValue = (CK_BYTE_PTR) malloc(sizeof(CK_BYTE));
|
||||||
if (ckpValue == NULL) {
|
if (ckpValue == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*ckpValue = jByteToCKByte(jValue);
|
*ckpValue = jByteToCKByte(jValue);
|
||||||
|
@ -871,7 +895,7 @@ CK_ULONG* jIntegerObjectToCKULongPtr(JNIEnv *env, jobject jObject)
|
||||||
jValue = (*env)->CallIntMethod(env, jObject, jValueMethod);
|
jValue = (*env)->CallIntMethod(env, jObject, jValueMethod);
|
||||||
ckpValue = (CK_ULONG *) malloc(sizeof(CK_ULONG));
|
ckpValue = (CK_ULONG *) malloc(sizeof(CK_ULONG));
|
||||||
if (ckpValue == NULL) {
|
if (ckpValue == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*ckpValue = jLongToCKLong(jValue);
|
*ckpValue = jLongToCKLong(jValue);
|
||||||
|
@ -900,7 +924,7 @@ CK_ULONG* jLongObjectToCKULongPtr(JNIEnv *env, jobject jObject)
|
||||||
jValue = (*env)->CallLongMethod(env, jObject, jValueMethod);
|
jValue = (*env)->CallLongMethod(env, jObject, jValueMethod);
|
||||||
ckpValue = (CK_ULONG *) malloc(sizeof(CK_ULONG));
|
ckpValue = (CK_ULONG *) malloc(sizeof(CK_ULONG));
|
||||||
if (ckpValue == NULL) {
|
if (ckpValue == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*ckpValue = jLongToCKULong(jValue);
|
*ckpValue = jLongToCKULong(jValue);
|
||||||
|
@ -930,7 +954,7 @@ CK_CHAR_PTR jCharObjectToCKCharPtr(JNIEnv *env, jobject jObject)
|
||||||
jValue = (*env)->CallCharMethod(env, jObject, jValueMethod);
|
jValue = (*env)->CallCharMethod(env, jObject, jValueMethod);
|
||||||
ckpValue = (CK_CHAR_PTR) malloc(sizeof(CK_CHAR));
|
ckpValue = (CK_CHAR_PTR) malloc(sizeof(CK_CHAR));
|
||||||
if (ckpValue == NULL) {
|
if (ckpValue == NULL) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*ckpValue = jCharToCKChar(jValue);
|
*ckpValue = jCharToCKChar(jValue);
|
||||||
|
@ -1087,7 +1111,7 @@ void jObjectToPrimitiveCKObjectPtrPtr(JNIEnv *env, jobject jObject, CK_VOID_PTR
|
||||||
malloc((strlen(exceptionMsgPrefix) + strlen(classNameString) + 1));
|
malloc((strlen(exceptionMsgPrefix) + strlen(classNameString) + 1));
|
||||||
if (exceptionMsg == NULL) {
|
if (exceptionMsg == NULL) {
|
||||||
(*env)->ReleaseStringUTFChars(env, jClassNameString, classNameString);
|
(*env)->ReleaseStringUTFChars(env, jClassNameString, classNameString);
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
throwOutOfMemoryError(env, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strcpy(exceptionMsg, exceptionMsgPrefix);
|
strcpy(exceptionMsg, exceptionMsgPrefix);
|
||||||
|
|
|
@ -228,7 +228,6 @@
|
||||||
#define CLASS_PKCS11EXCEPTION "sun/security/pkcs11/wrapper/PKCS11Exception"
|
#define CLASS_PKCS11EXCEPTION "sun/security/pkcs11/wrapper/PKCS11Exception"
|
||||||
#define CLASS_PKCS11RUNTIMEEXCEPTION "sun/security/pkcs11/wrapper/PKCS11RuntimeException"
|
#define CLASS_PKCS11RUNTIMEEXCEPTION "sun/security/pkcs11/wrapper/PKCS11RuntimeException"
|
||||||
#define CLASS_FILE_NOT_FOUND_EXCEPTION "java/io/FileNotFoundException"
|
#define CLASS_FILE_NOT_FOUND_EXCEPTION "java/io/FileNotFoundException"
|
||||||
#define CLASS_IO_EXCEPTION "java/io/IOException"
|
|
||||||
#define CLASS_C_INITIALIZE_ARGS "sun/security/pkcs11/wrapper/CK_C_INITIALIZE_ARGS"
|
#define CLASS_C_INITIALIZE_ARGS "sun/security/pkcs11/wrapper/CK_C_INITIALIZE_ARGS"
|
||||||
#define CLASS_CREATEMUTEX "sun/security/pkcs11/wrapper/CK_CREATEMUTEX"
|
#define CLASS_CREATEMUTEX "sun/security/pkcs11/wrapper/CK_CREATEMUTEX"
|
||||||
#define CLASS_DESTROYMUTEX "sun/security/pkcs11/wrapper/CK_DESTROYMUTEX"
|
#define CLASS_DESTROYMUTEX "sun/security/pkcs11/wrapper/CK_DESTROYMUTEX"
|
||||||
|
@ -280,6 +279,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue);
|
jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue);
|
||||||
|
void throwOutOfMemoryError(JNIEnv *env, const char *message);
|
||||||
|
void throwNullPointerException(JNIEnv *env, const char *message);
|
||||||
void throwIOException(JNIEnv *env, const char *message);
|
void throwIOException(JNIEnv *env, const char *message);
|
||||||
void throwPKCS11RuntimeException(JNIEnv *env, const char *message);
|
void throwPKCS11RuntimeException(JNIEnv *env, const char *message);
|
||||||
void throwDisconnectedRuntimeException(JNIEnv *env);
|
void throwDisconnectedRuntimeException(JNIEnv *env);
|
||||||
|
|
|
@ -40,7 +40,7 @@ void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
|
||||||
if (fAddress == NULL) {
|
if (fAddress == NULL) {
|
||||||
char errorMessage[256];
|
char errorMessage[256];
|
||||||
snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
|
snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
|
||||||
JNU_ThrowNullPointerException(env, errorMessage);
|
throwNullPointerException(env, errorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return fAddress;
|
return fAddress;
|
||||||
|
@ -69,7 +69,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssLoadLibrary
|
||||||
dprintf2("-handle: %u (0X%X)\n", hModule, hModule);
|
dprintf2("-handle: %u (0X%X)\n", hModule, hModule);
|
||||||
|
|
||||||
if (hModule == NULL) {
|
if (hModule == NULL) {
|
||||||
JNU_ThrowIOException(env, dlerror());
|
throwIOException(env, dlerror());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,12 +51,40 @@ FPTR_SCardBeginTransaction scardBeginTransaction;
|
||||||
FPTR_SCardEndTransaction scardEndTransaction;
|
FPTR_SCardEndTransaction scardEndTransaction;
|
||||||
FPTR_SCardControl scardControl;
|
FPTR_SCardControl scardControl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Throws a Java Exception by name
|
||||||
|
*/
|
||||||
|
void throwByName(JNIEnv *env, const char *name, const char *msg)
|
||||||
|
{
|
||||||
|
jclass cls = (*env)->FindClass(env, name);
|
||||||
|
|
||||||
|
if (cls != 0) /* Otherwise an exception has already been thrown */
|
||||||
|
(*env)->ThrowNew(env, cls, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Throws java.lang.NullPointerException
|
||||||
|
*/
|
||||||
|
void throwNullPointerException(JNIEnv *env, const char *msg)
|
||||||
|
{
|
||||||
|
throwByName(env, "java/lang/NullPointerException", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Throws java.io.IOException
|
||||||
|
*/
|
||||||
|
void throwIOException(JNIEnv *env, const char *msg)
|
||||||
|
{
|
||||||
|
throwByName(env, "java/io/IOException", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void *findFunction(JNIEnv *env, void *hModule, char *functionName) {
|
void *findFunction(JNIEnv *env, void *hModule, char *functionName) {
|
||||||
void *fAddress = dlsym(hModule, functionName);
|
void *fAddress = dlsym(hModule, functionName);
|
||||||
if (fAddress == NULL) {
|
if (fAddress == NULL) {
|
||||||
char errorMessage[256];
|
char errorMessage[256];
|
||||||
snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
|
snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
|
||||||
JNU_ThrowNullPointerException(env, errorMessage);
|
throwNullPointerException(env, errorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return fAddress;
|
return fAddress;
|
||||||
|
@ -69,7 +97,7 @@ JNIEXPORT void JNICALL Java_sun_security_smartcardio_PlatformPCSC_initialize
|
||||||
(*env)->ReleaseStringUTFChars(env, jLibName, libName);
|
(*env)->ReleaseStringUTFChars(env, jLibName, libName);
|
||||||
|
|
||||||
if (hModule == NULL) {
|
if (hModule == NULL) {
|
||||||
JNU_ThrowIOException(env, dlerror());
|
throwIOException(env, dlerror());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scardEstablishContext = (FPTR_SCardEstablishContext)findFunction(env, hModule, "SCardEstablishContext");
|
scardEstablishContext = (FPTR_SCardEstablishContext)findFunction(env, hModule, "SCardEstablishContext");
|
||||||
|
|
|
@ -37,7 +37,7 @@ void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
|
||||||
if (fAddress == NULL) {
|
if (fAddress == NULL) {
|
||||||
char errorMessage[256];
|
char errorMessage[256];
|
||||||
_snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
|
_snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
|
||||||
JNU_ThrowNullPointerException(env, errorMessage);
|
throwNullPointerException(env, errorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return fAddress;
|
return fAddress;
|
||||||
|
@ -78,7 +78,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssLoadLibrary
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
dprintf1("-error: %s\n", lpMsgBuf);
|
dprintf1("-error: %s\n", lpMsgBuf);
|
||||||
JNU_ThrowIOException(env, (char*)lpMsgBuf);
|
throwIOException(env, (char*)lpMsgBuf);
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue