/* []-----------------------------------[] | | | ||| ||||||||| ||| ||| | | ||| ||| |||| |||| | | ||| ||| ||||||||| | | ||| ||| ||| | ||| | | ||| ||||||||| ||| ||| | | ||| ||| ||| ||| | | ||| ||| ||| ||| | | ||| ||| ||| ||| | | ||||||||| ||||||||| ||| ||| | | | |-----------------------------------| | | | Project: Lite Security Module | | | []-----------------------------------[] Copyright (C) 2005-2009 by Clizio Merli Vercelli, Italy All rights reserved. This package is a Security Module written by Clizio Merli (clizio@clizio.com). This package is free for commercial and non-commercial use as long as the following conditions are aheared to. The following conditions apply to all code found in this distribution, except for the crypto libary used, for which its own conditions apply. The documentation included with this distribution is covered by the same copyright terms. Copyright remains Clizio Merli's, and as such any Copyright notices in the code are not to be removed. If this package is used in a product, Clizio Merli should be given attribution as the author of the parts used. This can be in the form of a textual message at program startup or in documentation (online and/or textual) provided with the package. 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 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 and/or other materials provided with the distribution. 3.All advertising materials mentioning features or use of this software must display the following acknowledgement: "This product includes software written by Clizio Merli (clizio@clizio.com)" THIS SOFTWARE IS PROVIDED BY CLIZIO MERLI "AS IS" AND ANY EXPRESS 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 AUTHOR OR CONTRIBUTORS 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. The licence and distribution terms for any publically available version or derivative of this code cannot be changed. i.e. this code cannot simply be copied and put under another distribution licence [including the GNU Public Licence]. */ /* +------------------------------------------------------+ | pkcs11int.c - LSM PKCS#11 internal definitions | +------------------------------------------------------+ */ #ifndef PKCS11INT_H #define PKCS11INT_H /**/ /*---------------------------------------------------------------------* <<< Defines >>> *---------------------------------------------------------------------*/ #define CRYPTO_INACTIVE 'I' #define CRYPTO_ACTIVE 'A' #ifdef WIN32 #define T_THREAD_MUTEX CRITICAL_SECTION #else #define T_THREAD_MUTEX pthread_mutex_t #endif /**/ /*---------------------------------------------------------------------* <<< Types >>> *---------------------------------------------------------------------*/ struct s_ThrFunctionList { CK_CREATEMUTEX CreateMutex; CK_DESTROYMUTEX DestroyMutex; CK_LOCKMUTEX LockMutex; CK_UNLOCKMUTEX UnlockMutex; }; typedef struct s_ThrFunctionList t_ThrFunctionList; struct s_P11Session /* a simple view of session */ { CK_SESSION_HANDLE Handle; CK_SLOT_ID SlotId; CK_VOID_PTR Application; CK_NOTIFY Notify; /* find object context */ unsigned long FindObjCount; unsigned long FindIndex; CK_OBJECT_HANDLE FindObjSet[MAX_SESSION_OBJECTS]; /* cryptographic context */ unsigned char EncryptState; t_CK_MECHANISM_LSM EncryptMechanism; unsigned char DecryptState; t_CK_MECHANISM_LSM DecryptMechanism; unsigned char SignState; t_CK_MECHANISM_LSM SignMechanism; unsigned char VerifyState; t_CK_MECHANISM_LSM VerifyMechanism; }; typedef struct s_P11Session t_P11Session; struct s_P11Slot { CK_SLOT_ID SlotId; unsigned char SlotName[16+1]; unsigned char TokenName[16+1]; }; typedef struct s_P11Slot t_P11Slot; struct s_P11Process { unsigned long PID; CK_FUNCTION_LIST FuncList; int NumSessions; t_P11Session SessionSet[MAX_SESSIONS_MANAGED]; t_P11Slot SlotSet[MAX_SLOTS_MANAGED]; }; typedef struct s_P11Process t_P11Process; #endif /**/ /*---------------------------------------------------------------------* <<< Procedures >>> *---------------------------------------------------------------------*/ int Lsm11ProtInit (T_THREAD_MUTEX *); int Lsm11ProtTerm (T_THREAD_MUTEX *); int Lsm11ProtLock (T_THREAD_MUTEX *); int Lsm11ProtUnlock (T_THREAD_MUTEX *); /* end of pkcs11int.h */