/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* *Copyright(C)1994-1999RSASecurityInc.Licencetocopythisdocument *isgrantedprovidedthatitisidentifiedas"RSASecurityIn.cPublic-Key *CryptographyStandards(PKCS)"inallmaterialmentioningorreferencing *thisdocument. * *Thelatestversionofthisheadercanbefoundat: *http://www.rsalabs.com/pkcs/pkcs-11/index.html
*/ #ifndef _PKCS11_H_ #define _PKCS11_H_ 1
#ifdef __cplusplus extern"C" { #endif
/* Before including this file (pkcs11.h) (or pkcs11t.h by *itself),6platform-specificmacrosmustbedefined.These *macrosaredescribedbelow,andtypicaldefinitionsforthem *arealsogiven.Beadvisedthatthesedefinitionscandepend *onboththeplatformandthecompilerused(andpossiblyalso *onwhetheraPKCS#11libraryislinkedstaticallyor *dynamically). * *Inadditiontodefiningthese6macros,thepackingconvention *forPKCS#11structuresshouldbeset.ThePKCS#11 *conventiononpackingisthatstructuresshouldbe1-byte *aligned. * *InaWin32environment,thismightbedonebyusingthe *followingpreprocessordirectivebeforeincludingpkcs11.h *orpkcs11t.h: * *#pragmapack(push,cryptoki,1) * *andusingthefollowingpreprocessordirectiveafterincluding *pkcs11.horpkcs11t.h: * *#pragmapack(pop,cryptoki) * *InaUNIXenvironment,you'reonyourownhere.Youmight *notneedtodoanything. * * *Nowforthemacros: * * *1.CK_PTR:Theindirectionstringformakingapointertoan *object.Itcanbeusedlikethis: * *typedefCK_BYTECK_PTRCK_BYTE_PTR; * *InaWin32environment,itmightbedefinedby * *#defineCK_PTR* * *InaUNIXenvironment,itmightbedefinedby * *#defineCK_PTR* * * *2.CK_DEFINE_FUNCTION(returnType,name):Amacrowhichmakes *anexportablePKCS#11libraryfunctiondefinitionoutofa *returntypeandafunctionname.Itshouldbeusedinthe *followingfashiontodefinetheexposedPKCS#11functionsin *aPKCS#11library: * *CK_DEFINE_FUNCTION(CK_RV,C_Initialize)( *CK_VOID_PTRpReserved *) *{ *... *} * *FordefiningafunctioninaWin32PKCS#11.dll,itmightbe *definedby * *#defineCK_DEFINE_FUNCTION(returnType,name)\ *returnType__declspec(dllexport)name * *InaUNIXenvironment,itmightbedefinedby * *#defineCK_DEFINE_FUNCTION(returnType,name)\ *returnTypename * * *3.CK_DECLARE_FUNCTION(returnType,name):Amacrowhichmakes *animportablePKCS#11libraryfunctiondeclarationoutofa *returntypeandafunctionname.Itshouldbeusedinthe *followingfashion: * *externCK_DECLARE_FUNCTION(CK_RV,C_Initialize)( *CK_VOID_PTRpReserved *); * *FordeclaringafunctioninaWin32PKCS#11.dll,itmight *bedefinedby * *#defineCK_DECLARE_FUNCTION(returnType,name)\ *returnType__declspec(dllimport)name * *InaUNIXenvironment,itmightbedefinedby * *#defineCK_DECLARE_FUNCTION(returnType,name)\ *returnTypename * * *4.CK_DECLARE_FUNCTION_POINTER(returnType,name):Amacro *whichmakesaPKCS#11APIfunctionpointerdeclarationor *functionpointertypedeclarationoutofareturntypeanda *functionname.Itshouldbeusedinthefollowingfashion: * *// Define funcPtr to be a pointer to a PKCS #11 API function *// taking arguments args and returning CK_RV. *CK_DECLARE_FUNCTION_POINTER(CK_RV,funcPtr)(args); * *or * *// Define funcPtrType to be the type of a pointer to a *// PKCS #11 API function taking arguments args and returning *// CK_RV, and then define funcPtr to be a variable of type *// funcPtrType. *typedefCK_DECLARE_FUNCTION_POINTER(CK_RV,funcPtrType)(args); *funcPtrTypefuncPtr; * *ForaccessingfunctionsinaWin32PKCS#11.dll,inmightbe *definedby * *#defineCK_DECLARE_FUNCTION_POINTER(returnType,name)\ *returnType__declspec(dllimport)(*name) * *InaUNIXenvironment,itmightbedefinedby * *#defineCK_DECLARE_FUNCTION_POINTER(returnType,name)\ *returnType(*name) * * *5.CK_CALLBACK_FUNCTION(returnType,name):Amacrowhichmakes *afunctionpointertypeforanapplicationcallbackoutof *areturntypeforthecallbackandanameforthecallback. *Itshouldbeusedinthefollowingfashion: * *CK_CALLBACK_FUNCTION(CK_RV,myCallback)(args); * *todeclareafunctionpointer,myCallback,toacallback *whichtakesargumentsargsandreturnsaCK_RV.Itcanalso *beusedlikethis: * *typedefCK_CALLBACK_FUNCTION(CK_RV,myCallbackType)(args); *myCallbackTypemyCallback; * *InaWin32environment,itmightbedefinedby * *#defineCK_CALLBACK_FUNCTION(returnType,name)\ *returnType(*name) * *InaUNIXenvironment,itmightbedefinedby * *#defineCK_CALLBACK_FUNCTION(returnType,name)\ *returnType(*name) * * *6.NULL_PTR:ThismacroisthevalueofaNULLpointer. * *InanyANSI/ISOCenvironment(andinmanyothersaswell), *thisshouldbedefinedby * *#ifndefNULL_PTR *#defineNULL_PTR0 *#endif
*/
/* All the various PKCS #11 types and #define'd values are in the
* file pkcs11t.h. */ #include"pkcs11t.h"
#define __PASTE(x, y) x##y
#ifndef CK_PKCS11_3_0 /* remember that we set it so we can unset it at the end */ #define __NSS_CK_PKCS11_3_IMPLICIT 1 #define CK_PKCS11_3_0 1 #endif
/* Pile all the function pointers into the CK_FUNCTION_LIST_3_0. */ /* pkcs11f.h has all the information about the PKCS #11
* function prototypes. */ #include"pkcs11f.h"
};
#define CK_PKCS11_2_0_ONLY 1
/* now define the 2.0 function list */ struct CK_FUNCTION_LIST {
CK_VERSION version; /* PKCS #11 version */
/* Pile all the function pointers into the CK_FUNCTION_LIST. */ /* pkcs11f.h has all the information about the PKCS #11
* function prototypes. */ #include"pkcs11f.h"
}; #include"pkcs11u.h"
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.