/*
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "pkcs11wrapper.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "sun_security_pkcs11_wrapper_PKCS11.h"
/* declare file private functions */
jobject ckMechanismInfoPtrToJMechanismInfo(JNIEnv *env, const CK_MECHANISM_INFO_PTR ckpMechanismInfo);
/* define variables */
return JNI_VERSION_1_4;
}
/* ************************************************************************** */
/* The native implementation of the methods of the PKCS11Implementation class */
/* ************************************************************************** */
/*
* This method is used to do static initialization. This method is static and
* synchronized. Summary: use this method like a static initialization block.
*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: initializeLibrary
* Signature: ()V
*/
{
#ifndef NO_CALLBACKS
if (notifyListLock == NULL) {
}
#endif
}
}
/* PKCS11 */
if (pNativeDataID == NULL) { return; }
/* CK_MECHANISM */
if (mech_mechanismID == NULL) { return; }
if (mech_pParameterID == NULL) { return; }
if (jByteArrayClass == NULL) { return; }
}
/* This method is designed to do a clean-up. It releases all global resources
* of this library. By now, this function is not called. Calling from
* JNI_OnUnload would be an option, but some VMs do not support JNI_OnUnload.
*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: finalizeLibrary
* Signature: ()V
*/
{
/* XXX
* remove all left lists and release the resources and the lock
* objects that synchroniz access to these lists.
*
removeAllModuleEntries(env);
if (moduleListHead == NULL) { * check, if we removed the last active module *
* remove also the moduleListLock, it is no longer used *
if (moduleListLock != NULL) {
destroyLockObject(env, moduleListLock);
moduleListLock = NULL;
}
#ifndef NO_CALLBACKS
* remove all left notify callback entries *
while (removeFirstNotifyEntry(env));
* remove also the notifyListLock, it is no longer used *
if (notifyListLock != NULL) {
destroyLockObject(env, notifyListLock);
notifyListLock = NULL;
}
if (jInitArgsObject != NULL) {
(*env)->DeleteGlobalRef(env, jInitArgsObject);
}
if (ckpGlobalInitArgs != NULL_PTR) {
free(ckpGlobalInitArgs);
}
#endif * NO_CALLBACKS *
}
*/
}
#ifdef P11_ENABLE_C_INITIALIZE
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_Initialize
* Parametermapping: *PKCS11*
* @param jobject jInitArgs CK_VOID_PTR pInitArgs
*/
{
/*
* Initalize Cryptoki
*/
TRACE0("DEBUG: initializing module... ");
if (ckpFunctions == NULL) {
TRACE0("failed getting module entry");
return;
}
: NULL_PTR;
TRACE0("FINISHED\n");
}
#endif
#ifdef P11_ENABLE_C_FINALIZE
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_Finalize
* Parametermapping: *PKCS11*
* @param jobject jReserved CK_VOID_PTR pReserved
*/
{
/*
* Finalize Cryptoki
*/
if (ckpFunctions == NULL) { return; }
}
#endif
#ifdef P11_ENABLE_C_GETINFO
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_GetInfo
* Parametermapping: *PKCS11*
* @return jobject jInfoObject CK_INFO_PTR pInfo
*/
{
}
return jInfoObject ;
}
/*
* converts a pointer to a CK_INFO structure into a Java CK_INFO Object.
*
* @param env - used to call JNI funktions to create the new Java object
* @param ckpInfo - the pointer to the CK_INFO structure
* @return - the new Java CK_INFO object
*/
{
/* load CK_INFO class */
/* load CK_INFO constructor */
"(Lsun/security/pkcs11/wrapper/CK_VERSION;[CJ[CLsun/security/pkcs11/wrapper/CK_VERSION;)V");
/* prep all fields */
jVendor =
/* create new CK_INFO object */
/* free local references */
return jInfoObject ;
}
#endif
#ifdef P11_ENABLE_C_GETSLOTLIST
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_GetSlotList
* Signature: (Z)[J
* Parametermapping: *PKCS11*
* @param jboolean jTokenPresent CK_BBOOL tokenPresent
* @return jlongArray jSlotList CK_SLOT_ID_PTR pSlotList
* CK_ULONG_PTR pulCount
*/
{
if (ckpSlotList == NULL) {
return NULL;
}
}
return jSlotList ;
}
#endif
#ifdef P11_ENABLE_C_GETSLOTINFO
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_GetSlotInfo
* Signature: (J)Lsun/security/pkcs11/wrapper/CK_SLOT_INFO;
* Parametermapping: *PKCS11*
* @param jlong jSlotID CK_SLOT_ID slotID
* @return jobject jSlotInfoObject CK_SLOT_INFO_PTR pInfo
*/
{
}
return jSlotInfoObject ;
}
/*
* converts a pointer to a CK_SLOT_INFO structure into a Java CK_SLOT_INFO
* Object.
*
* @param env - used to call JNI funktions to create the new Java object
* @param ckpSlotInfo - the pointer to the CK_SLOT_INFO structure
* @return - the new Java CK_SLOT_INFO object
*/
{
/* load CK_SLOT_INFO class */
/* load CK_SLOT_INFO constructor */
"([C[CJLsun/security/pkcs11/wrapper/CK_VERSION;Lsun/security/pkcs11/wrapper/CK_VERSION;)V");
/* prep all fields */
jVendor =
/* create new CK_SLOT_INFO object */
/* free local references */
return jSlotInfoObject ;
}
#endif
#ifdef P11_ENABLE_C_GETTOKENINFO
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_GetTokenInfo
* Signature: (J)Lsun/security/pkcs11/wrapper/CK_TOKEN_INFO;
* Parametermapping: *PKCS11*
* @param jlong jSlotID CK_SLOT_ID slotID
* @return jobject jInfoTokenObject CK_TOKEN_INFO_PTR pInfo
*/
{
}
return jInfoTokenObject ;
}
/*
* converts a pointer to a CK_TOKEN_INFO structure into a Java CK_TOKEN_INFO
* Object.
*
* @param env - used to call JNI funktions to create the new Java object
* @param ckpTokenInfo - the pointer to the CK_TOKEN_INFO structure
* @return - the new Java CK_TOKEN_INFO object
*/
{
/* load CK_TOKEN_INFO class */
/* load CK_TOKEN_INFO constructor */
"([C[C[C[CJJJJJJJJJJJLsun/security/pkcs11/wrapper/CK_VERSION;Lsun/security/pkcs11/wrapper/CK_VERSION;[C)V");
/* prep all fields */
jVendor =
jUtcTime =
/* create new CK_TOKEN_INFO object */
/* free local references */
return jTokenInfoObject ;
}
#endif
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_WaitForSlotEvent
* Parametermapping: *PKCS11*
* @param jlong jFlags CK_FLAGS flags
* @param jobject jReserved CK_VOID_PTR pReserved
* @return jlong jSlotID CK_SLOT_ID_PTR pSlot
*/
{
if (ckpFunctions == NULL) { return 0L; }
}
return jSlotID ;
}
#endif
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_GetMechanismList
* Signature: (J)[J
* Parametermapping: *PKCS11*
* @param jlong jSlotID CK_SLOT_ID slotID
* @return jlongArray jMechanismList CK_MECHANISM_TYPE_PTR pMechanismList
* CK_ULONG_PTR pulCount
*/
{
if (ckpMechanismList == NULL) {
return NULL;
}
}
return jMechanismList ;
}
#endif
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_GetMechanismInfo
* Signature: (JJ)Lsun/security/pkcs11/wrapper/CK_MECHANISM_INFO;
* Parametermapping: *PKCS11*
* @param jlong jSlotID CK_SLOT_ID slotID
* @param jlong jType CK_MECHANISM_TYPE type
* @return jobject jMechanismInfo CK_MECHANISM_INFO_PTR pInfo
*/
{
}
return jMechanismInfo ;
}
/*
* converts a pointer to a CK_MECHANISM_INFO structure into a Java
* CK_MECHANISM_INFO Object.
*
* @param env - used to call JNI funktions to create the new Java object
* @param ckpMechanismInfo - the pointer to the CK_MECHANISM_INFO structure
* @return - the new Java CK_MECHANISM_INFO object
*/
{
/* load CK_MECHANISM_INFO class */
/* load CK_MECHANISM_INFO constructor */
/* prep all fields */
/* create new CK_MECHANISM_INFO object */
/* free local references */
return jMechanismInfoObject ;
}
#endif
#ifdef P11_ENABLE_C_INITTOKEN
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_InitToken
* Signature: (J[C[C)V
* Parametermapping: *PKCS11*
* @param jlong jSlotID CK_SLOT_ID slotID
* @param jcharArray jPin CK_CHAR_PTR pPin
* CK_ULONG ulPinLen
* @param jcharArray jLabel CK_UTF8CHAR_PTR pLabel
*/
{
if (ckpFunctions == NULL) { return; }
/* ckLabelLength <= 32 !!! */
return;
}
}
#endif
#ifdef P11_ENABLE_C_INITPIN
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_InitPIN
* Signature: (J[C)V
* Parametermapping: *PKCS11*
* @param jlong jSessionHandle CK_SESSION_HANDLE
* @param jcharArray jPin CK_CHAR_PTR pPin
* CK_ULONG ulPinLen
*/
{
if (ckpFunctions == NULL) { return; }
}
#endif
#ifdef P11_ENABLE_C_SETPIN
/*
* Class: sun_security_pkcs11_wrapper_PKCS11
* Method: C_SetPIN
* Signature: (J[C[C)V
* Parametermapping: *PKCS11*
* @param jlong jSessionHandle CK_SESSION_HANDLE hSession
* @param jcharArray jOldPin CK_CHAR_PTR pOldPin
* CK_ULONG ulOldLen
* @param jcharArray jNewPin CK_CHAR_PTR pNewPin
* CK_ULONG ulNewLen
*/
{
if (ckpFunctions == NULL) { return; }
return;
}
}
#endif