Eneboo - Documentación para desarrolladores
|
00001 /* pkcs11.h include file for PKCS #11. 2001 June 25 */ 00002 00003 #ifndef _PKCS11_H_ 00004 #define _PKCS11_H_ 1 00005 00006 #ifdef __cplusplus 00007 extern "C" { 00008 #endif 00009 00010 /* Before including this file (pkcs11.h) (or pkcs11t.h by 00011 * itself), 6 platform-specific macros must be defined. These 00012 * macros are described below, and typical definitions for them 00013 * are also given. Be advised that these definitions can depend 00014 * on both the platform and the compiler used (and possibly also 00015 * on whether a Cryptoki library is linked statically or 00016 * dynamically). 00017 * 00018 * In addition to defining these 6 macros, the packing convention 00019 * for Cryptoki structures should be set. The Cryptoki 00020 * convention on packing is that structures should be 1-byte 00021 * aligned. 00022 * 00023 * If you're using Microsoft Developer Studio 5.0 to produce 00024 * Win32 stuff, this might be done by using the following 00025 * preprocessor directive before including pkcs11.h or pkcs11t.h: 00026 * 00027 * #pragma pack(push, cryptoki, 1) 00028 * 00029 * and using the following preprocessor directive after including 00030 * pkcs11.h or pkcs11t.h: 00031 * 00032 * #pragma pack(pop, cryptoki) 00033 * 00034 * If you're using an earlier version of Microsoft Developer 00035 * Studio to produce Win16 stuff, this might be done by using 00036 * the following preprocessor directive before including 00037 * pkcs11.h or pkcs11t.h: 00038 * 00039 * #pragma pack(1) 00040 * 00041 * In a UNIX environment, you're on your own for this. You might 00042 * not need to do (or be able to do!) anything. 00043 * 00044 * 00045 * Now for the macros: 00046 * 00047 * 00048 * 1. CK_PTR: The indirection string for making a pointer to an 00049 * object. It can be used like this: 00050 * 00051 * typedef CK_BYTE CK_PTR CK_BYTE_PTR; 00052 * 00053 * If you're using Microsoft Developer Studio 5.0 to produce 00054 * Win32 stuff, it might be defined by: 00055 * 00056 * #define CK_PTR * 00057 * 00058 * If you're using an earlier version of Microsoft Developer 00059 * Studio to produce Win16 stuff, it might be defined by: 00060 * 00061 * #define CK_PTR far * 00062 * 00063 * In a typical UNIX environment, it might be defined by: 00064 * 00065 * #define CK_PTR * 00066 * 00067 * 00068 * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes 00069 * an exportable Cryptoki library function definition out of a 00070 * return type and a function name. It should be used in the 00071 * following fashion to define the exposed Cryptoki functions in 00072 * a Cryptoki library: 00073 * 00074 * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)( 00075 * CK_VOID_PTR pReserved 00076 * ) 00077 * { 00078 * ... 00079 * } 00080 * 00081 * If you're using Microsoft Developer Studio 5.0 to define a 00082 * function in a Win32 Cryptoki .dll, it might be defined by: 00083 * 00084 * #define CK_DEFINE_FUNCTION(returnType, name) \ 00085 * returnType __declspec(dllexport) name 00086 * 00087 * If you're using an earlier version of Microsoft Developer 00088 * Studio to define a function in a Win16 Cryptoki .dll, it 00089 * might be defined by: 00090 * 00091 * #define CK_DEFINE_FUNCTION(returnType, name) \ 00092 * returnType __export _far _pascal name 00093 * 00094 * In a UNIX environment, it might be defined by: 00095 * 00096 * #define CK_DEFINE_FUNCTION(returnType, name) \ 00097 * returnType name 00098 * 00099 * 00100 * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes 00101 * an importable Cryptoki library function declaration out of a 00102 * return type and a function name. It should be used in the 00103 * following fashion: 00104 * 00105 * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)( 00106 * CK_VOID_PTR pReserved 00107 * ); 00108 * 00109 * If you're using Microsoft Developer Studio 5.0 to declare a 00110 * function in a Win32 Cryptoki .dll, it might be defined by: 00111 * 00112 * #define CK_DECLARE_FUNCTION(returnType, name) \ 00113 * returnType __declspec(dllimport) name 00114 * 00115 * If you're using an earlier version of Microsoft Developer 00116 * Studio to declare a function in a Win16 Cryptoki .dll, it 00117 * might be defined by: 00118 * 00119 * #define CK_DECLARE_FUNCTION(returnType, name) \ 00120 * returnType __export _far _pascal name 00121 * 00122 * In a UNIX environment, it might be defined by: 00123 * 00124 * #define CK_DECLARE_FUNCTION(returnType, name) \ 00125 * returnType name 00126 * 00127 * 00128 * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro 00129 * which makes a Cryptoki API function pointer declaration or 00130 * function pointer type declaration out of a return type and a 00131 * function name. It should be used in the following fashion: 00132 * 00133 * // Define funcPtr to be a pointer to a Cryptoki API function 00134 * // taking arguments args and returning CK_RV. 00135 * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args); 00136 * 00137 * or 00138 * 00139 * // Define funcPtrType to be the type of a pointer to a 00140 * // Cryptoki API function taking arguments args and returning 00141 * // CK_RV, and then define funcPtr to be a variable of type 00142 * // funcPtrType. 00143 * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args); 00144 * funcPtrType funcPtr; 00145 * 00146 * If you're using Microsoft Developer Studio 5.0 to access 00147 * functions in a Win32 Cryptoki .dll, in might be defined by: 00148 * 00149 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ 00150 * returnType __declspec(dllimport) (* name) 00151 * 00152 * If you're using an earlier version of Microsoft Developer 00153 * Studio to access functions in a Win16 Cryptoki .dll, it might 00154 * be defined by: 00155 * 00156 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ 00157 * returnType __export _far _pascal (* name) 00158 * 00159 * In a UNIX environment, it might be defined by: 00160 * 00161 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ 00162 * returnType (* name) 00163 * 00164 * 00165 * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes 00166 * a function pointer type for an application callback out of 00167 * a return type for the callback and a name for the callback. 00168 * It should be used in the following fashion: 00169 * 00170 * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args); 00171 * 00172 * to declare a function pointer, myCallback, to a callback 00173 * which takes arguments args and returns a CK_RV. It can also 00174 * be used like this: 00175 * 00176 * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args); 00177 * myCallbackType myCallback; 00178 * 00179 * If you're using Microsoft Developer Studio 5.0 to do Win32 00180 * Cryptoki development, it might be defined by: 00181 * 00182 * #define CK_CALLBACK_FUNCTION(returnType, name) \ 00183 * returnType (* name) 00184 * 00185 * If you're using an earlier version of Microsoft Developer 00186 * Studio to do Win16 development, it might be defined by: 00187 * 00188 * #define CK_CALLBACK_FUNCTION(returnType, name) \ 00189 * returnType _far _pascal (* name) 00190 * 00191 * In a UNIX environment, it might be defined by: 00192 * 00193 * #define CK_CALLBACK_FUNCTION(returnType, name) \ 00194 * returnType (* name) 00195 * 00196 * 00197 * 6. NULL_PTR: This macro is the value of a NULL pointer. 00198 * 00199 * In any ANSI/ISO C environment (and in many others as well), 00200 * this should best be defined by 00201 * 00202 * #ifndef NULL_PTR 00203 * #define NULL_PTR 0 00204 * #endif 00205 */ 00206 00207 #ifndef WIN32 00208 #include "unix.h" 00209 #else 00210 #include "cryptoki.h" 00211 #endif 00212 00213 /* All the various Cryptoki types and #define'd values are in the 00214 * file pkcs11t.h. */ 00215 #include "pkcs11t.h" 00216 00217 #define __PASTE(x,y) x##y 00218 00219 00220 /* ============================================================== 00221 * Define the "extern" form of all the entry points. 00222 * ============================================================== 00223 */ 00224 00225 #define CK_NEED_ARG_LIST 1 00226 #define CK_PKCS11_FUNCTION_INFO(name) \ 00227 extern CK_DECLARE_FUNCTION(CK_RV, name) 00228 00229 /* pkcs11f.h has all the information about the Cryptoki 00230 * function prototypes. */ 00231 #include "pkcs11f.h" 00232 00233 #undef CK_NEED_ARG_LIST 00234 #undef CK_PKCS11_FUNCTION_INFO 00235 00236 00237 /* ============================================================== 00238 * Define the typedef form of all the entry points. That is, for 00239 * each Cryptoki function C_XXX, define a type CK_C_XXX which is 00240 * a pointer to that kind of function. 00241 * ============================================================== 00242 */ 00243 00244 #define CK_NEED_ARG_LIST 1 00245 #define CK_PKCS11_FUNCTION_INFO(name) \ 00246 typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name)) 00247 00248 /* pkcs11f.h has all the information about the Cryptoki 00249 * function prototypes. */ 00250 #include "pkcs11f.h" 00251 00252 #undef CK_NEED_ARG_LIST 00253 #undef CK_PKCS11_FUNCTION_INFO 00254 00255 00256 /* ============================================================== 00257 * Define structed vector of entry points. A CK_FUNCTION_LIST 00258 * contains a CK_VERSION indicating a library's Cryptoki version 00259 * and then a whole slew of function pointers to the routines in 00260 * the library. This type was declared, but not defined, in 00261 * pkcs11t.h. 00262 * ============================================================== 00263 */ 00264 00265 #define CK_PKCS11_FUNCTION_INFO(name) \ 00266 __PASTE(CK_,name) name; 00267 00268 struct CK_FUNCTION_LIST { 00269 00270 CK_VERSION version; /* Cryptoki version */ 00271 00272 /* Pile all the function pointers into the CK_FUNCTION_LIST. */ 00273 /* pkcs11f.h has all the information about the Cryptoki 00274 * function prototypes. */ 00275 #include "pkcs11f.h" 00276 00277 }; 00278 00279 #undef CK_PKCS11_FUNCTION_INFO 00280 00281 00282 #undef __PASTE 00283 00284 #ifdef __cplusplus 00285 } 00286 #endif 00287 00288 #endif